[jira] [Created] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
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


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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory resolved VFS-406.
---------------------------------

    Resolution: Fixed

Committed revision 1339211.
               

> 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Reopened] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory reopened VFS-406:
---------------------------------


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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ 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: Committed revision 1339211.)
   

> 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

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

Gary D. Gregory commented on VFS-406:
-------------------------------------

Looking at trunk now, I am not sure how this can happen because the method is only used in two contexts: a RAM output stream, which only grows, never shrinks. The other context is the RAM random access file, which does not have a setLength method to shrink a file.

Can you provide test case that shows this happening?
               

> 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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (VFS-406) RAM FileSystem resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Miroslav Pokorny updated VFS-406:
---------------------------------

    Attachment: ApacheVfsRamShrinkBugDemoTest.java

Hi Gary

Your commentary is correct, it is not possible to shrink a RAM file using
the unmodified API. I however needed to add the ability to shrink a RAM
file so i simply made RamFileObject.resize(int] public. After this i was
able to call it. I have demonstrated a simple TestCase below which uses
reflection to call the resize method, where upon an AIOOBE will be thrown.
My fix makes the resize or shrink work. At some future time perhaps you
might wish to make shrinking part of the public API and with this it will
work.





--
mP

               

> 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
>         Attachments: ApacheVfsRamShrinkBugDemoTest.java
>
>   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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (VFS-406) [RAM] resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory updated VFS-406:
--------------------------------

    Summary: [RAM] resize throws ArrayOOBE when shrinking in size.  (was: RAM FileSystem resize throws ArrayOOBE when shrinking in size.)
   

> [RAM] 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
>         Attachments: ApacheVfsRamShrinkBugDemoTest.java
>
>   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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (VFS-406) [RAM] resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory resolved VFS-406.
---------------------------------

    Resolution: Fixed
      Assignee: Gary D. Gregory

Committed revision 1339834.
               

> [RAM] 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
>            Assignee: Gary D. Gregory
>         Attachments: ApacheVfsRamShrinkBugDemoTest.java
>
>   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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (VFS-406) [RAM] resize throws ArrayOOBE when shrinking in size.

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/VFS-406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary D. Gregory updated VFS-406:
--------------------------------

    Fix Version/s: 2.1
   

> [RAM] 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
>            Assignee: Gary D. Gregory
>             Fix For: 2.1
>
>         Attachments: ApacheVfsRamShrinkBugDemoTest.java
>
>   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