[java-opensaml] 09/09: OSJ-425 - IdP keeps repeatedly attempting to delete local storage data

Scott Cantor cantor.2 at osu.edu
Thu Mar 13 18:42:00 UTC 2025


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

scantor pushed a commit to branch maint-5.1
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=9f3a836d4532d79c70e951d4acc6cf9f80eb66e1

commit 9f3a836d4532d79c70e951d4acc6cf9f80eb66e1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 5 12:55:45 2025 -0500

    OSJ-425 - IdP keeps repeatedly attempting to delete local storage data
    
    https://shibboleth.atlassian.net/browse/OSJ-425
    
    Suggested fix to add setDirty(false) on empty data code branches.
---
 .../impl/client/JSONClientStorageServiceStore.java |  8 +++---
 .../client/PopulateClientStorageLoadContext.java   |  2 +-
 .../impl/client/XMLClientStorageServiceStore.java  |  3 ++-
 .../PopulateClientStorageSaveContextTest.java      | 31 ++++++++++++++++++++++
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/JSONClientStorageServiceStore.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/JSONClientStorageServiceStore.java
index d49a1e594..e63c2ec60 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/JSONClientStorageServiceStore.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/JSONClientStorageServiceStore.java
@@ -106,6 +106,7 @@ public class JSONClientStorageServiceStore extends AbstractClientStorageServiceS
         
         if (getContextMap().isEmpty()) {
             log.trace("{} Data is empty", storageService.getLogPrefix());
+            setDirty(false);
             return new ClientStorageServiceOperation(storageService.ensureId(), storageService.getStorageName(), null,
                     source);
         }
@@ -144,8 +145,9 @@ public class JSONClientStorageServiceStore extends AbstractClientStorageServiceS
 
             if (empty) {
                 log.trace("{} Data is empty", storageService.getLogPrefix());
-                return new ClientStorageServiceOperation(storageService.getId(), storageService.getStorageName(), null,
-                        source);
+                setDirty(false);
+                return new ClientStorageServiceOperation(storageService.ensureId(), storageService.getStorageName(),
+                        null, source);
             }
             
             final String raw = sink.toString();
@@ -180,4 +182,4 @@ public class JSONClientStorageServiceStore extends AbstractClientStorageServiceS
         }
     }
 
-}
\ No newline at end of file
+}
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
index 78d63f76b..9725f67ed 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/PopulateClientStorageLoadContext.java
@@ -105,7 +105,7 @@ public class PopulateClientStorageLoadContext extends AbstractProfileAction {
             } catch (final IOException e) {
                 log.warn("{} Error checking load status of {}, assuming unloaded", getLogPrefix(), service.getId());
                 loadCtx.getStorageKeys().add(service.getStorageName());
-                ids.add(service.getId());
+                ids.add(service.ensureId());
             }
         }
         
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/XMLClientStorageServiceStore.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/XMLClientStorageServiceStore.java
index 5d9fbc351..970ca3af1 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/XMLClientStorageServiceStore.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/client/XMLClientStorageServiceStore.java
@@ -130,6 +130,7 @@ public class XMLClientStorageServiceStore extends AbstractClientStorageServiceSt
         
         if (getContextMap().isEmpty()) {
             log.trace("{} Data is empty", storageService.getLogPrefix());
+            setDirty(false);
             return new ClientStorageServiceOperation(storageService.ensureId(), storageService.getStorageName(), null,
                     source);
         }
@@ -170,6 +171,7 @@ public class XMLClientStorageServiceStore extends AbstractClientStorageServiceSt
 
             if (empty) {
                 log.trace("{} Data is empty", storageService.getLogPrefix());
+                setDirty(false);
                 return new ClientStorageServiceOperation(storageService.ensureId(), storageService.getStorageName(),
                         null, source);
             }
@@ -209,7 +211,6 @@ public class XMLClientStorageServiceStore extends AbstractClientStorageServiceSt
         /** {@inheritDoc} */
         @Override
         protected void doInitialize() throws ComponentInitializationException {
-            // TODO Auto-generated method stub
             super.doInitialize();
             
             ((BasicParserPool) parserPool).setNamespaceAware(false);
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContextTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContextTest.java
index 9b7782aae..e0827153c 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContextTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/client/PopulateClientStorageSaveContextTest.java
@@ -106,5 +106,36 @@ public class PopulateClientStorageSaveContextTest extends AbstractBaseClientStor
         Assert.assertEquals(op.getKey(), ss.getStorageName());
         Assert.assertEquals(op.getStorageSource(), ClientStorageSource.HTML_LOCAL_STORAGE);
     }
+
+    @Test public void testInvalidBecomesClean() throws ComponentInitializationException, IOException {
+        final ClientStorageService ss = getStorageService();
+        action.setStorageServices(CollectionSupport.singletonList(ss));
+        action.initialize();
+
+        HttpServletRequestResponseContext.loadCurrent(new MockHttpServletRequest(), new MockHttpServletResponse());
+
+        ss.load("invalid encrypted data", ClientStorageSource.HTML_LOCAL_STORAGE);
+
+        action.execute(prc);
+        ActionTestingSupport.assertProceedEvent(prc);
+
+        final ClientStorageSaveContext saveCtx = prc.getSubcontext(ClientStorageSaveContext.class);
+        assert saveCtx != null;
+        Assert.assertTrue(saveCtx.isSourceRequired(ClientStorageSource.HTML_LOCAL_STORAGE));
+        Assert.assertEquals(saveCtx.getStorageOperations().size(), 1);
+
+        final ClientStorageServiceOperation op = saveCtx.getStorageOperations().iterator().next();
+        Assert.assertEquals(op.getStorageServiceID(), ss.getId());
+        Assert.assertEquals(op.getKey(), ss.getStorageName());
+        Assert.assertNull(op.getValue());
+        Assert.assertEquals(op.getStorageSource(), ClientStorageSource.HTML_LOCAL_STORAGE);
+
+        prc.removeSubcontext(ClientStorageSaveContext.class);
+
+        action.execute(prc);
+        ActionTestingSupport.assertEvent(prc, PopulateClientStorageSaveContext.SAVE_NOT_NEEDED);
+
+        Assert.assertNull(prc.getSubcontext(ClientStorageSaveContext.class));
+    }
    
 }
\ No newline at end of file

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


More information about the commits mailing list