[java-opensaml COMMIT] /trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService...

noreply at shibboleth.net noreply at shibboleth.net
Tue Oct 18 16:22:50 EDT 2016


Author: scantor
Date: Tue Oct 18 16:22:50 2016
New Revision: 4541

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4541&view=rev
Log:
Trap unchecked exceptions from getContextMap method to prevent them from getting out.

Modified:
    trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java

Modified: trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java?rev=4541&r1=4540&r2=4541&view=diff
==============================================================================
--- trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java	(original)
+++ trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java	Tue Oct 18 16:22:50 2016
@@ -68,7 +68,12 @@
         try {
             writeLock.lock();
             
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
             
             // Create new context if necessary.
             Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
@@ -172,7 +177,12 @@
         try {
             writeLock.lock();
             
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
 
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
             if (dataMap != null) {    
@@ -200,7 +210,11 @@
         try {
             writeLock.lock();
             setDirty();
-            getContextMap().remove(context);
+            try {
+                getContextMap().remove(context);
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
         } finally {
             writeLock.unlock();
         }
@@ -217,7 +231,13 @@
         try {
             writeLock.lock();
             
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
             
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
             if (dataMap != null) {
@@ -246,6 +266,9 @@
      * 
      * <p>This method is guaranteed to be called under cover the lock returned by {{@link #getLock()}.</p>
      * 
+     * TODO: this method needs to be able to throw IOException to deal with unexpected scenarios without
+     * raising unchecked exceptions.
+     * 
      * @return map of contexts to manipulate
      */
     @Nonnull @NonnullElements @Live protected abstract Map<String, Map<String, MutableStorageRecord>> getContextMap();
@@ -276,7 +299,13 @@
         try {
             readLock.lock();
             
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
             
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
             if (dataMap == null) {
@@ -330,7 +359,12 @@
         try {
             writeLock.lock();
             
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
 
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
             if (dataMap == null) {
@@ -393,7 +427,12 @@
         try {
             writeLock.lock();
 
-            final Map<String,Map<String,MutableStorageRecord>> contextMap = getContextMap();
+            final Map<String,Map<String,MutableStorageRecord>> contextMap;
+            try {
+                contextMap = getContextMap();
+            } catch (final Exception e) {
+                throw new IOException(e);
+            }
             
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);

[... 2 lines stripped ...]


More information about the commits mailing list