Use try-with-resources
New feature, improvement proposal
There's a lot of code like this scattered throughout the project:
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
if (data != null) {
fos.write(data.getBytes(StandardCharsets.UTF_8));
}
fos.close();
fos = null;
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (final IOException e) {
// Suppressed due to an exception already thrown in the try block.
}
}
Use try-with-resources from Java 7
Hi @elharo,
I’m interested in contributing to this issue. Could you please provide more details on where to start? For example, are there specific classes or files that need changes, or does this require broader modifications across the codebase? Any guidance on the scope of the work would be greatly appreciated.
Thanks!
Hi @elharo,
I’m interested in contributing to this issue. Could you please provide more details on where to start? For example, are there specific classes or files that need changes, or does this require broader modifications across the codebase? Any guidance on the scope of the work would be greatly appreciated.
Thanks!
Hi @sidhantmourya, it's affect the whole codebase. Just go through file by file.
hi @Bukama, thank you for the heads-up! I’ve gone through the documentation on contributing patches: https://maven.apache.org/guides/development/guide-maven-development.html. While it explains the patch creation process, I’m still unsure about how to actually start working on the project — especially in terms of debugging or navigating the codebase.
I’ve already forked the repository, but since I’ve never contributed to a large open-source Java project like this before, I’d really appreciate some guidance on how to set up the development environment. For example:
Is there a recommended IDE for working with Maven’s codebase? (e.g., IntelliJ IDEA or Eclipse)
Do I need to import it as a Maven project into the IDE, or is working directly from a text editor like VS Code also feasible?
Are there specific tips or best practices for exploring or understanding the project layout?
Any help on how to effectively get started with the development workflow would be greatly appreciated!
Hi @Bukama if this issue is still open I want to work on it
Fixed: https://github.com/apache/maven-resolver/pull/1623
Hi,
I noticed that PR #1623 appears to address the changes proposed here. Is there any remaining work related to this issue, or should it be considered resolved?
Thanks.
It isn't resolved until it's fixed. #1623 is not merged at this time.
hello @elharo , I saw the recent discussion and the clarification that the issue is still open since PR #1623 hasn't merged. I would like to take this on now and complete the refactoring of all remaining try-finally blocks to use try-with-resources. I will submit a new Pull Request shortly.
It isn't resolved until it's fixed. #1623 is not merged at this time.
Thanks for the clarification.
Given that this affects the whole codebase and some related changes are already in progress, would it be acceptable to contribute smaller, focused PRs (e.g., one module or test package at a time) to continue this work? If so, is there any specific area you’d recommend starting with?
Thanks.