[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17135656#comment-17135656 ] chenshuming commented on VFS-396: - I can't see this problem in my test. The RamFileSystem can detect the file's size become too large and throw Exception. I notice this issue's description says : ``` there is a check if (fs.size() + newSize - this.size() > maxSize) For every resize check, fs.size() would be 0 ``` In current VFS project, the check is "if (fs.size() + newSize - this.size() > maxSize)", And I can see "fs.size()" is the file system current size instead of 0 . So I think this check work and maybe this issue should close. > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar >Priority: Major > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13559330#comment-13559330 ] Gary Gregory commented on VFS-396: -- Feel free to patch :) > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13559331#comment-13559331 ] Gary Gregory commented on VFS-396: -- Feel free to patch :) > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13554892#comment-13554892 ] Thomas Neidhart commented on VFS-396: - I just realized that there is a potential glitch that could/should be improved: the write method of the RAMFileOutputStream will only throw an IOException, while the close may throw a (delayed) FileSystemException. As the OutputStream as received by FileContent.getOutputStream will be wrapped by another, buffered stream, a user may either receive the actual exception when calling flush or close and it will be an FileSystemException instead of the IOException if the content is immediately written by write. > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13553887#comment-13553887 ] Thomas Neidhart commented on VFS-396: - I did a small test myself but I can not confirm the observation: {noformat} FileSystemOptions largeSized = new FileSystemOptions(); public void setup() { RamFileSystemConfigBuilder.getInstance().setMaxSize(largeSized, 500); } ... @Test public void testChunkFileWrite() throws Exception { // Default FS final FileObject fo1 = manager.resolveFile("ram:/fo1", largeSized); fo1.createFile(); try { final OutputStream os = fo1.getContent().getOutputStream(); // write file in chunks of 8kbytes (total 10.000.000 bytes) for (int i = 0; i < 1220; i++) { os.write(new byte[8192]); } os.close(); fail("It shouldn't save such a big file"); } catch (final FileSystemException e) { // Expected } } {noformat} The test successfully detects that the file will be too large, see also the debug output of the check in RamFileObject#resize(): {noformat} afs.size()=0 newSize=8192 this.size()=0 afs.size()=8192 newSize=16384 this.size()=8192 afs.size()=16384 newSize=24576 this.size()=16384 afs.size()=24576 newSize=32768 this.size()=24576 afs.size()=32768 newSize=40960 this.size()=32768 afs.size()=40960 newSize=49152 this.size()=40960 ... {noformat} > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit.
[ https://issues.apache.org/jira/browse/VFS-396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13158036#comment-13158036 ] Gary D. Gregory commented on VFS-396: - Can you provide a patch with a unit test please? -- Posted from Bugbox for iPhone > RAM FileSystem allows the file system size to exceed the max size limit. > > > Key: VFS-396 > URL: https://issues.apache.org/jira/browse/VFS-396 > Project: Commons VFS > Issue Type: Bug >Affects Versions: 2.0 > Environment: All >Reporter: Rupesh Kumar > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When a new file is created in the RAM file system, and content is written to > its outputstream, there is a check in place for ensuring that file system > size does not exceed the max limit set. But that check is wrong. > In RamFileOutputStream.write(), you calculate the size, newsize and call > file.resize(newSize) > And in the RamFileObject.resize(), there is a check > if (fs.size() + newSize - this.size() > maxSize) > { > throw new IOException("FileSystem capacity (" + maxSize > + ") exceeded."); > } > This check is wrong. > Consider this case of a new file system where the file system size is set to > 5 MB and I am trying to create a file of 10 MB in the RAM file system. the > file is being written in the chunk of 8 kb. For every resize check, fs.size() > would be 0 and (newsize - this.size()) would be 8 kb and therefore the check > never passes. > It could have been correct if the "old size" was locked down to the size > that was registered with the file system but the old size (this.size()) keeps > changing at every write. Thus the difference in newSize and this.size() would > always be the chunk size (typically 8 kb) and therefore no exception would be > thrown ever. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira