You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/12/19 21:08:00 UTC

[jira] [Work logged] (COMPRESS-499) SeekableInMemoryByteChannel sets position incorrectly if > size

     [ https://issues.apache.org/jira/browse/COMPRESS-499?focusedWorklogId=361487&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-361487 ]

ASF GitHub Bot logged work on COMPRESS-499:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Dec/19 21:07
            Start Date: 19/Dec/19 21:07
    Worklog Time Spent: 10m 
      Work Description: trejkaz commented on pull request #88: COMPRESS-499: Fixed edge case in `SeekableInMemoryByteChannel#truncate`
URL: https://github.com/apache/commons-compress/pull/88
 
 
   Initial proposed patch.
   
   It's unknown whether the bug has any actual impact because the edge case is very specific and honestly is a misuse-case in my book.
   
   Test cases cover what we deemed to be all possible size vs new size vs position relationships.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 361487)
    Remaining Estimate: 0h
            Time Spent: 10m

> SeekableInMemoryByteChannel sets position incorrectly if > size
> ---------------------------------------------------------------
>
>                 Key: COMPRESS-499
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-499
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.19
>            Reporter: Trejkaz
>            Priority: Minor
>         Attachments: Screen Shot 2019-12-19 at 12.37.18 pm.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Something we noticed in passing when attempting to use this class as a reference for implementing a new channel class of our own:
> https://github.com/apache/commons-compress/blob/c03704d773dfa0dfc5b2e53b4c198a95d0213ca0/src/main/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannel.java#L102
> If the size of the file/channel is 10 and I call truncate(12), the current behaviour is to set the position back to 10.
> The docs of SeekableByteChannel, however, require that this not be done:
> https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/channels/SeekableByteChannel.html#truncate(long)
> {quote}
> If the given size is greater than or equal to the current size then the entity is not modified. In either case, if the current position is greater than the given size then *it is set to that size*.
> {quote}
> I'm not sure whether this bug means there is a bug in the compression library proper, because anyone using a channel sensibly would not be setting the position past the length anyway, but I thought I would raise the issue regardless, in case that were not the case.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)