1

My JDMK based application is getting intermittent IOExceptions at line 313 in com.sun.jdmk.comm.HttpSendSocket and I can't figure out why. All I know from the Javadoc about this is if an I/O error occurs while creating the input stream you'll get an IOException, but I don't know what kind of I/O error occurred or why one did. The code actually worked both before and after this error transpired.

Any tips on how to debug this intermittent problem would be appreciated.

I don't want to paste the source code here for HttpSendSocket since it belongs not to me, but I know it's doing an HttpURLConnection conn.getInputStream() when the IOException exception is thrown.

I thought about trying to create my own version of HttpSendSocket, and adding diagnostics in it, but couldn't figure out how since it's a package protected class.

Stack trace below:

com.sun.jdmk.comm.CommunicationException: java.io.IOException: HTTP request failed
at com.sun.jdmk.comm.HttpSendSocket.readNotify(HttpSendSocket.java:313)
at com.sun.jdmk.comm.HttpSendInputStream.read(HttpSendInputStream.java:95)
at java.io.FilterInputStream.read(FilterInputStream.java:94)
at java.io.PushbackInputStream.read(PushbackInputStream.java:150)
at com.sun.jdmk.comm.GenericHttpConnectorClient.sendHttp(GenericHttpConnectorClient.java:486)
at com.sun.jdmk.comm.GenericHttpConnectorClient.invokeRemoteOperation(GenericHttpConnectorClient.java:2234)
at com.sun.jdmk.comm.GenericHttpConnectorClient.invoke(GenericHttpConnectorClient.java:1366)

As I said, any helpful suggestions would be appreciated.

Dale
  • 3,527
  • 6
  • 24
  • 22
  • No status codes returned or maybe a message? And what are the urls you're calling? – Darwind Mar 13 '14 at 22:10
  • There wasn't much help in the way of status codes or messages at all. Just a stack trace. I was hoping I could create my own HttpSendSocket class that extends the original and add some diagnostics but HttpSendSocket is package protected, so I wasn't sure how to proceed that way. – Dale Mar 13 '14 at 22:14
  • But was there a message or status code returned? It might help you a lot actually :-) – Darwind Mar 13 '14 at 22:16
  • There was nothing helpful. All I know is where in my code that the error came from. – Dale Mar 13 '14 at 22:18
  • I am using the deprecated GenericHttpConnectorClient. I cannot change that - for now. – Dale Mar 13 '14 at 22:19
  • 1
    *Post* the stack trace. Expecting an answer without it is utopian. – user207421 Mar 13 '14 at 22:37
  • Stack trace added to question, above. – Dale Mar 14 '14 at 14:12

2 Answers2

1

The communication Exception was caused by using ArrayList method subList. ArrayList is serializable but subList data IS NOT serializable, and therefore you cannot retrieve the data over an HttpConnector. The solution was to change:

List<UserProcessInfo> values = new ArrayList<UserProcessInfo>();
...
values.size() <= 1000 ? values : values.subList(0,1000);

to:

List<UserProcessInfo> values = new ArrayList<UserProcessInfo>();
...
return values.size() <= 1000 ? values : new ArrayList<UserProcessInfo>(values.subList(0,1000));
  • Thanks, Sherry!!!! Great find. When the return data is not serializable it causes problems and the error that occurs is very nebulous. – Dale Mar 19 '14 at 14:12
0

Attach the JDMK source to your IDE, then set a breakpoint in the HttpSendSocket and run it with debugging enabled. At least in IntelliJ you can attach the library source by trying to open the class from the stacktrace, then choosing to link source. Don't know how the process is for other IDE's but I would expect it to be possible.

kg_sYy
  • 1,127
  • 9
  • 26
  • Thanks, I'll give it a shot. FYI, I'm using Eclipse. The problem with the setting a breakpoint technique is I cannot make this problem happen at will. It's very intermittent. So I was really hoping to simply add some diagnostics, rebuild, and run the code from a command line. Just the same, I'll see if I can use the technique you've suggested. Thanks! – Dale Mar 13 '14 at 22:21
  • I'm still looking but Eclipse wants the jdmkrt.jar file that contains the source. How do you get that? – Dale Mar 13 '14 at 22:27
  • Do you have the source code? From your post I got that impression. If so, you should be able to just zip the source tree and give that to eclipse if it does not take the directory. – kg_sYy Mar 13 '14 at 22:28
  • I do not have the source myself. I have only seen sources on the internet for the individual class files. Eclipse allows me to attach a source file, but it needs to be in a jar or zip file, and I don't have that... – Dale Mar 13 '14 at 22:32
  • OK, if you do not have the source code (and cannot download it from anywhere), you can't do that. Or perhaps if you have just that class code, you could attach that by creating a source tree for it with just that in there. Other than that, you may just try your idea of a new version with some debugging info. Or try another open source implementation if possible, you should be able to debug those.. – kg_sYy Mar 13 '14 at 22:42
  • Not sure if this is the newest version of the class, but it might be helpful none-the-less: http://grepcode.com/file/repo1.maven.org/maven2/com.betfair.net.java.opendmk/core/1.0-b02/com/sun/jdmk/comm/HttpSendSocket.java Problem is that they're somewhat "eating" the exception ;-( – Darwind Mar 13 '14 at 22:52
  • ok i see the whole code is there, it is just not the latest. and yes, they do a nasty swallow on the exception. have you tried http://grepcode.com/eclipse? also, you have the whole source tree in the link you provide if you click on "files". it seems to be a maven repository, maybe you can download the whole thing and attach to eclipse if that plugin does not work – kg_sYy Mar 13 '14 at 23:21