Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-13877

NullPointerException in MetricsCollector.java

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      A NullPointerException is thrown from here:

      https://github.com/infinispan/infinispan/blob/13.0.8.Final/core/src/main/java/org/infinispan/metrics/impl/MetricsCollector.java#L115

      This happens as soon as I add SSL_KEY_EXCHANGE and ASYM_ENCRYPT to the jgroups protocol stack

      It looks like JGroupsMetricsMetadata.PROTOCOL_METADATA.get returns null on this line for SSL_KEY_EXCHANGE  and/or ASYM_ENCRYPT:

      https://github.com/infinispan/infinispan/blob/13.0.8.Final/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java#L1512

      which causes the NPE

       

       

      This was the stack trace that I got:

       

      ERROR [org.jgroups.JChannel] (keycloak-cache-init) JGRP000016: exception in channelConnected callback: java.lang.NullPointerException
      java.lang.NullPointerException
      at org.infinispan.metrics.impl.MetricsCollector.registerMetrics(MetricsCollector.java:115)
      at org.infinispan.remoting.transport.jgroups.JGroupsTransport.lambda$channelConnected$9(JGroupsTransport.java:1512)
      at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
      at org.infinispan.remoting.transport.jgroups.JGroupsTransport.channelConnected(JGroupsTransport.java:1508)
      at org.jgroups.JChannel.lambda$notifyChannelConnected$1(JChannel.java:1104)
      at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807)
      at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425)
      at org.jgroups.JChannel.notifyListeners(JChannel.java:1118)
      at org.jgroups.JChannel.notifyChannelConnected(JChannel.java:1104)
      at org.jgroups.JChannel.connect(JChannel.java:363)
      at org.jgroups.JChannel.connect(JChannel.java:352)
      at org.infinispan.remoting.transport.jgroups.JGroupsTransport.startJGroupsChannelIfNeeded(JGroupsTransport.java:548)
      at org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:476)
      at org.infinispan.remoting.transport.jgroups.CorePackageImpl$1.start(CorePackageImpl.java:42)
      at org.infinispan.remoting.transport.jgroups.CorePackageImpl$1.start(CorePackageImpl.java:27)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.invokeStart(BasicComponentRegistryImpl.java:617)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:608)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:577)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:808)
      at org.infinispan.metrics.impl.MetricsCollector.start(MetricsCollector.java:70)
      at org.infinispan.metrics.impl.CorePackageImpl$1.start(CorePackageImpl.java:41)
      at org.infinispan.metrics.impl.CorePackageImpl$1.start(CorePackageImpl.java:34)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.invokeStart(BasicComponentRegistryImpl.java:617)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:608)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:577)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:808)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.startDependencies(BasicComponentRegistryImpl.java:635)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.doStartWrapper(BasicComponentRegistryImpl.java:599)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.startWrapper(BasicComponentRegistryImpl.java:577)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl.access$700(BasicComponentRegistryImpl.java:30)
      at org.infinispan.factories.impl.BasicComponentRegistryImpl$ComponentWrapper.running(BasicComponentRegistryImpl.java:808)
      at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:354)
      at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:250)
      at org.infinispan.manager.DefaultCacheManager.internalStart(DefaultCacheManager.java:766)
      at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:734)
      at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:405)
      at org.keycloak.quarkus.runtime.storage.infinispan.CacheManagerFactory.startCacheManager(CacheManagerFactory.java:86)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      at java.base/java.lang.Thread.run(Thread.java:829)

       

      It is possible that I just forgot to configure something, or misconfigured something, but it looks to me that even in that case, the NPE should never happen.

       

      I have patched it for now by adding a simple null check right before the for loop on line 115 (for version 13.0.8.Final) in MetricsCollector.java:

            if (attributes == null)

      {           attributes = new java.util.ArrayList<>();       }

              dlovison@redhat.com Diego Lovison
              braddahi Brahim Raddahi (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: