fix: resolve resource leaks in GHService.getDiffStats() (#1660)#1661
fix: resolve resource leaks in GHService.getDiffStats() (#1660)#1661Fikri-20 wants to merge 1 commit intojenkins-infra:mainfrom
Conversation
4630494 to
1c84e11
Compare
|
I deleted the old getDiffStats() method in GHService.java. It was broken. Created The new version uses |
|
Hi, I see the Jenkins check is failing with 'mvn clean install' returning exit code 1, but I can't access the logs. My local tests and GitHub Actions (linux-25, windows-25) all pass. |
|
Hello, no need to consistently ping me. This is can be considered rude. Logs are on https://ci.jenkins.io Please only ping if you don't get any feedback after few days Thanks |
|
@jonesbusy Regarding the PR, I’m working on it now to figure out its failing tests, and continue working on. |
|
It's not about being upset but about distraction and constant notifications for non-urgent PR (that 90% of the time is AI slop) We are mentor, we do this mentorship on our free time This PR and description looks particulary suspicous to me. Auto generated PR and issue are easily catchable If ObjectReader need to be properly close I would use a try/cache/resource on existing code without extracting all logic into separate class |
jonesbusy
left a comment
There was a problem hiding this comment.
Only fix resource leak without creating new class (which make it difficult to review)
a8442c6 to
1552abf
Compare
|
@jonesbusy you're right, this PR was AI-assisted and I should revise it multiple times before submission.
I did that, please take a look. I'm new to Java and still learning. I appreciate you taking the time to explain the mistakes I might make. and I'm all ears to follow your instructions. I believe that over time, I'd meet your expectations of type and workflow of contribution to this project. Thanks! |
Properly close JGit resources using try-with-resources: - ObjectReader and DiffFormatter now in try-with-resources block - RevWalk wrapped in nested try-with-resources - Removes manual reader.close() call Fixes jenkins-infra#1660
1552abf to
ba20d90
Compare
Summary
Fixes resource leaks in
GHService.getDiffStats()by extracting JGit operationsto a new
DiffStatsCalculatorclass that uses proper try-with-resources.Changes
DiffStatsCalculator.java- encapsulates all JGit diff operationsGHService.getDiffStats()now delegates to DiffStatsCalculatorObjectReader- closed via try-with-resourcesDiffFormatter- closed via try-with-resourcesRevWalkinstances - closed via try-with-resourcesBug Fix
Testing done
Manual Testing:
Built the project with the fix:
Verified the code change:
DiffStatsCalculator.javawith proper try-with-resourcesGHService.getDiffStats()now delegates to DiffStatsCalculatorCode Analysis Proof:
ResourceLeakDemodemonstrating the leak pattern in original codeNo automated test added because:
Fixes #1660