ConfigLoader does not close file when loading hibernate.cfg.xml

Description

In org.hibernate.boot.cfgxml.internal.ConfigLoader#loadConfigXmlFile(File)
A FileInputStream is opened but never closed. This produces a resource-leak where the input file is kept open much longer than necessary. It is particularly problematicin web-applications, where the desire is to have near-zero downtime. It prevents a modification of the hibernate configuration while the web application server is running. It must first be stopped before the hibernate configuration can be edited.

This method should close the FileInputStream in a finally block:

The jaxbProcessorHolder object clearly cannot require the stream to remain open for any kind of background processes, because the same jaxbProcessorHolder is called in the method #loadConfigXmlUrl(URL url) where the opened InputStream is correctly closed.

Environment

None

Assignee

Unassigned

Reporter

nathan kummer

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure