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 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") { val generateTemplates = tasks.register<Copy>("generateTemplates") {
inputs.properties( 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 { "commit" to provider {
val res = runCatching { project.extensions.getByType<Grgit>().head().id } val res = runCatching { project.extensions.getByType<Grgit>().head().id }
res.getOrDefault("") res.getOrDefault("")

View File

@@ -103,7 +103,7 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
} }
public static void dereference() { public static void dereference() {
dataLoaders.v().forEach(IrisData::cleanupEngine); dataLoaders.values().forEach(IrisData::cleanupEngine);
} }
public static int cacheSize() { public static int cacheSize() {

View File

@@ -63,14 +63,20 @@ public class IrisContext {
} }
} }
public static void dereference() { public static synchronized void dereference() {
for (Thread i : context.k()) { var it = context.entrySet().iterator();
if (!i.isAlive() || context.get(i).engine.isClosed()) { while (it.hasNext()) {
if (context.get(i).engine.isClosed()) { var entry = it.next();
Iris.debug("Dereferenced Context<Engine> " + i.getName() + " " + i.threadId()); 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();
} }
} }
} }