Name: dbT83986 Date: 03/09/99
According to the JDK API doc, the getInputStream() method does not
throw a NullPointerException. However, in actual use, it throws
this exception about 35% of the time. The code below _should_
work, but does not work reliably due to NullPointerExceptions:
URLConnection serverConnection = targetURL.openConnection();
serverConnection.connect();
InputStream inStream = serverConnection.getInputStream();
The code below is a workaround for the problem, retrying getting
the input stream until it actually succeeds:
URLConnection serverConnection = targetURL.openConnection();
serverConnection.connect();
InputStream inStream = null;
while (inStream == null)
{
try
{
inStream = serverConnection.getInputStream();
}
catch(NullPointerException ex)
{
try
{ Thread.currentThread().sleep(15); }
catch (Exception e)
{}
}
}
(Review ID: 55154)
======================================================================
- relates to
-
JDK-4147525 bugs in HttpUrlConnection with KeepAlive
-
- Closed
-