use try-with-resources statement in MavenProperties#2441
use try-with-resources statement in MavenProperties#2441Pankraz76 wants to merge 1 commit intoapache:masterfrom
try-with-resources statement in MavenProperties#2441Conversation
compat/maven-embedder/src/main/java/org/apache/maven/cli/props/MavenProperties.java
Show resolved
Hide resolved
c078b6c to
6981dd5
Compare
gnodet
left a comment
There was a problem hiding this comment.
That's wrong imho.
The one responsible for closing the out Writer should be the caller, as the writer is passed as an argument. Closing the PropertiesWriter will automatically close the out writer too, so that looks a bad idea to me.
|
yes this one looks special. will check, merci. |
the scope of lets request some secret expertise @elharo. 🥷
|
|
If the properties writer is not closed, it should be flushed immediately, gc can happen way after out is closed. |
yes then flush is mandatory. but is this really important? Assuming order will remain the same when impl. will flush itself. It feels like optimization not required by test nether by business case, assuming result is the same. Only real difference seems explicit call, of whats done by Never needed to use .flush as always the impl. is smart enough to do so. Its a expensive operation just like finalize should never been called directly. thats some else regards never to be called by dev imho. The cleanup order of the |

Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] SUMMARY,where you replace
MNG-XXXandSUMMARYwith the appropriate JIRA issue.[MNG-XXX] SUMMARY.Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
mvn clean verifyto make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.