mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-09 01:06:05 +00:00
make context dereference method fail-safe
This commit is contained in:
@@ -103,7 +103,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
}
|
||||
|
||||
public static void dereference() {
|
||||
dataLoaders.v().forEach(IrisData::cleanupEngine);
|
||||
dataLoaders.values().forEach(IrisData::cleanupEngine);
|
||||
}
|
||||
|
||||
public static int cacheSize() {
|
||||
|
||||
@@ -63,14 +63,20 @@ public class IrisContext {
|
||||
}
|
||||
}
|
||||
|
||||
public static void dereference() {
|
||||
for (Thread i : context.k()) {
|
||||
if (!i.isAlive() || context.get(i).engine.isClosed()) {
|
||||
if (context.get(i).engine.isClosed()) {
|
||||
Iris.debug("Dereferenced Context<Engine> " + i.getName() + " " + i.threadId());
|
||||
}
|
||||
public static synchronized void dereference() {
|
||||
var it = context.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
var entry = it.next();
|
||||
var thread = entry.getKey();
|
||||
var context = entry.getValue();
|
||||
if (thread == null || context == null) {
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
context.remove(i);
|
||||
if (!thread.isAlive() || context.engine.isClosed()) {
|
||||
Iris.debug("Dereferenced Context<Engine> " + thread.getName() + " " + thread.threadId());
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user