[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-11-25 Thread L (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17449396#comment-17449396
 ] 

L commented on VFS-807:
---

[~ggregory] : yes, it can be closed.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-11-25 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17449284#comment-17449284
 ] 

Gary D. Gregory commented on VFS-807:
-

[~klv_m72] 

Can this ticket be closed?

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-06 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394809#comment-17394809
 ] 

Gary D. Gregory commented on VFS-807:
-

[~klv_m72]

My mistake. Fixed in git master.

TY!

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-06 Thread L (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394698#comment-17394698
 ] 

L commented on VFS-807:
---

[~ggregory]

I am using Windows 10 and jdk 8 as well.

The thing is: you did not correctly pushed my test changes, namely, 
ProviderWriteAppendTests.java:

Mine code:

 
{code:java}
try (OutputStream os = file.getContent().getOutputStream(true)) {
    os.write(content1.getBytes(StandardCharsets.UTF_8));
} 
{code}
 

Code in master:

 
{code:java}
try (FileContent fileContent = file.getContent(); OutputStream os = 
fileContent.getOutputStream()) {
    os.write(content1.getBytes(StandardCharsets.UTF_8));
} 
{code}
Your code does not perform "append". It must be 
fileContent.getOutputStream(*true*)

 

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-06 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394676#comment-17394676
 ] 

Gary D. Gregory commented on VFS-807:
-

Also note that the change to use Files NIO to create the input stream is not in.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-06 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394675#comment-17394675
 ] 

Gary D. Gregory commented on VFS-807:
-

That was a typo on my end, sorry, the tests passed without the change to main. 
What OS/JRE are you on?

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-05 Thread L (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394536#comment-17394536
 ] 

L commented on VFS-807:
---

[~ggregory]: thanks for pushing the tests.

As for "the tests pass without the change to {{LocalFile}} ": of course they 
pass now since you *have changed* LocalFile (the same fix as Commons IO) 
finally fixing the problem. My comment with diff file was posted several days 
ago when LocalFile in master was still buggy.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-05 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17394206#comment-17394206
 ] 

Gary D. Gregory commented on VFS-807:
-

i [~klv_m72]

I pushed your tests and the same fix as Commons IO BUT for me, on Windows 10 
and Java 8, the tests pass without the change to {{LocalFile}} but you seem to 
report otherwise so this might be OS and Java version dependent.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-04 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17393510#comment-17393510
 ] 

Gary D. Gregory commented on VFS-807:
-

Hi [~klv_m72]

Please provide your diff as a PR on GitHub such that the GitHub Actions builds 
kick in for all of the OSs and JDKs we check.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-04 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17393448#comment-17393448
 ] 

Gary D. Gregory commented on VFS-807:
-

Hi [~klv_m72]

Please don't delete comments ("// TODO Reuse Apache Commons IO") in your patch 
because that's where the implementation will be coming from as soon as Apache 
Commons IO is released, you can see git master for Commons IO which I just 
updated. My plan is to release Commons IO and then to reuse its 
PathUtils.newOutputStream() method from here.

 

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-08-02 Thread L (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17391433#comment-17391433
 ] 

L commented on VFS-807:
---

I have added some tests verifying the bug.  I did not succeed creating a PR.

The attached file (vfs-807.diff) contains the test changes and the correct fix 
for this issue.
 # ProviderWriteTests.testOverwriteContent() fails with 2.9.0 and works in the 
latest master.
 # ProviderWriteAppendTests.testAppendToNonExsiting() fails with 2.9.0 and in 
the latest master.
 # They both succeed with the changes to LocalFile done in the patch.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Fix For: 2.9.1
>
> Attachments: TestJdkWriteFile.java, vfs-807.diff
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-07-30 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390771#comment-17390771
 ] 

Gary D. Gregory commented on VFS-807:
-

Hi [~klv_m72]

Please try git master. I did not try your Java app as it is not runnable as a 
unit test. If you want to provide something we can use, feel free to provide a 
PR on GitHub for a unit test ;)

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Attachments: TestJdkWriteFile.java
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-07-30 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390642#comment-17390642
 ] 

Gary D. Gregory commented on VFS-807:
-

The problem is also like IO-744

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Attachments: TestJdkWriteFile.java
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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


[jira] [Commented] (VFS-807) LocalFile migration to NIO is not done correctly

2021-07-30 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390484#comment-17390484
 ] 

Gary D. Gregory commented on VFS-807:
-

[~klv_m72]

Thank you for your report. 

Feel free to provide a PR on GitHub.

> LocalFile migration to NIO is not done correctly
> 
>
> Key: VFS-807
> URL: https://issues.apache.org/jira/browse/VFS-807
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: L
>Priority: Blocker
> Attachments: TestJdkWriteFile.java
>
>
> According to release notes 
> ([https://archive.apache.org/dist/commons/vfs/RELEASE-NOTES.txt),] version 
> 2.9.0 includes the following change:
> Replace construction of FileInputStream and FileOutputStream objects with 
> Files NIO APIs. #164. Thanks to Arturo Bernal.
> Strangely, it was not completed: LocalFlie.java has the following now, even 
> in master: 
> {code:java}
> /**
>  * Creates an input stream to read the content from.
>  */
>  @Override
>  protected InputStream doGetInputStream(final int bufferSize) throws 
> Exception {
> return new FileInputStream(file);
>  } 
> {code}
>  
> But what is worse, doGetOutputStream is *completely* broken: 
> {code:java}
> /**
>  * Creates an output stream to write the file content to.
>  */
> @Override
> protected OutputStream doGetOutputStream(final boolean bAppend) throws 
> Exception {
> return Files.newOutputStream(file.toPath(), bAppend ? 
> StandardOpenOption.APPEND : StandardOpenOption.CREATE);
> } {code}
>  
> This can be demonstrated with a small java program, see attachment. The 
> program just tries to write to a local file (into the same directory), using 
> different ways to do it:
>  # Java IO, how it was done before VFS 2.9.0
>  # Java NIO the way VFS 2.9.0 does it
>  # Java NIO the way it must be done
> What is important, the program also verifies the result.
> VFS 2.9.0 fails in 2 cases: 
>  # When the file does not exist and append must be performed:  
> java.nio.file.NoSuchFileException is thrown in this case.
>  # When the file exists and no append must be performed: the file is not 
> truncated, so whatever is written overwrites the beginning of the file, 
> keeping the rest.
>  
>  
>  



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