Skip to content

Commit 860e354

Browse files
committed
Fix cohort handling in KnowledgeGraphNeo4j caching logic:
- Correct type assignment for `Cohort` validations by checking `ret.getClass` instead of `assetClass`. - Adjust caching logic to ensure proper type casting and error handling.
1 parent 7104119 commit 860e354

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

klab.services.runtime/src/main/java/org/integratedmodelling/klab/services/runtime/neo4j/KnowledgeGraphNeo4j.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,8 @@ protected <T extends RuntimeAsset> T retrieve(Object key, Class<T> assetClass, S
902902

903903
if (key instanceof Long id) {
904904
try {
905-
var ret = (T) assetCache.get(id, () -> retrieveFromGraph(id, assetClass, scope));
906-
if (Cohort.class.isAssignableFrom(assetClass)
905+
var ret = assetCache.get(id, () -> retrieveFromGraph(id, assetClass, scope));
906+
if (Cohort.class.isAssignableFrom(ret.getClass())
907907
&& ret instanceof CohortImpl cohort
908908
&& scope instanceof ContextScope contextScope) {
909909
// the cohort geometry is recomputed at each query
@@ -912,7 +912,7 @@ protected <T extends RuntimeAsset> T retrieve(Object key, Class<T> assetClass, S
912912
cohort.setGeometry(cohortGeometry);
913913
}
914914
}
915-
return ret;
915+
return (T) ret;
916916
} catch (Throwable e) {
917917
// fall back to other strategy
918918
Logging.INSTANCE.warn("Ignoring unexpected cache error in service-side knowledge graph", e);

0 commit comments

Comments
 (0)