How to handle this exception

Akintos
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(RealBufferedSource.java:398)
at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:392)
at okhttp3.internal.Util.bomAwareCharset(Util.java:449)
at okhttp3.ResponseBody.string(ResponseBody.java:174)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:24)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:53)
at com.zerodhatech.kiteconnect.KiteConnect.getOrders(KiteConnect.java:382)
at com.katiyar.share.Startup.runInstrumentOrderUpdate(Startup.java:254)
at com.katiyar.share.Startup.run(Startup.java:343)
at java.lang.Thread.run(Thread.java:748)
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());
}
e.printStackTrace();
return;
}

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(ResponseBody.java:174)
    at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:24)
    This leads to illegal state exception which is not thrown by Kite api
Sign In or Register to comment.