Fix Resource Leaks with Try-With-Resources Pattern#586
Conversation
|
@cyrille-artho or @Mahmoud-Khawaja can you please review this |
|
Hi Pritam, |
|
@Mahmoud-Khawaja Sure, thank's for the feedback, if there are any improvement with this PR if you feel, please let me konw |
|
@cyrille-artho can you please review it |
|
@cyrille-artho can you please review this |
cyrille-artho
left a comment
There was a problem hiding this comment.
Thank you for your effort with various code involving try.
Can you please elaborate on the new one-line try blocks that have neither a catch nor finally block associated to them?
Furthermore, why remove the lines br.close() in several places?
It may be a good idea to split your PR into smaller ones so we can review the changes one by one.
| } | ||
| } | ||
| } | ||
| br.close(); |
There was a problem hiding this comment.
Please reinstate the lines that close br as to ensure efficient resource handling.
|
@cyrille-artho
If you prefer keeping the explicit close() calls for clarity, I can restore them please let me know your preference. |
|
Sorry for the late response; various factors coincided that prevented me from getting back to this earlier. |
Description
This PR fixes multiple resource leaks across the JPF core codebase.
Several
FileInputStream,FileReader, andBufferedReaderinstances were not being closed properly, which could lead to file handle exhaustion and memory leaks during long JPF runs.fixes - #585
Changes Made
JPF_java_lang_System.javaFileInputStreamingetSysPropsFromFile()LogConsole.javaBufferedReaderinrun()Config.javaFileInputStreamleaks inloadProperties()RepositoryEntry.javaJPFSiteUtils.javaFileReader/BufferedReaderleaks in utility methodsTotal: 14 resource leaks fixed.
Example
Before
After
Testing
✅ All 1,030 tests passed
✅ Verified with
./gradlew buildJars test✅ Manually tested with
java -jar build/RunJPF.jar src/examples/Racer.jpf✅ No functional or behavioral changes
Test Summary:
Impact
finallyblocks)Checklist