make context dereference method fail-safe

This commit is contained in:
Julian Krings
2026-01-02 14:12:44 +01:00
parent 40b020fc5d
commit dbafe84fa5
3 changed files with 20 additions and 10 deletions

View File

@@ -182,10 +182,14 @@ tasks {
}
val templateSource = file("src/main/templates")
val templateDest = layout.buildDirectory.dir("generated/sources/templates")
val templateDest = layout.buildDirectory.dir("generated/sources/templates")!!
val generateTemplates = tasks.register<Copy>("generateTemplates") {
inputs.properties(
"environment" to if (project.hasProperty("release")) "production" else "development",
"environment" to when {
project.hasProperty("release") -> "producction"
project.hasProperty("argghh") -> "Argghh!"
else -> "development"
},
"commit" to provider {
val res = runCatching { project.extensions.getByType<Grgit>().head().id }
res.getOrDefault("")

View File

@@ -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() {

View File

@@ -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();
}
}
}