You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (JIRA)" <ji...@apache.org> on 2012/05/16 17:07:02 UTC
[jira] [Updated] (VFS-406) RAM FileSystem resize throws ArrayOOBE
when shrinking in size.
[ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory updated VFS-406:
--------------------------------
Comment: was deleted
(was: Oops, resolved wrong issue.)
> RAM FileSystem resize throws ArrayOOBE when shrinking in size.
> --------------------------------------------------------------
>
> Key: VFS-406
> URL: https://issues.apache.org/jira/browse/VFS-406
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Reporter: Miroslav Pokorny
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> Im targetting 2.0 as it is the official download.
> The fix is quite simple.
> FILE: RamFileObject
> ORIGINAL
> void resize(int newSize)
> {
> int size = this.size();
> byte[] newBuf = new byte[newSize];
> System.arraycopy(this.buffer, 0, newBuf, 0, size);
> this.buffer = newBuf;
> updateLastModified();
> }
> // when shrinking size > newSize thus an AOOBE will be thrown.
> FIXED
> void resize(final int newSize) {
> final int size = this.size();
> final byte[] newBuf = new byte[newSize];
> // HACK fixed error which prevented resizing to a small buffer.
> System.arraycopy(this.buffer, 0, newBuf, 0, Math.min(newSize, size));
> this.buffer = newBuf;
> this.updateLastModified();
> }
--
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