Skip to content

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

Open

Description

@git-jxj

Issue Description

Type: bug report

Describe what happened

FileInJarReadableDataSource opens a JarFile during construction, but its close() method only sets the read buffer to null. The JarFile remains open after the data source is closed.

On Linux, creating and closing 20 data sources for 20 different temporary JARs leaves all 20 JAR file descriptors open while those closed data source objects remain reachable. This can consume file descriptors during repeated data source initialization and cleanup, and retain locks on JAR files on platforms that lock open files.

Describe what you expected to happen

Closing the data source should immediately close its owned JarFile, including when the initial configuration parser fails. Repeated closes should remain safe.

How to reproduce it (as minimally and precisely as possible)

  1. Create 20 distinct temporary JAR files using JarOutputStream, each containing rules.json with the content [].
  2. For each JAR, construct a FileInJarReadableDataSource<String> with an identity converter, retain the data source in a list, and call close().
  3. Inspect /proc/self/fd symlink targets within the same JVM for those temporary JAR paths.

Observed with the current 1.8 branch (a3f40ba8e900c8489bd520274739f17235a7721c):

JAR descriptors before=0; after closing 20 sources=20

Closing the owned JarFile in close() gives:

JAR descriptors before=0; after closing 20 sources=0

Tell us your environment

Linux, Eclipse Temurin JDK 17.0.20.1, current 1.8 branch. The file descriptor check uses real JAR files and real data sources without mocks.

Anything else we need to know?

This resource lifecycle issue is independent of how entry contents are read.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions