This commit is contained in:
Phillip Webb
2017-12-13 13:54:22 -08:00
parent 5ca608330c
commit 3273859fde
26 changed files with 83 additions and 75 deletions

View File

@@ -361,12 +361,17 @@ public class Restarter {
((Set<?>) instance).clear();
}
if (instance instanceof Map) {
Map<?, ?> map = ((Map<?, ?>) instance);
map.keySet().removeIf(value -> value instanceof Class && ((Class<?>) value)
.getClassLoader() instanceof RestartClassLoader);
((Map<?, ?>) instance).keySet().removeIf(this::isFromRestartClassLoader);
}
}
private boolean isFromRestartClassLoader(Object object) {
if (object instanceof Class) {
return ((Class<?>) object).getClassLoader() instanceof RestartClassLoader;
}
return false;
}
/**
* Cleanup any soft/weak references by forcing an {@link OutOfMemoryError} error.
*/
@@ -434,8 +439,7 @@ public class Restarter {
}
}
public Object getOrAddAttribute(String name,
final ObjectFactory<?> objectFactory) {
public Object getOrAddAttribute(String name, final ObjectFactory<?> objectFactory) {
synchronized (this.attributes) {
if (!this.attributes.containsKey(name)) {
this.attributes.put(name, objectFactory.getObject());