You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/10 16:52:33 UTC
[commons-io] branch master updated: Add DeferredFileOutputStream.getPath().
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 8d8935e0 Add DeferredFileOutputStream.getPath().
8d8935e0 is described below
commit 8d8935e0d6118b35eb744f16b4ad819758d87218
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 10 12:52:28 2023 -0400
Add DeferredFileOutputStream.getPath().
Bump version from 2.13.1 to 2.14.0 due to new API
---
pom.xml | 6 +++---
src/changes/changes.xml | 8 +++++++-
.../io/output/DeferredFileOutputStream.java | 23 ++++++++++++++++++----
.../io/output/DeferredFileOutputStreamTest.java | 9 ++++++---
4 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/pom.xml b/pom.xml
index 837eee26..fab23973 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.13.1-SNAPSHOT</version>
+ <version>2.14.0-SNAPSHOT</version>
<name>Apache Commons IO</name>
<inceptionYear>2002</inceptionYear>
@@ -294,8 +294,8 @@ file comparators, endian transformation classes, and much more.
<commons.componentid>io</commons.componentid>
<commons.module.name>org.apache.commons.io</commons.module.name>
<commons.rc.version>RC1</commons.rc.version>
- <commons.bc.version>2.12.0</commons.bc.version>
- <commons.release.version>2.13.0</commons.release.version>
+ <commons.bc.version>2.13.0</commons.bc.version>
+ <commons.release.version>2.14.0</commons.release.version>
<commons.release.desc>(requires Java 8)</commons.release.desc>
<commons.jira.id>IO</commons.jira.id>
<commons.jira.pid>12310477</commons.jira.pid>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 90ecd182..ad806944 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,10 +47,16 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
- <release version="2.13.1" date="2023-MM-DD" description="Java 8 required.">
+ <release version="2.14.0" date="2023-MM-DD" description="Java 8 required.">
+ <!-- ADD -->
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add DeferredFileOutputStream.getPath().
+ </action>
+ <!-- FIX -->
<action dev="ggregory" type="fix" issue="IO-799" due-to="Jeroen van der Vegt, Gary Gregory">
ReaderInputStream.read() throws an exception instead of returning -1 when called again after returning -1.
</action>
+ <!-- UPDATE -->
</release>
<release version="2.13.0" date="2023-06-03" description="Java 8 required.">
<!-- FIX -->
diff --git a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
index 78bc4b9c..606bd5b7 100644
--- a/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
@@ -297,19 +297,34 @@ public class DeferredFileOutputStream extends ThresholdingOutputStream {
}
/**
- * Gets either the output file specified in the constructor or the temporary file created or null.
+ * Gets either the output File specified in the constructor or the temporary File created or null.
* <p>
- * If the constructor specifying the file is used then it returns that same output file, even when threshold has not been reached.
+ * If the constructor specifying the File is used then it returns that same output File, even when threshold has not been reached.
* <p>
- * If constructor specifying a temporary file prefix/suffix is used then the temporary file created once the threshold is reached is returned If the
+ * If constructor specifying a temporary File prefix/suffix is used then the temporary File created once the threshold is reached is returned if the
* threshold was not reached then {@code null} is returned.
*
- * @return The file for this output stream, or {@code null} if no such file exists.
+ * @return The File for this output stream, or {@code null} if no such File exists.
*/
public File getFile() {
return outputPath != null ? outputPath.toFile() : null;
}
+ /**
+ * Gets either the output Path specified in the constructor or the temporary Path created or null.
+ * <p>
+ * If the constructor specifying the file is used then it returns that same output Path, even when threshold has not been reached.
+ * <p>
+ * If constructor specifying a temporary Path prefix/suffix is used then the temporary Path created once the threshold is reached is returned if the
+ * threshold was not reached then {@code null} is returned.
+ *
+ * @return The Path for this output stream, or {@code null} if no such Path exists.
+ * @since 2.14.0
+ */
+ public Path getPath() {
+ return outputPath;
+ }
+
/**
* Gets the current output stream. This may be memory based or disk based, depending on the current state with respect to the threshold.
*
diff --git a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
index 35038d2e..8b01b5c8 100644
--- a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
@@ -200,7 +200,8 @@ public class DeferredFileOutputStreamTest {
.setDirectory(tempDir)
.get();
// @formatter:on
- assertNull(dfos.getFile(), "Check file is null-A");
+ assertNull(dfos.getFile(), "Check File is null-A");
+ assertNull(dfos.getPath(), "Check Path is null-A");
dfos.write(testBytes, 0, testBytes.length);
dfos.close();
assertFalse(dfos.isInMemory());
@@ -237,7 +238,8 @@ public class DeferredFileOutputStreamTest {
.setDirectory(tempDir)
.get();
// @formatter:on
- assertNull(dfos.getFile(), "Check file is null-A");
+ assertNull(dfos.getFile(), "Check File is null-A");
+ assertNull(dfos.getPath(), "Check Path is null-A");
dfos.write(testBytes, 0, testBytes.length);
dfos.close();
assertFalse(dfos.isInMemory());
@@ -265,7 +267,8 @@ public class DeferredFileOutputStreamTest {
final String suffix = ".out";
final File tempDir = FileUtils.current();
final DeferredFileOutputStream dfos = new DeferredFileOutputStream(testBytes.length + 42, initialBufferSize, prefix, suffix, tempDir);
- assertNull(dfos.getFile(), "Check file is null-A");
+ assertNull(dfos.getFile(), "Check File is null-A");
+ assertNull(dfos.getPath(), "Check Path is null-A");
dfos.write(testBytes, 0, testBytes.length);
dfos.close();
assertTrue(dfos.isInMemory());