muse-dev[bot] commented on a change in pull request #1758: URL: https://github.com/apache/lucene-solr/pull/1758#discussion_r498037436
########## File path: solr/core/src/java/org/apache/solr/api/CustomContainerPlugins.java ########## @@ -163,6 +174,47 @@ public synchronized void refresh() { } } + private void handleClusterSingleton(ApiInfo newApiInfo, ApiInfo oldApiInfo) { + if (newApiInfo != null) { + // register new api + Object instance = newApiInfo.getInstance(); + if (instance instanceof ClusterSingleton) { + ClusterSingleton singleton = (ClusterSingleton) instance; + coreContainer.getClusterSingletons().getSingletons().put(singleton.getName(), singleton); + // easy check to see if we should immediately start this singleton + if (coreContainer.getClusterEventProducer() != null && + coreContainer.getClusterEventProducer().isRunning()) { + try { + singleton.start(); + } catch (Exception exc) { + log.warn("Exception starting ClusterSingleton {}: {}", newApiInfo, exc); + } + } + } + if (instance instanceof ClusterEventListener) { + // XXX nocommit obtain a list of supported event types from the config + ClusterEvent.EventType[] types = ClusterEvent.EventType.values(); + try { + coreContainer.getClusterEventProducer().registerListener((ClusterEventListener) instance, types); + } catch (Exception exc) { + log.warn("Exception adding ClusterEventListener {}: {}", newApiInfo, exc); + } + } + } + if (oldApiInfo != null) { + // stop & unregister the old api + Object instance = oldApiInfo.getInstance(); + if (instance instanceof ClusterSingleton) { + ClusterSingleton singleton = (ClusterSingleton) instance; + singleton.stop(); + coreContainer.getClusterSingletons().getSingletons().remove(singleton.getName()); + } + if (instance instanceof ClusterEventListener) { + coreContainer.getClusterEventProducer().unregisterListener((ClusterEventListener) instance); Review comment: *NULL_DEREFERENCE:* object returned by `CustomContainerPlugins.coreContainer.getClusterEventProducer()` could be null and is dereferenced at line 213. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org