[JBoss JIRA] Updated: (NETTY-254) Do not do lazy-initialization in dynamic buffer

Trustin Lee (JIRA) jira-events at lists.jboss.org
Thu Nov 19 03:39:29 EST 2009


     [ https://jira.jboss.org/jira/browse/NETTY-254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee updated NETTY-254:
------------------------------

        Summary: Do not do lazy-initialization in dynamic buffer  (was: ChannelBuffer.setIndex() fails with a dynamic buffer )
    Description: 
Any newly created dynamic buffer has 0 capacity, and a new space is allocated on demand (i.e. lazily).  However, this causes a lot of confusion to users.  For example:  The following code fails with IndexOutOfBoundsException:

    ChannelBuffer buf = ChannelBufers.dynamicBuffer(1500);
    buf.setIndex(0, 1000);

where it should not fail because user asked for at least 1600 bytes.  There's not much gain from the lazy initialization - it just gives user confusion, hence the internal buffer should be initialized immediately.

  was:
The following code fails with IndexOutOfBoundsException:

ChannelBuffer buf = ChannelBufers.dynamicBuffer(1500);
buf.setIndex(0, 1000);

where it should not fail.

I'm not sure setIndex() should increase the capacity yet, but at least it should not fail when there's no need for capacity increment.



> Do not do lazy-initialization in dynamic buffer
> -----------------------------------------------
>
>                 Key: NETTY-254
>                 URL: https://jira.jboss.org/jira/browse/NETTY-254
>             Project: Netty
>          Issue Type: Bug
>          Components: Buffer
>            Reporter: Trustin Lee
>            Assignee: Trustin Lee
>             Fix For: 3.2.0.ALPHA2
>
>
> Any newly created dynamic buffer has 0 capacity, and a new space is allocated on demand (i.e. lazily).  However, this causes a lot of confusion to users.  For example:  The following code fails with IndexOutOfBoundsException:
>     ChannelBuffer buf = ChannelBufers.dynamicBuffer(1500);
>     buf.setIndex(0, 1000);
> where it should not fail because user asked for at least 1600 bytes.  There's not much gain from the lazy initialization - it just gives user confusion, hence the internal buffer should be initialized immediately.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the netty-dev mailing list