olamy commented on code in PR #1623:
URL: https://github.com/apache/maven-resolver/pull/1623#discussion_r2423371660
##########
maven-resolver-test-util/src/main/java/org/eclipse/aether/internal/test/util/TestFileProcessor.java:
##########
@@ -63,46 +63,18 @@ public boolean mkdirs(File directory) {
public void write(File file, String data) throws IOException {
mkdirs(file.getParentFile());
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(file);
-
+ try (FileOutputStream 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.
- }
}
}
public void write(File target, InputStream source) throws IOException {
mkdirs(target.getAbsoluteFile().getParentFile());
- OutputStream fos = null;
- try {
- fos = new BufferedOutputStream(new FileOutputStream(target));
-
+ try (OutputStream fos = new BufferedOutputStream(new
FileOutputStream(target))) {
Review Comment:
Are we sure `new FileOutputStream` is correctly close? Why not
`Files.newOuputStream` what is the reasoning not using it?
--
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]