Bug Killer
Bug Killer

Reputation: 661

Program never throws exception when debugger is attached

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

Upvotes: 3

Views: 2837

Answers (3)

AVA
AVA

Reputation: 2558

When the error, Data received in non-data state is thrown, check whether the outputstream of socket is closed but the input stream is not closed and continuing to send/receive data and socket is also not closed. Closing the streams of socket along with socket at the end could help to resolve the issue.

Upvotes: 0

Dr Rick
Dr Rick

Reputation: 56

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).

Upvotes: 4

Danilo Mu&#241;oz
Danilo Mu&#241;oz

Reputation: 623

If you are running your application in linux, try this:

  • run your app and after check the program call using 'ps -aux | grep java'
  • run in debug mode and after check the program call using 'ps -aux | grep java'
  • this will make you sure about the jvm path

Another very important thing is checking your system properties by adding the following code to your app:

System.getProperties().list(System.out);
  • after that, compare the output running your app normally and in debug mode.

Upvotes: 0

Related Questions