Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program never throws exception when debugger is attached

Tags:

java

ssl

I have a Java based service that is throwing an unexpected SSL exception "Socket is closed"... or sometimes "Data is recieved in a non-data state" when I run it. When I configure a remote debugger by adding jvmArgs: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050 , and then run it it never throws this exception. Is there something about this option that modifies the behaviour of the service?

Exception:

javax.net.ssl.SSLProtocolException: Data received in non-data state: 6
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1061)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:110)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:191)
    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:164)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
    at java.security.DigestInputStream.read(DigestInputStream.java:161)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at com.amazonaws.services.s3.internal.ChecksumValidatingInputStream.read(ChecksumValidatingInputStream.java:97)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:103)
    at javax.crypto.CipherInputStream.read(CipherInputStream.java:224)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at <mypackagenameremovedforanonymity>.GetObjectActivity.enact(GetObjectActivity.java:118)

Context: I am reading from an InputStream that wraps the SSL socket

like image 984
Bug Killer Avatar asked May 12 '26 21:05

Bug Killer


1 Answers

This may be an issue that others have seen with the AWS SDK and Garbage Collection. I had the same kind of issue. Reading from S3 input streams would fail with various socket/SSL errors and when I tried to isolate or debug it, the problem would go away. Turns out the the S3 client connection was getting garbage collected because the input stream was not holding on to it. I found the following link and it solved my problem.

https://forums.aws.amazon.com/thread.jspa?messageID=438171

Rick

P.S. Just to be clear, the above link is for running on the Android, but the problem and solution are generic across all platforms (I ran into it on JDK 7 running on Windows).

like image 168
Dr Rick Avatar answered May 14 '26 13:05

Dr Rick