Skip to content

Close the JarFile owned by FileInJarReadableDataSource - #3662

Open
git-jxj wants to merge 1 commit into
alibaba:1.8from
git-jxj:fix/jar-datasource-close-resource
Open

git-jxj wants to merge 1 commit into
alibaba:1.8from
git-jxj:fix/jar-datasource-close-resource

Conversation

@git-jxj

@git-jxj git-jxj commented Oct 8, 2026

Copy link
Copy Markdown

Describe what this PR does / why we need it

FileInJarReadableDataSource.close() clears the buffer but leaves the owned JarFile open. Explicitly closing a data source therefore retains its file descriptor until the JAR is otherwise cleaned up.

Does this pull request fix one issue?

Fixes #3660

Describe how you did it

Close the owned JarFile before releasing the read buffer.

Describe how to verify it

Regression tests verify that the real JAR handle is closed after successful loading and after an initial parser failure, and that repeated closes are safe. Both tests fail before the fix and pass afterward.

A Linux JVM integration reproduction creates and closes 20 separate JAR data sources while retaining their objects. The unmodified implementation keeps 20 JAR file descriptors open; the patch keeps none open.

Validation on JDK 17:

mvn -B -pl sentinel-extension/sentinel-datasource-extension -am test -Dtest=FileInJarReadableDataSourceCloseTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B -pl sentinel-extension/sentinel-datasource-extension -am install -DskipTests=true -Dmaven.javadoc.skip=true -DminimumPriority=1

The matching module build, including the configured PMD check, also passes.

Special notes for reviews

Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io>
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.

[BUG] FileInJarReadableDataSource.close() does not release the JAR file

1 participant