Repository: karaf
Updated Branches:
refs/heads/karaf-3.0.x 215f002f3 -> 24a71cc0e
[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/24a71cc0
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/24a71cc0
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/24a71cc0
Branch: refs/heads/karaf-3.0.x
Commit: 24a71cc0e5ac7de47e9541de724497e4523e68df
Parents: 215f002
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Tue Apr 7 18:13:07 2015 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Tue Apr 7 18:59:04 2015 +0200
----------------------------------------------------------------------
.../jaas/modules/encryption/EncryptionSupport.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/24a71cc0/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 ebdaa77..18e695d 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);
|