Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Set the default timeout values to non-zero #117

Open
arinto opened this issue Sep 30, 2015 · 1 comment
Open

Set the default timeout values to non-zero #117

arinto opened this issue Sep 30, 2015 · 1 comment

Comments

@arinto
Copy link
Contributor

arinto commented Sep 30, 2015

I have long running thread the repeatedly perform API calls and after running for several days, this thread stuck at this point (below it the jstack output):

"pool-3-thread-1" #20 prio=5 os_prio=0 tid=0x00007f30ac4ba000 nid=0x4962 runnable [0x00007f304b56d000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
        at java.net.SocketInputStream.read(SocketInputStream.java:170)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
        at sun.security.ssl.InputRecord.read(InputRecord.java:503)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:961)
        - locked <0x00000005cc52ffa0> (a java.lang.Object)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:918)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
        - locked <0x00000005cc530090> (a sun.security.ssl.AppInputStream)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        - locked <0x00000005cc5300c0> (a java.io.BufferedInputStream)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1535)
        - locked <0x00000005cc530100> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
        - locked <0x00000005cc530100> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
        at org.jinstagram.http.Response.<init>(Response.java:33)
        at org.jinstagram.http.Request.doSend(Request.java:96)
        at org.jinstagram.http.Request.send(Request.java:69)
        at org.jinstagram.Instagram.getApiResponse(Instagram.java:862)
        at org.jinstagram.Instagram.createInstagramObject(Instagram.java:781)
        at org.jinstagram.Instagram.getUserFeedInfoNextPage(Instagram.java:233)
        at xxx.xxx.yyy.run(yyy.java:165)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

According to the output, the thread is waiting for the socketRead0 to finish. And in this case, due to some error, the socketRead0 method is never finish.

We need to have some timeout mechanism to alleviate this issue, and it seems that we can do that via InstagramConfig. I'm testing this solution now, and will update this issue accordingly. CMIIW.

Therefore, to prevent jInstagram users experiencing the same issue, I suggest we set the default values for this configuration to non-zero value.

@Piccirello
Copy link
Contributor

Piccirello commented Dec 4, 2016

I too have had threads get blocked due to a lack of a default timeout. I've since set a timeout with InstagramConfig, but the need to do this is not at all clear from the (lack of) documentation.

Changes proposed in 2dc12f7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants