Skip to content

Conversation

@mehmetali2003
Copy link

@mehmetali2003 mehmetali2003 commented Oct 28, 2025

HHH-12986 ConfigLoader does not close file when loading hibernate.cfg.xml


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-12986

HHH-12986 ConfigLoader does not close file when loading hibernate.cfg.xml
@hibernate-github-bot
Copy link

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [631a47a]

› This message was automatically generated.

try {
FileInputStream cfgFileStream = null;
try {
cfgFileStream = new FileInputStream( cfgXmlFile );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using the auto-closable?

try (FileInputStream stream = new FileInputStream( cfgXmlFile )) {
			return LoadedConfig.consume( jaxbProcessorHolder.getValue()
					.unmarshal( stream,
							new Origin( FILE, cfgXmlFile.getAbsolutePath() ) ) );
		}
catch (FileNotFoundException e) {
			throw new ConfigurationException(
					"Specified cfg.xml file [" + cfgXmlFile.getAbsolutePath() + "] does not exist"
			);
		}
		catch (IOException e) {
			log.debug( "Unable to close cfg.xml URL stream", e );
		}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems reasonable.

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.

2 participants