My threads keep dying! Exceptions without stack traces? How to debug?

T

Twisted

My thread factory is groaning under the load. It keeps having to create
new threads to replace ones that keep dying. The threads are all
identical code-wise, and their run() methods consist mainly of a big
try block that calls some other stuff and sleeps and such. The try
block doesn't bother recovering from most exceptions; there's an ending
catch (Exception e) that notifies the thread factory of a thread's
untimely demise, and exits.

I figured this would give the system some robustness, as well as
providing a way to debug. But I am having difficulty with the latter.
Noticing a lot of logged exceptions without any detail info, I tried
sticking a breakpoint in that catch block, just where it calls the
factory's thread death notifier, and inspecting the exception objects
when the breakpoint is tripped.

They have no stack trace. Some are NullPointerExceptions whose "cause"
field refers recursively to the same exception, with null detail and
stack trace fields. Others are IllegalArgumentExceptions with the same
property. Still more are like these last, but the detail field says
"java.lang.IllegalArgumentException: protocol = http host = null"...

Anyone know where they're coming from?
 
T

Twisted

I've got new information on some of the IllegalArgumentExceptions, and
think I've eliminated the NullPointerExceptions (things like
getContentType() on URLConnections were sometimes returning null for
some reason).

Removing the exception handler and letting the exceptions go uncaught
leads to a usable stack trace. The "protocol = http host = null" ones
look like this:

Exception in thread "Thread-135" java.lang.IllegalArgumentException:
protocol = http host = null
at sun.net.spi.DefaultProxySelector.select(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at imagesucker.ImagesuckerThread.spiderURL(ImagesuckerThread.java:153)
at imagesucker.ImagesuckerThread.run(ImagesuckerThread.java:76)

Now the connect() URLConnection instance method isn't mentioned as
throwing anything but IO exceptions in the documentation...does anyone
have any information on what would cause this? Could the URL have had a
null host? If so, how?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top