neilcsmith-net commented on code in PR #153:
URL:
https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/153#discussion_r1510935202
##########
nb-repository-plugin/src/main/java/org/apache/netbeans/nbm/repository/PopulateRepositoryMojo.java:
##########
@@ -1105,17 +1104,24 @@ else if ( wr instanceof ModuleWrapperMaven )
// mavenModel.setBuild(build);
File fil = null;
- try ( FileWriter writer = new FileWriter( fil ) )
+ try
{
- MavenXpp3Writer xpp = new MavenXpp3Writer();
- fil = Files.createTempFile( "maven", ".pom" ).toFile();
+ fil = Files.createTempFile("maven", ".pom").toFile();
fil.deleteOnExit();
- xpp.write( writer, mavenModel );
- }
- catch ( IOException ex )
+ } catch (IOException ex)
{
ex.printStackTrace();
- }
+ }
+ if (fil != null) {
Review Comment:
Would this not be better as nested `try`?
```
try {
File file = Files.createTempFile("maven", ".pom").toFile();
file.deleteOnExit();
try (FileWriter writer = new FileWriter(file)) {
// write
}
} catch (IOException ex) {
// handle all exceptions
}
```
It's a shame try-with-resources doesn't seem to handle intermediate
declarations that are not `AutoCloseable`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists