commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stepan Koltsov (JIRA)" <>
Subject [jira] Commented: (FILEUPLOAD-159) MultipartStream.position method
Date Sun, 18 Jan 2009 02:28:59 GMT


Stepan Koltsov commented on FILEUPLOAD-159:

Seems like it is a bug.

I think "int read()" is not really needed (because, most users call "read(byte[], ...)" methods).

I propose refactoring of read() method to

int read() {
    byte[] buffer = new byte[1];
    int count = read(buffer);
    if (count < 0) return -1;
    if (count == 0) throw new Error(); // read(byte[]) method is not allowed to return 0
    return buffer[0] & 0xFF;

It is a bit slower, but avoids code duplication between read methods.

> MultipartStream.position method
> -------------------------------
>                 Key: FILEUPLOAD-159
>                 URL:
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: Nightly Builds
>            Reporter: Stepan Koltsov
>         Attachments: commons-fileupload-position-2008-05-28.diff
> Attached patch adds MultipartStream.position() method, that returns current position
withing InputStream plus offset in buffer. I. e. current parser position.
> Use case is parsing multipart that is stored as file on disk: at first run we read that
file and saving part offsets (by calling position() methods). Then we can randomly access
all parts without storing parts as separate files on disk.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message