Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 72C20EE3D for ; Tue, 22 Jan 2013 03:06:20 +0000 (UTC) Received: (qmail 59534 invoked by uid 500); 22 Jan 2013 03:06:19 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 58761 invoked by uid 500); 22 Jan 2013 03:06:17 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 58339 invoked by uid 99); 22 Jan 2013 03:06:15 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jan 2013 03:06:15 +0000 Date: Tue, 22 Jan 2013 03:06:15 +0000 (UTC) From: "Gary Gregory (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (VFS-396) RAM FileSystem allows the file system size to exceed the max size limit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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