[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555997&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555997
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 19:53
Start Date: 22/Feb/21 19:53
Worklog Time Spent: 10m 
  Work Description: garydgregory merged pull request #206:
URL: https://github.com/apache/commons-io/pull/206


   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555997)
Time Spent: 4h  (was: 3h 50m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 4h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555872&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555872
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 15:57
Start Date: 22/Feb/21 15:57
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782224839


   
   [![Coverage 
Status](https://coveralls.io/builds/37332860/badge)](https://coveralls.io/builds/37332860)
   
   Coverage increased (+0.1%) to 89.383% when pulling 
**99f52c851f263e12da83982d001db190331643d8 on 
jmark109:IO-651_DeferredFileOutputStream_getInputStream** into 
**5833b831ffe2bf8cdb74ee5567c8ae33abb0c7f4 on apache:master**.
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555872)
Time Spent: 3h 50m  (was: 3h 40m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555851&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555851
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 15:07
Start Date: 22/Feb/21 15:07
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-783439763


   @garydgregory Issues have been addressed.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555851)
Time Spent: 3h 40m  (was: 3.5h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555845&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555845
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:48
Start Date: 22/Feb/21 14:48
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580307445



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {
+final byte[] resultBytes = IOUtils.toByteArray(is);
+assertArrayEquals(testBytes, resultBytes);
+}
+}
+
+/**
+ * Tests the case where the amount of data exceeds the threshold, and is 
therefore written to disk. The actual data
+ * written to disk is verified, as is the file itself.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")

Review comment:
   Done.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555845)
Time Spent: 3.5h  (was: 3h 20m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555842&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555842
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:46
Start Date: 22/Feb/21 14:46
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580305820



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,

Review comment:
   Won't work here since the `DeferredFileOutputStream` needs to be closed 
while it is still in scope in order to execute `toInputStream()`





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555842)
Time Spent: 3h 20m  (was: 3h 10m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555840&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555840
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:43
Start Date: 22/Feb/21 14:43
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580302932



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");

Review comment:
   Removed.
   
   Was following pattern of existing test.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555840)
Time Spent: 3h 10m  (was: 3h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555839&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555839
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:42
Start Date: 22/Feb/21 14:42
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580302602



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,

Review comment:
   Done.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555839)
Time Spent: 3h  (was: 2h 50m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 3h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555837&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555837
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:41
Start Date: 22/Feb/21 14:41
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580301812



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {
+final byte[] resultBytes = IOUtils.toByteArray(is);
+assertArrayEquals(testBytes, resultBytes);
+}
+}
+
+/**
+ * Tests the case where the amount of data exceeds the threshold, and is 
therefore written to disk. The actual data
+ * written to disk is verified, as is the file itself.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testAboveThresholdGetInputStream(final int initialBufferSize, 
@TempDir Path tempDir) throws IOException {
+final File testFile = 
tempDir.resolve("testAboveThreshold.dat").toFile();
+
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length - 5, initialBufferSize,
+testFile);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertFalse(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {
+final byte[] resultBytes = IOUtils.toByteArray(is);
+assertArrayEquals(testBytes, resultBytes);

Review comment:
   Removed.
   Note, I was just following the pattern of the existing test.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555837)
Time Spent: 2h 50m  (was: 2h 40m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555836&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555836
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:41
Start Date: 22/Feb/21 14:41
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580301256



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {
+final byte[] resultBytes = IOUtils.toByteArray(is);
+assertArrayEquals(testBytes, resultBytes);
+}
+}
+
+/**
+ * Tests the case where the amount of data exceeds the threshold, and is 
therefore written to disk. The actual data
+ * written to disk is verified, as is the file itself.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testAboveThresholdGetInputStream(final int initialBufferSize, 
@TempDir Path tempDir) throws IOException {
+final File testFile = 
tempDir.resolve("testAboveThreshold.dat").toFile();
+
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length - 5, initialBufferSize,
+testFile);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertFalse(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {

Review comment:
   Fixed.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555836)
Time Spent: 2h 40m  (was: 2.5h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555835&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555835
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:40
Start Date: 22/Feb/21 14:40
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580300990



##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {

Review comment:
   Fixed.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555835)
Time Spent: 2.5h  (was: 2h 20m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-22 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555834&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555834
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 22/Feb/21 14:39
Start Date: 22/Feb/21 14:39
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r580300360



##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,31 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @throws IOException if this stream is not yet closed or an error occurs.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream#toInputStream()

Review comment:
   Added `@since`.
   
   I tried running the default maven build, but it doesn't work for me. It 
always dies in the middle with a "killed" message on the terminal. I did run 
all the individual goal that are part of the default build and they all 
complete successfully.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555834)
Time Spent: 2h 20m  (was: 2h 10m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=555277&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-555277
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 20/Feb/21 22:21
Start Date: 20/Feb/21 22:21
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r579716893



##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,31 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @throws IOException if this stream is not yet closed or an error occurs.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream#toInputStream()

Review comment:
   Ping. FYI, you should run the _default_ Maven build: 'mvn'.
   





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 555277)
Time Spent: 2h 10m  (was: 2h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554950&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554950
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 21:44
Start Date: 19/Feb/21 21:44
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r579489683



##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,31 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @throws IOException if this stream is not yet closed or an error occurs.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream#toInputStream()

Review comment:
   Needs a Javadoc since tag.

##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {
+final byte[] resultBytes = IOUtils.toByteArray(is);
+assertArrayEquals(testBytes, resultBytes);
+}
+}
+
+/**
+ * Tests the case where the amount of data exceeds the threshold, and is 
therefore written to disk. The actual data
+ * written to disk is verified, as is the file itself.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testAboveThresholdGetInputStream(final int initialBufferSize, 
@TempDir Path tempDir) throws IOException {
+final File testFile = 
tempDir.resolve("testAboveThreshold.dat").toFile();
+
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length - 5, initialBufferSize,
+testFile);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertFalse(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {

Review comment:
   Missing space after "try".

##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 fail("Unexpected IOException");
 }
 }
+
+/**
+ * Tests the case where the amount of data falls below the threshold, and 
is therefore confined to memory.
+ * Testing the getInputStream() method.
+ */
+@ParameterizedTest(name = "initialBufferSize = {0}")
+@MethodSource("data")
+public void testBelowThresholdGetInputStream(final int initialBufferSize) 
throws IOException {
+final DeferredFileOutputStream dfos = new 
DeferredFileOutputStream(testBytes.length + 42, initialBufferSize,
+null);
+try {
+dfos.write(testBytes, 0, testBytes.length);
+dfos.close();
+} catch (final IOException e) {
+fail("Unexpected IOException");
+}
+assertTrue(dfos.isInMemory());
+
+try(InputStream is = dfos.toInputStream()) {

Review comment:
   Missing space after "try".

##
File path: 
src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
##
@@ -365,4 +370,55 @@ private void verifyResultFile(final File testFile) {
 

[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554908&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554908
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 20:21
Start Date: 19/Feb/21 20:21
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782320401


   @garydgregory I think this is good to go now. Let me know if there are any 
other issue.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554908)
Time Spent: 1h 40m  (was: 1.5h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554909&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554909
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 20:21
Start Date: 19/Feb/21 20:21
Worklog Time Spent: 10m 
  Work Description: jmark109 edited a comment on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782320401


   @garydgregory I think this is good to go now. Let me know if there are any 
other issues.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554909)
Time Spent: 1h 50m  (was: 1h 40m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554879&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554879
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 19:13
Start Date: 19/Feb/21 19:13
Worklog Time Spent: 10m 
  Work Description: coveralls edited a comment on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782224839


   
   [![Coverage 
Status](https://coveralls.io/builds/37283381/badge)](https://coveralls.io/builds/37283381)
   
   Coverage decreased (-0.1%) to 89.254% when pulling 
**f424ab6d90fd01a1cad883d3a05c3a409c3a8405 on 
jmark109:IO-651_DeferredFileOutputStream_getInputStream** into 
**c54bf688e94b550c3ccd4c0789e0b3e00cf1d0ea on apache:master**.
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554879)
Time Spent: 1.5h  (was: 1h 20m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554872&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554872
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 18:58
Start Date: 19/Feb/21 18:58
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r579407661



##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,27 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream.toInputStream()

Review comment:
   Ok, I see it now. I needed to run the `javadoc:javadoc` goal. I haven't 
used maven default goals before, so I was just running `package` and `test` 
manually. 
   It should be fixed now. Sorry for the confusion.





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554872)
Time Spent: 1h 20m  (was: 1h 10m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554866&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554866
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 18:39
Start Date: 19/Feb/21 18:39
Worklog Time Spent: 10m 
  Work Description: XenoAmess commented on a change in pull request #206:
URL: https://github.com/apache/commons-io/pull/206#discussion_r579396064



##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,27 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream.toInputStream()

Review comment:
   @see org.apache.commons.io.output.ByteArrayOutputStream#toInputStream()

##
File path: 
src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java
##
@@ -272,4 +274,27 @@ public void writeTo(final OutputStream outputStream) 
throws IOException {
 }
 }
 }
+
+/**
+ * Gets the current contents of this byte stream as an {@link InputStream}.
+ * If the data for this output stream has been retained in memory, the
+ * returned stream is backed by buffers of {@code this} stream,
+ * avoiding memory allocation and copy, thus saving space and time.
+ * Otherwise, the returned stream will be one that is created from the data
+ * that has been committed to disk.
+ *
+ * @return the current contents of this output stream.
+ * @see org.apache.commons.io.output.ByteArrayOutputStream.toInputStream()

Review comment:
   ```@see 
org.apache.commons.io.output.ByteArrayOutputStream#toInputStream()```





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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554866)
Time Spent: 1h 10m  (was: 1h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554861&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554861
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 18:22
Start Date: 19/Feb/21 18:22
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782252971


   @garydgregory I just ran `mvn package` again and it was successful. I don't 
see any errors.
   I also tried running `mvn test` just to make sure, and no errors either.
   What errors do you see?



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554861)
Time Spent: 1h  (was: 50m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554846&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554846
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 17:48
Start Date: 19/Feb/21 17:48
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782232501


   > @garydgregory Yes, I see that. I don't think these failures have anything 
to do with my changes. Looks like some type of misconfiguration with the build. 
I see errors like this:
   > 
   > ```
   > java.lang.IllegalAccessError: class 
org.apache.commons.io.input.BufferedFileChannelInputStream (in unnamed module 
@0x685f4c2e) cannot access class sun.nio.ch.DirectBuffer (in module java.base) 
because module java.base does not export sun.nio.ch to unnamed module 
@0x685f4c2e
   > ```
   > 
   > I did not touch that class. I only added one new method to 
`DeferredFileOutputStream` so it should not affect any other tests.
   > 
   > When I build locally everything works fine.
   
   Just run the default maven goal and you will see Javadoc errors. 



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554846)
Time Spent: 50m  (was: 40m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554845&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554845
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 17:41
Start Date: 19/Feb/21 17:41
Worklog Time Spent: 10m 
  Work Description: jmark109 commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782228140


   @garydgregory Yes, I see that. I don't think these failures have anything to 
do with my changes. Looks like some type of misconfiguration with the build. I 
see errors like this:
   ```
   java.lang.IllegalAccessError: class 
org.apache.commons.io.input.BufferedFileChannelInputStream (in unnamed module 
@0x685f4c2e) cannot access class sun.nio.ch.DirectBuffer (in module java.base) 
because module java.base does not export sun.nio.ch to unnamed module 
@0x685f4c2e
   ```
   I did not touch that class. I only added one new method to 
`DeferredFileOutputStream` so it should not affect any other tests.
   
   When I build locally everything works fine.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554845)
Time Spent: 40m  (was: 0.5h)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554841&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554841
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 17:36
Start Date: 19/Feb/21 17:36
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782225559


   @jmark109 
   This PR causes build failures.
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554841)
Time Spent: 0.5h  (was: 20m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554839&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554839
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 17:35
Start Date: 19/Feb/21 17:35
Worklog Time Spent: 10m 
  Work Description: coveralls commented on pull request #206:
URL: https://github.com/apache/commons-io/pull/206#issuecomment-782224839


   
   [![Coverage 
Status](https://coveralls.io/builds/37280798/badge)](https://coveralls.io/builds/37280798)
   
   Coverage decreased (-0.1%) to 89.254% when pulling 
**6f50f16c23702947c9d928370ab4f2e585ecfd38 on 
jmark109:IO-651_DeferredFileOutputStream_getInputStream** into 
**c54bf688e94b550c3ccd4c0789e0b3e00cf1d0ea on apache:master**.
   



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554839)
Time Spent: 20m  (was: 10m)

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (IO-651) Provide method to retrieve data from DeferredFileOutputStream as InputStream

2021-02-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-651?focusedWorklogId=554813&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-554813
 ]

ASF GitHub Bot logged work on IO-651:
-

Author: ASF GitHub Bot
Created on: 19/Feb/21 16:39
Start Date: 19/Feb/21 16:39
Worklog Time Spent: 10m 
  Work Description: jmark109 opened a new pull request #206:
URL: https://github.com/apache/commons-io/pull/206


   Add DeferredFileOutputStream.getInputStream() for efficient retrieval of 
OutputSteam data.
   
   Fixes IO-651.



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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 554813)
Remaining Estimate: 0h
Time Spent: 10m

> Provide method to retrieve data from DeferredFileOutputStream as InputStream
> 
>
> Key: IO-651
> URL: https://issues.apache.org/jira/browse/IO-651
> Project: Commons IO
>  Issue Type: Improvement
>  Components: Streams/Writers
>Affects Versions: 2.6
>Reporter: John Mark
>Priority: Major
>  Labels: easyfix, performance, pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> It would be very helpful to have to {{toInputStream()}} method on the 
> {{DeferredFileOutputStream}} class. Besides for convenience, it would allow 
> for improved efficiency since in the case of in-memory data the byte buffer 
> would not need to be copied (as opposed to the current {{getData()}} method). 
> The implementation is pretty simple and can be something like the following 
> (based on the current {{writeTo(OutputStream)}} method):
> {code:java}
> public InputStream toInputStream() throws IOException {
> if (!closed) {
> throw new IOException("Stream not closed");
> }
> if (isInMemory()) {
> return memoryOutputStream.toInputStream();
> } else {
> return Files.newInputStream(outputFile.toPath());
> }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)