Search code examples
javainfinispanqpid

Conflict when both infinispan and qpid-broker registers URLStreamHandlers


I'm trying to upgrade infinispan from version 9 to 13 in our application. Since version 12.1, infinispan has a ClasspathURLStreamHandler that automatically registers itself (on Java >= 9).

This causes issues as our application also uses qpid-broker, and that library also has a URLStreamHandler that automatically registers itself.

Now, I don't fully understand how URL.setURLStreamHandlerFactory works - but my understanding of the problem is:

  1. Both infinispan and qpid-broker tries to register their respective URLStreamHandler, for the classpath protocol
  2. Only one URLStreamHandler can be registered. In this case infinispan happens to be first, and its handler is registered.
  3. When starting up qpid-broker, it tries to read system.properties using an URL classpath:system.properties (this happens in org.apache.qpid.server.SystemLauncher).
  4. There is no system.properties on the classpath (I think) - and infinispan's handler returns null, resulting in a NullPointerException in qpid-broker.

Note that the behavior of infinispan's handler is different compared to the behaviour of qpid-broker's handler, which throws an exception on failure (e.g. FileNotFoundException or MalformedURLException) instead of returning null.

Questions:

  • How is the fact that libraries can (and apparently will) register things like URLStreamHandlerFactory, which affects the JVM globally and can only be registered once, usually handled in large applications like ours that can have lots of dependencies?

  • Could this problem be considered a bug in infinispan? If its handler would have the same behaviour as qpid-broker's, i.e. throw an exception instead of returning null, maybe it wouldn't have matter which handler is actually registered and used?

  • Is there some other way, beside adjusting the behaviour of infinispan's handler, to fix this problem?


Solution

  • You are right, the behaviour is wrong. I've created an issue https://issues.redhat.com/browse/ISPN-14732 and it will be incorporated in 14.0.8.Final.