[java-identity-provider] branch master updated: IDP-1208 - Make cache key optional/conditional on DataConnector searches

Scott Cantor cantor.2 at osu.edu
Fri Aug 18 13:55:49 EDT 2017


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=819f279b4438a7291aca1d2761f4b78f63fa8beb

The following commit(s) were added to refs/heads/master by this push:
       new  819f279   IDP-1208 - Make cache key optional/conditional on DataConnector searches
819f279 is described below

commit 819f279b4438a7291aca1d2761f4b78f63fa8beb
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Aug 18 13:55:46 2017 -0400

    IDP-1208 - Make cache key optional/conditional on DataConnector searches
    
    https://issues.shibboleth.net/jira/browse/IDP-1208
---
 .../dc/impl/AbstractSearchDataConnector.java         | 20 +++++++++++++-------
 .../attribute/resolver/dc/impl/ExecutableSearch.java |  8 ++++----
 .../impl/AbstractExecutableSearchFilterBuilder.java  |  3 ++-
 .../impl/AbstractExecutableStatementBuilder.java     |  7 ++++---
 4 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/AbstractSearchDataConnector.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/AbstractSearchDataConnector.java
index cd3d081..d343573 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/AbstractSearchDataConnector.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/AbstractSearchDataConnector.java
@@ -179,14 +179,20 @@ public abstract class AbstractSearchDataConnector<T1 extends ExecutableSearch,T2
         Map<String, IdPAttribute> resolvedAttributes = null;
         if (resultsCache != null && resolutionContext.getAllowCachedResults()) {
             final String cacheKey = executable.getResultCacheKey();
-            resolvedAttributes = resultsCache.getIfPresent(cacheKey);
-            log.trace("{} Cache found, resolved attributes {} using cache {}", new Object[] {getLogPrefix(),
-                    resolvedAttributes, resultsCache,});
-            if (resolvedAttributes == null) {
+            if (cacheKey != null) {
+                resolvedAttributes = resultsCache.getIfPresent(cacheKey);
+                log.trace("{} Cache found, resolved attributes {} using cache {}", new Object[] {getLogPrefix(),
+                        resolvedAttributes, resultsCache,});
+                if (resolvedAttributes == null) {
+                    resolvedAttributes = retrieveAttributes(executable);
+                    log.trace("{} Resolved attributes {}", getLogPrefix(), resolvedAttributes);
+                    resultsCache.put(cacheKey, resolvedAttributes != null ? resolvedAttributes
+                            : Collections.<String,IdPAttribute>emptyMap());
+                }
+            } else {
+                log.trace("No cache key returned, will not check for cached results");
                 resolvedAttributes = retrieveAttributes(executable);
-                log.trace("{} Resolved attributes {}", getLogPrefix(), resolvedAttributes);
-                resultsCache.put(cacheKey, resolvedAttributes != null ? resolvedAttributes
-                        : Collections.<String,IdPAttribute>emptyMap());
+                log.trace("{} Resolved attributes: {}", getLogPrefix(), resolvedAttributes);
             }
         } else {
             resolvedAttributes = retrieveAttributes(executable);
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ExecutableSearch.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ExecutableSearch.java
index b3cdf1c..ebd2532 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ExecutableSearch.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/impl/ExecutableSearch.java
@@ -17,9 +17,7 @@
 
 package net.shibboleth.idp.attribute.resolver.dc.impl;
 
-import javax.annotation.Nonnull;
-
-import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import javax.annotation.Nullable;
 
 /** Should be implemented by objects used to search for attributes, that uniquely identify those search results. */
 public interface ExecutableSearch {
@@ -27,7 +25,9 @@ public interface ExecutableSearch {
     /**
      * Gets a key that uniquely identifies this object and may be used as a key in a result cache.
      * 
+     * <p>If a null is returned, no caching will be done.</p>
+     * 
      * @return the result cache key
      */
-    @Nonnull @NotEmpty public String getResultCacheKey();
+    @Nullable public String getResultCacheKey();
 }
\ No newline at end of file
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/AbstractExecutableSearchFilterBuilder.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/AbstractExecutableSearchFilterBuilder.java
index dcfdeca..3d2bb8d 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/AbstractExecutableSearchFilterBuilder.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/ldap/impl/AbstractExecutableSearchFilterBuilder.java
@@ -18,6 +18,7 @@
 package net.shibboleth.idp.attribute.resolver.dc.ldap.impl;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import org.ldaptive.ConnectionFactory;
 import org.ldaptive.LdapException;
@@ -51,7 +52,7 @@ public abstract class AbstractExecutableSearchFilterBuilder extends AbstractInit
         return new ExecutableSearchFilter() {
 
             /** {@inheritDoc} */
-            @Nonnull public String getResultCacheKey() {
+            @Nullable public String getResultCacheKey() {
                 return searchFilter.format();
             }
 
diff --git a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/AbstractExecutableStatementBuilder.java b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/AbstractExecutableStatementBuilder.java
index 9be89e4..260b9ba 100644
--- a/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/AbstractExecutableStatementBuilder.java
+++ b/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/rdbms/impl/AbstractExecutableStatementBuilder.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import net.shibboleth.idp.attribute.IdPAttributeValue;
 import net.shibboleth.idp.attribute.resolver.ResolutionException;
@@ -81,19 +82,19 @@ public abstract class AbstractExecutableStatementBuilder extends AbstractInitial
         return new ExecutableStatement() {
 
             /** {@inheritDoc} */
-            @Override @Nonnull public String getResultCacheKey() {
+            @Nullable public String getResultCacheKey() {
                 return query;
             }
 
             /** {@inheritDoc} */
-            @Override @Nonnull public ResultSet execute(@Nonnull final Connection connection) throws SQLException {
+            @Nonnull public ResultSet execute(@Nonnull final Connection connection) throws SQLException {
                 final Statement stmt = connection.createStatement();
                 stmt.setQueryTimeout(queryTimeout);
                 return stmt.executeQuery(query);
             }
 
             /** {@inheritDoc} */
-            @Override public String toString() {
+            public String toString() {
                 return query;
             }
         };

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list