How to handle this exception

I have hit the below exception while fetching orders at around Mon Jun 15 12:37:01 IST 2020
Exception in thread "Thread-4" java.lang.IllegalStateException: closed
at okio.RealBufferedSource.rangeEquals(
at okio.RealBufferedSource.rangeEquals(
at okhttp3.internal.Util.bomAwareCharset(
at okhttp3.ResponseBody.string(
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(
at com.zerodhatech.kiteconnect.KiteConnect.getOrders(
at com.katiyar.share.Startup.runInstrumentOrderUpdate(
The exception handler couldn't handle it and exited the code.
try {
OrderList = Startup.KiteConnObj.getOrders();
} catch (JSONException | IOException | KiteException e) {
System.out.println("Getting order caused exception in order update thread. Its ok");
if (e instanceof KiteException) {
System.out.println(((KiteException)e).message +" "+ ((KiteException)e).code +" "+ e.getClass().getName());
} else {
System.out.println(e.getMessage() + " " + e.getClass().getName());

Any ideas how to handle it?
  • sujith
    This isn't related to javakiteconnect. The issue could be somewhere else are you doing UI operations on the background thread?
  • Akintos
    By UI u mean User interface? I dont have any UI
    I thought these two lines in backtrace clearly indicated kite connect code could not handle the response
    at okhttp3.ResponseBody.string(
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(
    This leads to illegal state exception which is not thrown by Kite api
Sign In or Register to comment.