You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2015/04/07 18:13:55 UTC
karaf git commit: [KARAF-3625] Give some time to find encryption
service in order to avoid race condition throwing IllegalStateException
Repository: karaf
Updated Branches:
refs/heads/karaf-2.x fc26ae0c2 -> 02ae75d22
[KARAF-3625] Give some time to find encryption service in order to avoid race condition throwing IllegalStateException
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/02ae75d2
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/02ae75d2
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/02ae75d2
Branch: refs/heads/karaf-2.x
Commit: 02ae75d227b21b9e4b365ba4b7a2a5b02bfd9bb2
Parents: fc26ae0
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue Apr 7 18:13:07 2015 +0200
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue Apr 7 18:13:07 2015 +0200
----------------------------------------------------------------------
.../jaas/modules/encryption/EncryptionSupport.java | 16 +++++++++++++++-
.../OSGI-INF/blueprint/karaf-jaas-module.xml | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/02ae75d2/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java
index cc2d074..3af884e 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java
@@ -78,6 +78,20 @@ public class EncryptionSupport {
encryptionServiceReferences = bundleContext.getServiceReferences(
EncryptionService.class.getName(),
name != null && name.length() > 0 ? "(name=" + name + ")" : null);
+ int timeout = 0;
+ while (encryptionServiceReferences == null || encryptionServiceReferences.length == 0) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException ie) {
+ // nothing to do
+ }
+ encryptionServiceReferences = bundleContext.getServiceReferences(
+ EncryptionService.class.getName(),
+ name != null && name.length() > 0 ? "(name=" + name + ")" : null);
+ timeout++;
+ if (timeout == 40)
+ break;
+ }
} catch (InvalidSyntaxException e) {
throw new IllegalStateException("The encryption service filter is not well formed.", e);
}
@@ -85,7 +99,7 @@ public class EncryptionSupport {
if (name != null && name.length() > 0) {
throw new IllegalStateException("Encryption service " + name + " not found. Please check that the encryption service is correctly set up.");
} else {
- throw new IllegalStateException("No encryption service found. Please install the Karaf encryption feature and check that the encryption algorithm is supported..");
+ throw new IllegalStateException("No encryption service found. Please install the Karaf encryption feature and check that the encryption algorithm is supported.");
}
}
Arrays.sort(encryptionServiceReferences);
http://git-wip-us.apache.org/repos/asf/karaf/blob/02ae75d2/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
----------------------------------------------------------------------
diff --git a/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml b/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
index b4d0740..915f076 100644
--- a/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
+++ b/jaas/modules/src/main/resources/OSGI-INF/blueprint/karaf-jaas-module.xml
@@ -71,7 +71,7 @@
</jaas:module>
</jaas:config>
- <!-- Properties installer -->
+ <!-- AutoEncryption support -->
<bean class="org.apache.karaf.jaas.modules.properties.AutoEncryptionSupport"
init-method="init" destroy-method="destroy">
<argument>