From f76cdf0786f0045c86aac07d6e1d60a4c65c6c3a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 16:43:03 +0000 Subject: [PATCH 1/2] Initial plan From 50f1d51d832bae20f86271db8b48b229626a46af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 16:47:44 +0000 Subject: [PATCH 2/2] Fix resource leak: wrap InputStream in try-with-resources in CritterGizmoGenerator Co-authored-by: evanchooly <195021+evanchooly@users.noreply.github.com> --- .../critter/parser/gizmo/CritterGizmoGenerator.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/dev/morphia/critter/parser/gizmo/CritterGizmoGenerator.java b/core/src/main/java/dev/morphia/critter/parser/gizmo/CritterGizmoGenerator.java index 1f6082cebae..b76c1828f77 100644 --- a/core/src/main/java/dev/morphia/critter/parser/gizmo/CritterGizmoGenerator.java +++ b/core/src/main/java/dev/morphia/critter/parser/gizmo/CritterGizmoGenerator.java @@ -23,11 +23,10 @@ public static GizmoEntityModelGenerator generate(Class type, CritterClassLoad Generators generators, boolean runtimeMode) { ClassNode classNode = new ClassNode(); String resourceName = "%s.class".formatted(type.getName().replace('.', '/')); - java.io.InputStream inputStream = type.getClassLoader().getResourceAsStream(resourceName); - if (inputStream == null) { - throw new IllegalArgumentException("Could not find class file for %s".formatted(type.getName())); - } - try { + try (java.io.InputStream inputStream = type.getClassLoader().getResourceAsStream(resourceName)) { + if (inputStream == null) { + throw new IllegalArgumentException("Could not find class file for %s".formatted(type.getName())); + } new ClassReader(inputStream).accept(classNode, 0); } catch (IOException e) { throw new RuntimeException("Failed to read class %s".formatted(type.getName()), e);