commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Goncalves (JIRA)" <j...@apache.org>
Subject [jira] Commented: (FILEUPLOAD-144) Parameters values are lost
Date Tue, 18 Sep 2007 08:16:44 GMT

    [ https://issues.apache.org/jira/browse/FILEUPLOAD-144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12528296
] 

Laurent Goncalves commented on FILEUPLOAD-144:
----------------------------------------------

After more unit testing, I've found another bug with the pad attribute used in the input.read(...)
method.
The pad is updated by the findSeparator() method with a maximum value given by keepRegion
attribute.
The good approach is to use the tail attribute in the input.read(...) method and update it
in the loop.
The final code of the makeAvailable() method must be :

        private int makeAvailable() throws IOException {
            if (pos != -1) {
                return 0;
            }

            // Move the data to the beginning of the buffer.
            total += tail - head - pad;
            System.arraycopy(buffer, tail - pad, buffer, 0, pad);

            // Refill buffer with new data.
            head = 0;
            tail = pad;
            int bytesRead = 0;
            do
            {
               bytesRead = input.read(buffer, tail, bufSize - tail);
               if (bytesRead != -1)
               {
                  notifier.noteBytesRead(bytesRead);
                  tail += bytesRead;
                  findSeparator();
               }
               // separator was not found, it denotes a miss in the buffer
               // force other buffer's reading until end of stream or first separator found
            }
            while (pos == -1 && bytesRead >= 0);
            
            return available();
        }

> Parameters values are lost
> --------------------------
>
>                 Key: FILEUPLOAD-144
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-144
>             Project: Commons FileUpload
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: JBoss 4 / XP / Servlet / both Firefox and IE
>            Reporter: Vera Mickael
>            Priority: Critical
>         Attachments: test.fileupload.zip
>
>
> When parsing a request with the streaming API, some parameters loose their values. I
can easily reproduce the problem when a lot of parameters are submitted (about 400 in a table).
My code is as follows :
>             final FileItemStream itemStream = anItemIterator.next();
>             final String fieldName = itemStream.getFieldName();
>             System.out.print("Field " + fieldName);
>             InputStream stream = itemStream.openStream();
>             final String value = Streams.asString(stream, "UTF-8");
> The last statement sometimes returns a value and sometimes not. Sometimes I can retreive
all parameters, sometimes I loose 3 or 4 parameters. I reproduced the problem on two computers.
I have a very small application with a servlet of 69 lines that reproduces the problem, the
project is attached to this issue. 

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


Mime
View raw message