-
Notifications
You must be signed in to change notification settings - Fork 32
try with resources #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| try ( FileOutputStream outputStream = new FileOutputStream( file ) ) | ||
| { | ||
| outputStream.write( data.getBytes() ); | ||
| outputStream.flush(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think the .flush() is guaranteed by try-with-resources... but perhaps by not wrapping FOS in a BufferedOutputStream then that's not a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close also flushes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @roxspring is right about FOS not wrapped in BOS not being problem for flushing or not. But I'm not sure that close also flushes. There is flush called in FOS.finalize but close inherited from OutputStream is no-op (immaterial), as FOS.close doesn't seem to call flush neither.
On the other hand close of BufferedOutputStream flushes indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling flush just before close is generally useless cause close ensures all data have been written.
That said we are speaking of a FileOutputStream where flush() is a noop so it is even safer to drop.
…m 2.6 to 3.3.1 Bumps org.apache.maven.plugins:maven-resources-plugin from 2.6 to 3.3.1. ## Release notes Sourced from org.apache.maven.plugins:maven-resources-plugin's releases. 3.3.1 [MRESOURCES-288] - Make tests-jar reproducible (#56) @cstamas [MRESOURCES-297] - Update to parent POM 39, reformat (#55) @cstamas [MRESOURCES-293] - Make resources param not read-only (#54) @cstamas [MRESOURCES-295] - Drop Plexus legacy code (#53) @cstamas [MRESOURCES-294] - Upgrade plexus-utils to 3.5.1 (#52) @slachiewicz 🚨 Removed remove specific IDE m2e files (#40) @olamy 📦 Dependency updates Bump apache/maven-gh-actions-shared from 2 to 3 (#46) @dependabot 📝 Documentation updates doc: adds alternative variable syntax using @ delimiters to the documentation (#36) @kevin0x90 3.3.0 📦 Dependency updates Bump maven-filtering from 3.2.0 to 3.3.0 (#32) @dependabot Bump plexus-utils from 3.4.1 to 3.4.2 (#28) @dependabot Bump commons-io from 1.4 to 2.7 in /src/it/user-filters (#18) @dependabot [MRESOURCES-282] - Bump parent-pom from 34 to 36 (#24) @slachiewicz 📝 Documentation updates (doc) Fix XML formatting (#26) @pzygielo (doc) Fix XML formatting (#15) @pzygielo 👻 Maintenance add release drafter (#29) @olamy [MRESOURCES-277] - Update plugin (requires Maven 3.2.5+) - Java 8 (#23) @slachiewicz [MRESOURCES-283] - Require Java 8 and upgrade deps (#22) @slachiewicz 3.2.0 What's Changed [MRESOURCES-259] update commons-io by @elharo in apache/maven-resources-plugin#1 add .checkstyle to .gitignore by @elharo in apache/maven-resources-plugin#2 close file by @elharo in apache/maven-resources-plugin#3 [MRESOURCES-261] update to Maven 3.1 by @elharo in apache/maven-resources-plugin#4 try with resources by @elharo in apache/maven-resources-plugin#5 future proof method that is marked for incompatible change by @elharo in apache/maven-resources-plugin#6 New Contributors ... (truncated) ## Commits 978ce1e [maven-release-plugin] prepare release maven-resources-plugin-3.3.1 b7cd080 [MRESOURCES-296] Upgrade to maven-filtering 3.3.1 1c9f610 [MRESOURCES-288] Make tests-jar reproducible (#56) 1946127 [MRESOURCES-293] Rollback f7a6f22 [MRESOURCES-297] Update to parent POM 39, reformat (#55) 22d64ca remove specific IDE m2e files (#40) 02c2d01 [MRESOURCES-293] Make resources param not read-only (#54) 6bb3e1f [MRESOURCES-295] Drop Plexus legacy code (#53) df7e172 [MRESOURCES-294] Upgrade plexus-utils to 3.5.1 9354ecd Bump apache/maven-gh-actions-shared from 2 to 3 Additional commits viewable in compare view  Issue-ID: CIMAN-33 Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: lfit.gh2gerrit <releng+lfit-gh2gerrit@linuxfoundation.org> Change-Id: I7ec3f0f8fb35c0771c23e8199cea48b265706f0b GitHub-PR: #23 GitHub-Hash: d4984246f920c32a
@roxspring