[ 
https://issues.apache.org/jira/browse/FILEUPLOAD-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12656563#action_12656563
 ] 

Jochen Wiedmann commented on FILEUPLOAD-170:
--------------------------------------------

I'll show you the code. (See below.) Assuming that there is no bug in the JVM 
(for which commons-fileupload cannot take responsibility), note that:

- The variable "items" is initialized at the beginning. It is never changed.
  It can never be null.
- There is only one "return" statement, which returns "items". Hence it
  is impossible that null is returned.
- The elements added to "items" are stored in the variable "fileItem".
- These elements can also never be null: Otherwise, you'd get a 
NullPointerException
  when Streams.copy is invoked.

Please contact the Struts users mailing list for help. This is a bug tracker, 
not a support forum.




    public List /* FileItem */ parseRequest(RequestContext ctx)
            throws FileUploadException {
        try {
            FileItemIterator iter = getItemIterator(ctx);
            List items = new ArrayList();
            FileItemFactory fac = getFileItemFactory();
            if (fac == null) {
                throw new NullPointerException(
                    "No FileItemFactory has been set.");
            }
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                FileItem fileItem = fac.createItem(item.getFieldName(),
                        item.getContentType(), item.isFormField(),
                        item.getName());
                try {
                    Streams.copy(item.openStream(), fileItem.getOutputStream(),
                            true);
                } catch (FileUploadIOException e) {
                    throw (FileUploadException) e.getCause();
                } catch (IOException e) {
                    throw new IOFileUploadException(
                            "Processing of " + MULTIPART_FORM_DATA
                            + " request failed. " + e.getMessage(), e);
                }
                if (fileItem instanceof FileItemHeadersSupport) {
                    final FileItemHeaders fih = item.getHeaders();
                    ((FileItemHeadersSupport) fileItem).setHeaders(fih);
                }
                items.add(fileItem);
            }
            return items;
        } catch (FileUploadIOException e) {
            throw (FileUploadException) e.getCause();
        } catch (IOException e) {
            throw new FileUploadException(e.getMessage(), e);
        }
    }


> problem in parseRequest method of 
> ----------------------------------
>
>                 Key: FILEUPLOAD-170
>                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-170
>             Project: Commons FileUpload
>          Issue Type: Bug
>         Environment: OS: fedora7
> IDE:Netbeans
>            Reporter: vaishali dolas
>
> I'm facing problem to build progressbar while file uploading
> the code snippet is here
> // Create a factory for disk-based file items
> FileItemFactory factory = new DiskFileItemFactory();
> // Create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(factory);
> // Parse the request
> List   items = upload.parseRequest(request);
> In items i'm always getting null

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

Reply via email to