lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [lucene-solr] 27/36: Fix a bug in component registration.
Date Wed, 18 Dec 2019 16:39:05 GMT
This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch jira/solr-13579
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit e44e82255ebbe2e15215c344ad7ea973747fffa5
Author: Andrzej Bialecki <ab@apache.org>
AuthorDate: Mon Aug 12 09:52:47 2019 +0200

    Fix a bug in component registration.
---
 .../src/java/org/apache/solr/managed/DefaultResourceManager.java   | 7 ++++---
 .../java/org/apache/solr/managed/DefaultResourceManagerPool.java   | 5 +++++
 .../core/src/java/org/apache/solr/managed/ResourceManagerPool.java | 7 +++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
index e6eb55c..069628d 100644
--- a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
+++ b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManager.java
@@ -178,15 +178,16 @@ public class DefaultResourceManager extends ResourceManager {
     if (pool == null) {
       throw new IllegalArgumentException("Pool '" + name + "' doesn't exist.");
     }
-    String type = pool.getType();
+    String poolType = pool.getType();
     resourcePools.forEach((poolName, otherPool) -> {
       if (otherPool == pool) {
         return;
       }
-      if (otherPool.getType().equals(type)) {
+      if (otherPool.isRegistered(managedComponent.getManagedComponentId().toString()) &&
+          otherPool.getType().equals(poolType)) {
         throw new IllegalArgumentException("Resource " + managedComponent.getManagedComponentId()
+
             " is already managed in another pool (" +
-            otherPool.getName() + ") of the same type " + type);
+            otherPool.getName() + ") of the same type " + poolType);
       }
     });
     pool.registerComponent(managedComponent);
diff --git a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
index 07de310..1f1e6d2 100644
--- a/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
+++ b/solr/core/src/java/org/apache/solr/managed/DefaultResourceManagerPool.java
@@ -105,6 +105,11 @@ public class DefaultResourceManagerPool implements ResourceManagerPool
{
   }
 
   @Override
+  public boolean isRegistered(String componentId) {
+    return components.containsKey(componentId);
+  }
+
+  @Override
   public Map<String, ManagedComponent> getComponents() {
     return Collections.unmodifiableMap(components);
   }
diff --git a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
index dc2ddac..0761442 100644
--- a/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
+++ b/solr/core/src/java/org/apache/solr/managed/ResourceManagerPool.java
@@ -22,6 +22,13 @@ public interface ResourceManagerPool extends Runnable, Closeable {
   /** Remove named component from this pool. */
   boolean unregisterComponent(String componentId);
 
+  /**
+   * Check whether a named component is registered in this pool.
+   * @param componentId component id
+   * @return true if the component with this name is registered, false otherwise.
+   */
+  boolean isRegistered(String componentId);
+
   /** Get components managed by this pool. */
   Map<String, ManagedComponent> getComponents();
 


Mime
View raw message