[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynam...

noreply at shibboleth.net noreply at shibboleth.net
Mon Nov 7 19:26:40 EST 2016


Author: putmanb
Date: Mon Nov  7 19:26:40 2016
New Revision: 4572

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4572&view=rev
Log:
OSJ-168: On-disk caching of dynamically acquired metadata

Fix minor issue where update of persistent cache key doesn't happen in cases where 1) filter exception 2) predicate eval was false.
In these cases we don't throw out the cached data, so should still update the cache key like in the success case.

Modified:
    trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java

Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java?rev=4572&r1=4571&r2=4572&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java	(original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java	Mon Nov  7 19:26:40 2016
@@ -982,28 +982,15 @@
         
         if (isValid(descriptor)) {
             if (getInitializationFromCachePredicate().apply(descriptor)) {
-                final String expectedKey = getPersistentCacheKeyGenerator().apply(descriptor);
                 try {
                     processNewMetadata(descriptor, descriptor.getEntityID(), true);
                     log.trace("Successfully processed EntityDescriptor with entityID '{}' from cache", 
                             descriptor.getEntityID());
                     persistentCacheInitMetrics.entriesLoaded++;
-
-                    // Update storage key if necessary, e.g. if cache key generator impl has changed.
-                    if (!Objects.equals(currentKey, expectedKey)) {
-                        log.trace("Current cache storage key '{}' differs from expected key '{}', updating",
-                                currentKey, expectedKey);
-                        getPersistentCacheManager().updateKey(currentKey, expectedKey);
-                        log.trace("Successfully updated cache storage key '{}' to '{}'", 
-                                currentKey, expectedKey);
-                    }
-
                 } catch (final FilterException e) {
                     log.warn("Error processing EntityDescriptor '{}' from cache with storage key '{}'", 
                             descriptor.getEntityID(), currentKey, e);
                     persistentCacheInitMetrics.entriesSkippedProcessingException++;
-                } catch (final IOException e) {
-                    log.warn("Error updating cache storage key '{}' to '{}'", currentKey, expectedKey, e);
                 }
             } else {
                 log.trace("Cache initialization predicate indicated to not process EntityDescriptor " 
@@ -1011,6 +998,21 @@
                         descriptor.getEntityID(), currentKey);
                 persistentCacheInitMetrics.entriesSkippedFailedPredicate++;
             }
+            
+            // Update storage key if necessary, e.g. if cache key generator impl has changed.
+            final String expectedKey = getPersistentCacheKeyGenerator().apply(descriptor);
+            try {
+                if (!Objects.equals(currentKey, expectedKey)) {
+                    log.trace("Current cache storage key '{}' differs from expected key '{}', updating",
+                            currentKey, expectedKey);
+                    getPersistentCacheManager().updateKey(currentKey, expectedKey);
+                    log.trace("Successfully updated cache storage key '{}' to '{}'", 
+                            currentKey, expectedKey);
+                }
+            } catch (final IOException e) {
+                log.warn("Error updating cache storage key '{}' to '{}'", currentKey, expectedKey, e);
+            }
+                
         } else {
             log.trace("EntityDescriptor with entityID '{}' and storaage key '{}' in cache was " 
                     + "not valid, skipping and removing", descriptor.getEntityID(), currentKey);



More information about the commits mailing list