commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miroslav Pokorny (Created) (JIRA)" <>
Subject [jira] [Created] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.
Date Tue, 20 Mar 2012 04:49:43 GMT
RAM FileSystem resize throws ArrayOOBE when shrinking in size.

                 Key: VFS-406
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 2.0
            Reporter: Miroslav Pokorny

Im targetting 2.0 as it is the official download.

The fix is quite simple.

FILE: RamFileObject

    void resize(int newSize)
        int size = this.size();
        byte[] newBuf = new byte[newSize];
        System.arraycopy(this.buffer, 0, newBuf, 0, size);
        this.buffer = newBuf;
// when shrinking size > newSize thus an AOOBE will be thrown.

    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 message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message