| Bug #75691 | Resource is not closed in NonRegisteringDriver | ||
|---|---|---|---|
| Submitted: | 30 Jan 2015 6:20 | Modified: | 25 Jan 2022 9:16 |
| Reporter: | Shou Aoki | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 5.1.34 | OS: | Any |
| Assigned to: | Filipe Silva | CPU Architecture: | Any |
[5 Feb 2015 16:23]
Filipe Silva
Hi, Thank you for this bug report. It was verified as described.
[25 Jan 2022 9:16]
Alexander Soklakov
Posted by developer: This bug is not reproducible with the latest Connector/J 8.0. Connector/J 5.1 series came to EOL on Feb 9th, 2021, see https://www.mysql.com/support/eol-notice.html, so this bug will not be fixed there.

Description: Hi all, We found resource leak on com.mysql.jdbc.NonRegisteringDriver#parseURL. That code is following: ---------------------------------------------------- try { InputStream configAsStream = super.getClass().getResourceAsStream( "configs/" + configName + ".properties"); ... configProps.load(configAsStream); } catch (IOException ioEx) { ---------------------------------------------------- The variable configAsSystem is not closed. However getResourceAsStream() is use FileInputStream, This class will call close method by *finalize method*. So configAsStream will close when GC run but we want close immediately after load properties. How to repeat: When you use the "useConfigs" property. Suggested fix: Use try-with-resources with configAsStream variable.