Skip to content

Release the classpath ResourceLoader when scomp fails - #111

Merged
pjfanning merged 1 commit into
apache:trunkfrom
pjfanning:leak-schemacompiler-classpath
Sep 7, 2026
Merged

Release the classpath ResourceLoader when scomp fails#111
pjfanning merged 1 commit into
apache:trunkfrom
pjfanning:leak-schemacompiler-classpath

Conversation

@pjfanning

Copy link
Copy Markdown
Member

SchemaCompiler.compile builds a PathResourceLoader over the -cp entries — which opens a ZipFile per jar — and closes it on the last line of the method:

if (cpResourceLoader != null) {
    cpResourceLoader.close();
}
return result;

Nothing guards the ~100 lines in between. If loadTypeSystem, system.save(filer), generateTypes or the extension hooks throw, every classpath jar stays open for the life of the JVM. This is easy to hit when scomp is driven in-process (the Maven plugin, Ant task, or a build that catches the exception and carries on).

The body now runs in a try/finally. The change is almost entirely re-indentation — git diff -w shows just the try, the finally and a comment.

compile.scomp.checkin.CompilationTests passes.

🤖 Generated with Claude Code

SchemaCompiler.compile builds a PathResourceLoader over the -cp entries, which
opens a ZipFile per jar, and closes it on the last line of the method. Nothing
guards the path in between: if loadTypeSystem, system.save(filer),
generateTypes or the extension hooks throw, every classpath jar stays open for
the life of the JVM.

Put the body in a try/finally. The change is almost entirely re-indentation -
"git diff -w" shows the try, the finally and a comment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pjfanning
pjfanning merged commit 11034c8 into apache:trunk Sep 7, 2026
3 checks passed
@pjfanning
pjfanning deleted the leak-schemacompiler-classpath branch September 7, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant