This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git
The following commit(s) were added to refs/heads/1.x by this push:
new 6143d689 DiskFileItem.getInputStream() now uses NIO
6143d689 is described below
commit 6143d68971f3e7ae617375cd356306feb61e15e9
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sat Mar 15 17:40:48 2025 -0400
DiskFileItem.getInputStream() now uses NIO
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java | 7 ++-----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 03127b4b..74c61b81 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,6 +52,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Use
try-with-resources.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Port to Java 1.4
Throwable APIs (!).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Remove -nouses
directive from maven-bundle-plugin. OSGi package imports now state 'uses'
definitions for package imports, this doesn't affect JPMS (from
org.apache.commons:commons-parent:80).</action>
+ <action type="fix" dev="ggregory" due-to="Gary
Gregory">DiskFileItem.getInputStream() now uses NIO.</action>
<!-- UPDATE -->
<action dev="ggregory" type="update">Bump Java from 6 to 8.</action>
<action dev="ggregory" type="update">Bump
org.apache.commons:commons-parent from 62 to 81, upgrades Doxia from 1 to
2.</action>
diff --git a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
index d5dfd152..c2819180 100644
--- a/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
+++ b/src/main/java/org/apache/commons/fileupload/disk/DiskFileItem.java
@@ -18,7 +18,6 @@ package org.apache.commons.fileupload.disk;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -320,12 +319,10 @@ public class DiskFileItem
* @throws IOException if an error occurs.
*/
@Override
- public InputStream getInputStream()
- throws IOException {
+ public InputStream getInputStream() throws IOException {
if (!isInMemory()) {
- return new FileInputStream(dfos.getFile());
+ return Files.newInputStream(dfos.getPath());
}
-
if (cachedContent == null) {
cachedContent = dfos.getData();
}