Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When loading configuration from a Resource, Log4J2LoggingSystem may not close the InputStream #44467

Closed
wants to merge 1 commit into from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Feb 27, 2025

Javadoc of ConfigurationSource states:

@param stream the input stream, the caller is responsible for closing this resource.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 27, 2025
@nosan nosan changed the title When loading the Log4j2 configuration from a Resource, the InputStream remains open When loading the Log4j2 configuration from a Resource, the InputStream may remains open Feb 27, 2025
@nosan
Copy link
Contributor Author

nosan commented Feb 27, 2025

  • PropertiesConfigurationFactory closes stream
  • JsonConfigurationFactory closes stream
  • XmlConfigurationFactory closes stream
  • YamlConfigurationFactory closes stream

@wilkinsona wilkinsona changed the title When loading the Log4j2 configuration from a Resource, the InputStream may remains open When loading the Log4j2 configuration from a Resource, the InputStream may not be closed Feb 27, 2025
@wilkinsona wilkinsona changed the title When loading the Log4j2 configuration from a Resource, the InputStream may not be closed When loading configuration from a Resource, Log4J2LoggingSystem may not close the InputStream Feb 27, 2025
@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 28, 2025
@mhalbritter mhalbritter modified the milestones: 3.3.10, 3.3.x Feb 28, 2025
@nosan
Copy link
Contributor Author

nosan commented Feb 28, 2025

I've revisited this one once again, and all underlying Log4j2 ConfigurationFactory close the ConfigurationSource.stream

@nosan
Copy link
Contributor Author

nosan commented Feb 28, 2025

Meanwhile, you can register your own ConfigurationFactory and rely on the caller to close the stream.

@mhalbritter
Copy link
Contributor

Thanks @nosan !

mhalbritter added a commit that referenced this pull request Feb 28, 2025
* pr/44467:
  Close InputStream when loading Log4j2 Configuration from a Resource

Closes gh-44467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants