Use InputStream.transferTo() instead of FileUtil.copy() and simplify usages#9278
Use InputStream.transferTo() instead of FileUtil.copy() and simplify usages#9278mbien merged 1 commit intoapache:masterfrom
Conversation
matthiasblaesing
left a comment
There was a problem hiding this comment.
I caught a few instances where a ByteArrayInputStream was used just to write a byte array to a stream. I don't see a reason, so I suggest to dump that.
There were other instances that could be replaced with InputStream#readAllBytes, but I scrolled through them until I noticed that, so I suggest to ignore these for now.
php/php.project/src/org/netbeans/modules/php/project/ui/customizer/PhpProjectProperties.java
Outdated
Show resolved
Hide resolved
java/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
Outdated
Show resolved
Hide resolved
java/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
Outdated
Show resolved
Hide resolved
...seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java
Outdated
Show resolved
Hide resolved
...ule/src/org/netbeans/modules/java/j2semodule/ui/customizer/J2SEModularProjectProperties.java
Outdated
Show resolved
Hide resolved
ide/web.browser.api/src/org/netbeans/modules/web/browser/spi/ExternalModificationsSupport.java
Outdated
Show resolved
Hide resolved
java/maven/src/org/netbeans/modules/maven/customizer/LicenseHeaderPanelProvider.java
Outdated
Show resolved
Hide resolved
platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/DelayFSEventsTest.java
Outdated
Show resolved
Hide resolved
platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/DelayFSEventsTest.java
Outdated
Show resolved
Hide resolved
I revisited the code section where the method was inlined and rewrote some of the usages as simplified ARM blocks, using I am not really expecting anyone to review this via github this since the changeset is now larger. Might be easier via IDE. I will take another good look myself before merging. |
cf8afa3 to
d2a9dc8
Compare
motivation: - JDK's InputStream implementation of transferTo() is somewhat similar to FileUtil.copy() (the buffer is a little bit smaller) - subclasses like BufferedInputStream, FileInputStream and others have specialized implementations changes: - deprecated FileUtil.copy() and replaced usage with transferTo() - bumped enterprise/web.jsf.navigation, enterprise/web.jsf, enterprise/websvc.utilities and groovy/groovy.samples to release 17 - bumped remaining rust cluster to release 21 - some sections were further simplified after inlining (ARM, readAllBytes() or write() conversions)
2c882f2 to
3909ded
Compare
|
looked through it again. will merge once CI is done. |
waited with this until most of the codebase migrated to JDK 17+ (#8813), so that we don't have to do it multiple times.
motivation:
InputStreamimplementation oftransferTo()is somewhat similar toFileUtil.copy()(the buffer is a little bit smaller)BufferedInputStream,FileInputStreamand others have specialized implementationschanges:
FileUtil.copy()and replaced usage withtransferTo()readAllBytes()orwrite(bytes)conversions)