You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2016/02/15 09:46:02 UTC
svn commit: r1730467 -
/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java
Author: cziegeler
Date: Mon Feb 15 08:46:01 2016
New Revision: 1730467
URL: http://svn.apache.org/viewvc?rev=1730467&view=rev
Log:
SLING-5521 : Support Closeable for provider state
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java
Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java?rev=1730467&r1=1730466&r2=1730467&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrProviderState.java Mon Feb 15 08:46:01 2016
@@ -18,13 +18,16 @@
*/
package org.apache.sling.jcr.resource.internal.helper.jcr;
+import java.io.Closeable;
+import java.io.IOException;
+
import javax.jcr.Session;
import org.apache.sling.jcr.resource.internal.HelperData;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-class JcrProviderState {
+class JcrProviderState implements Closeable {
private final Session session;
@@ -63,12 +66,22 @@ class JcrProviderState {
return helperData;
}
+ @Override
+ public void close() throws IOException {
+ logout();
+ }
+
void logout() {
if (logout) {
session.logout();
}
if (bundleContext != null) {
- bundleContext.ungetService(repositoryRef);
+ try {
+ bundleContext.ungetService(repositoryRef);
+ } catch ( final IllegalStateException ise ) {
+ // this might happen on shutdown / updates (bundle is invalid)
+ // we can ignore this.
+ }
}
}
}