URLConnection::getContentHandler has a benign race condition on stuffing URLConnection.handlers map with new handlers.
URLConnection::getContentHandler synchronizes on an instance rather than on the class:
private static Hashtable<String, ContentHandler> handlers = new Hashtable<>();
/**
* Gets the Content Handler appropriate for this connection.
*/
synchronized ContentHandler getContentHandler()
throws UnknownServiceException
{
String contentType = stripOffParameters(getContentType());
ContentHandler handler = null;
if (contentType == null)
throw new UnknownServiceException("no content-type");
try {
handler = handlers.get(contentType);
if (handler != null)
return handler;
} catch(Exception e) {
}
if (factory != null)
handler = factory.createContentHandler(contentType);
if (handler == null) {
try {
handler = lookupContentHandlerClassFor(contentType);
} catch(Exception e) {
e.printStackTrace();
handler = UnknownContentHandler.INSTANCE;
}
handlers.put(contentType, handler);
}
return handler;
}
URLConnection::getContentHandler synchronizes on an instance rather than on the class:
private static Hashtable<String, ContentHandler> handlers = new Hashtable<>();
/**
* Gets the Content Handler appropriate for this connection.
*/
synchronized ContentHandler getContentHandler()
throws UnknownServiceException
{
String contentType = stripOffParameters(getContentType());
ContentHandler handler = null;
if (contentType == null)
throw new UnknownServiceException("no content-type");
try {
handler = handlers.get(contentType);
if (handler != null)
return handler;
} catch(Exception e) {
}
if (factory != null)
handler = factory.createContentHandler(contentType);
if (handler == null) {
try {
handler = lookupContentHandlerClassFor(contentType);
} catch(Exception e) {
e.printStackTrace();
handler = UnknownContentHandler.INSTANCE;
}
handlers.put(contentType, handler);
}
return handler;
}
- relates to
-
JDK-8064925 URLConnection::getContent needs to be updated to work with modules
-
- Closed
-