fix(core): Disable manifest URL caching when reading versions (JAVA-730) - #6124
Open
0xadam-brown wants to merge 1 commit into
Open
0xadam-brown wants to merge 1 commit into
0xadam-brown wants to merge 1 commit into
Conversation
0xadam-brown
commented
Sep 16, 2026
| ClassLoader.getSystemClassLoader().getResources("META-INF/MANIFEST.MF"); | ||
| while (resources.hasMoreElements()) { | ||
| try { | ||
| final @NotNull Manifest manifest = new Manifest(resources.nextElement().openStream()); |
Member
Author
There was a problem hiding this comment.
Hard to see what happened b/c the diff realigns the indententation for most of this method. Here's what changed:
Before
final @NotNull Manifest manifest = new Manifest(resources.nextElement().openStream());
...After
final @NotNull URLConnection connection = resources.nextElement().openConnection();
connection.setUseCaches(false);
try (final @NotNull InputStream inputStream = connection.getInputStream()) {
...
}Note that simply closing the stream was insufficient to avoid leaking the jars. Verified with my clanker that disabling caches was also needed.
📲 Install BuildsAndroid
|
ManifestVersionReader was retaining jar-backed inflater state while scanning META-INF/MANIFEST.MF entries. Disable URL caching for those reads and close the stream after parsing.
0xadam-brown
force-pushed
the
fix/manifest-version-reader-leak
branch
from
September 16, 2026 15:38
a4d0445 to
1bb7493
Compare
0xadam-brown
marked this pull request as ready for review
September 16, 2026 15:38
0xadam-brown
requested review from
adinauer,
markushi,
romtsn and
runningcode
as code owners
September 16, 2026 15:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
ManifestVersionReader was retaining jar-backed inflater state while scanning META-INF/MANIFEST.MF entries. PR fixes that by disabling URL caching for those reads and close the stream after parsing.
💡 Motivation and Context
Note that the ManifestVersionReader is invoked during
Sentry.init(), but only on the JVM (not on Android). Performance penalty for the fix is limited:resolves: JAVA-730
💚 How did you test it?
I had my clanker reproduce the issue, then fix, then verify we were no longer leaking the jars.
No tests added because ManifestVersionReader is currently without a test suite, and adding it would require introducing a new constructor with a ClassLoader argument. Happy to do so if folks prefer, but for now I've kept the change minimal.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps