This is an automated email from the ASF dual-hosted git repository.

spolavarapu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new 22d4560  RANGER-3638: Avoid calling rangerSolrAuthorizerImpl close() 
when the call is for SearchComponent (or Document level authorization)
22d4560 is described below

commit 22d45607b3b9f168587da56440586bc1fe6471f5
Author: Sailaja Polavarapu <[email protected]>
AuthorDate: Thu Feb 24 17:55:49 2022 -0800

    RANGER-3638: Avoid calling rangerSolrAuthorizerImpl close() when the call 
is for SearchComponent (or Document level authorization)
---
 .../solr/authorizer/RangerSolrAuthorizer.java      | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git 
a/ranger-solr-plugin-shim/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
 
b/ranger-solr-plugin-shim/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
index dfa2196..3a10bc2 100644
--- 
a/ranger-solr-plugin-shim/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
+++ 
b/ranger-solr-plugin-shim/src/main/java/org/apache/ranger/authorization/solr/authorizer/RangerSolrAuthorizer.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.ranger.plugin.classloader.RangerPluginClassLoader;
+import org.apache.solr.common.StringUtils;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.handler.component.ResponseBuilder;
 import org.apache.solr.handler.component.SearchComponent;
@@ -126,12 +127,21 @@ public class RangerSolrAuthorizer extends SearchComponent 
implements Authorizati
                if(LOG.isDebugEnabled()) {
                        LOG.debug("==> RangerSolrAuthorizer.close(Resource)");
                }
-               try {
-                       activatePluginClassLoader();
-
-                       rangerSolrAuthorizerImpl.close();
-               } finally {
-                       deactivatePluginClassLoader();
+               // close() to be forwarded only for authorizer instance
+               boolean isAuthorizer = StringUtils.equals(super.getName(), 
RANGER_SOLR_AUTHORIZER_IMPL_CLASSNAME);
+               if (isAuthorizer) {
+
+                       try {
+                               activatePluginClassLoader();
+
+                               rangerSolrAuthorizerImpl.close();
+                       } finally {
+                               deactivatePluginClassLoader();
+                       }
+               } else {
+                       if(LOG.isDebugEnabled()) {
+                               LOG.debug("RangerSolrAuthorizer.close(): not 
forwarding for instance '" + super.getName() + "'");
+                       }
                }
 
                if(LOG.isDebugEnabled()) {

Reply via email to