提交 f02b149f 编写于 作者: P prr

8172461: Service Registration Lifecycle

Reviewed-by: serb, vadim, skoivu, shurailine
上级 7fe61077
......@@ -26,6 +26,9 @@
package javax.imageio.spi;
import java.io.File;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
......@@ -701,11 +704,12 @@ class SubRegistry {
Class category;
// Provider Objects organized by partial oridering
PartiallyOrderedSet poset = new PartiallyOrderedSet();
// Provider Objects organized by partial ordering
final PartiallyOrderedSet poset = new PartiallyOrderedSet();
// Class -> Provider Object of that class
Map<Class<?>,Object> map = new HashMap();
final Map<Class<?>,Object> map = new HashMap();
final Map<Class<?>,AccessControlContext> accMap = new HashMap<>();
public SubRegistry(ServiceRegistry registry, Class category) {
this.registry = registry;
......@@ -720,6 +724,7 @@ class SubRegistry {
deregisterServiceProvider(oprovider);
}
map.put(provider.getClass(), provider);
accMap.put(provider.getClass(), AccessController.getContext());
poset.add(provider);
if (provider instanceof RegisterableService) {
RegisterableService rs = (RegisterableService)provider;
......@@ -739,6 +744,7 @@ class SubRegistry {
if (provider == oprovider) {
map.remove(provider.getClass());
accMap.remove(provider.getClass());
poset.remove(provider);
if (provider instanceof RegisterableService) {
RegisterableService rs = (RegisterableService)provider;
......@@ -785,10 +791,17 @@ class SubRegistry {
if (provider instanceof RegisterableService) {
RegisterableService rs = (RegisterableService)provider;
rs.onDeregistration(registry, category);
AccessControlContext acc = accMap.get(provider.getClass());
if (acc != null || System.getSecurityManager() == null) {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
rs.onDeregistration(registry, category);
return null;
}, acc);
}
}
}
poset.clear();
accMap.clear();
}
public void finalize() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册