This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 8ee2ebb [KARAF-5506]use ThreadLocal for the visible service cache so
that different shell for different users/roles won't interfere each other
8ee2ebb is described below
commit 8ee2ebb23e6c2ff55ea109a1e2b8b57dc738e178
Author: Freeman Fang <[email protected]>
AuthorDate: Wed Nov 29 19:44:49 2017 +0800
[KARAF-5506]use ThreadLocal for the visible service cache so that different
shell for different users/roles won't interfere each other
---
.../console/osgi/secured/SecuredSessionFactoryImpl.java | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
index 0a23245..0d9812c 100644
---
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
+++
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
@@ -69,7 +69,7 @@ public class SecuredSessionFactoryImpl extends
SessionFactoryImpl implements Con
private Map<String, Dictionary<String, Object>> scopes = new HashMap<>();
private SingleServiceTracker<ConfigurationAdmin> configAdminTracker;
private ServiceRegistration<ConfigurationListener> registration;
- private Map<Object, Boolean> serviceVisibleMap = new HashMap<>();
+ private ThreadLocal<Map<Object, Boolean>> serviceVisibleMap = new
ThreadLocal<>();
public SecuredSessionFactoryImpl(BundleContext bundleContext, ThreadIO
threadIO) throws InvalidSyntaxException {
super(threadIO);
@@ -104,17 +104,20 @@ public class SecuredSessionFactoryImpl extends
SessionFactoryImpl implements Con
@Override
protected boolean isVisible(Object service) {
- if (this.serviceVisibleMap.get(service) != null) {
- return this.serviceVisibleMap.get(service);
+ if (this.serviceVisibleMap.get() == null) {
+ this.serviceVisibleMap.set(new HashMap<>());
+ }
+ if (this.serviceVisibleMap.get().get(service) != null) {
+ return this.serviceVisibleMap.get().get(service);
}
if (service instanceof Command) {
Command cmd = (Command) service;
boolean ret = isVisible(cmd.getScope(), cmd.getName());
- this.serviceVisibleMap.put(service, ret);
+ this.serviceVisibleMap.get().put(service, ret);
return ret;
} else {
boolean ret = super.isVisible(service);
- this.serviceVisibleMap.put(service, ret);
+ this.serviceVisibleMap.get().put(service, ret);
return ret;
}
}
@@ -282,7 +285,9 @@ public class SecuredSessionFactoryImpl extends
SessionFactoryImpl implements Con
try {
synchronized(this.serviceVisibleMap) {
- this.serviceVisibleMap.clear();
+ if (this.serviceVisibleMap.get() != null) {
+ this.serviceVisibleMap.get().clear();
+ }
}
switch (event.getType()) {
case ConfigurationEvent.CM_DELETED:
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].