Author: markt
Date: Fri Mar 15 11:10:27 2013
New Revision: 1456895

URL: http://svn.apache.org/r1456895
Log:
Merge updates from Commons FileUpload to r1453817

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/   (props changed)
    tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/package-info.java
    tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/package-info.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/package-info.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/LimitedInputStream.java
    
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/package-info.java

Propchange: tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/
------------------------------------------------------------------------------
  Merged 
/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload:r1453286-1453817

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 
(original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 
Fri Mar 15 11:10:27 2013
@@ -87,16 +87,13 @@ public abstract class FileUploadBase {
         return false;
     }
 
-
     // ----------------------------------------------------- Manifest constants
 
-
     /**
      * HTTP content type header name.
      */
     public static final String CONTENT_TYPE = "Content-type";
 
-
     /**
      * HTTP content disposition header name.
      */
@@ -107,40 +104,33 @@ public abstract class FileUploadBase {
      */
     public static final String CONTENT_LENGTH = "Content-length";
 
-
     /**
      * Content-disposition value for form data.
      */
     public static final String FORM_DATA = "form-data";
 
-
     /**
      * Content-disposition value for file attachment.
      */
     public static final String ATTACHMENT = "attachment";
 
-
     /**
      * Part of HTTP content type header.
      */
     public static final String MULTIPART = "multipart/";
 
-
     /**
      * HTTP content type header for multipart forms.
      */
     public static final String MULTIPART_FORM_DATA = "multipart/form-data";
 
-
     /**
      * HTTP content type header for multiple uploads.
      */
     public static final String MULTIPART_MIXED = "multipart/mixed";
 
-
     // ----------------------------------------------------------- Data members
 
-
     /**
      * The maximum size permitted for the complete request, as opposed to
      * {@link #fileSizeMax}. A value of -1 indicates no maximum.
@@ -165,7 +155,6 @@ public abstract class FileUploadBase {
 
     // ----------------------------------------------------- Property accessors
 
-
     /**
      * Returns the factory class used when creating file items.
      *
@@ -173,7 +162,6 @@ public abstract class FileUploadBase {
      */
     public abstract FileItemFactory getFileItemFactory();
 
-
     /**
      * Sets the factory class to use when creating file items.
      *
@@ -181,7 +169,6 @@ public abstract class FileUploadBase {
      */
     public abstract void setFileItemFactory(FileItemFactory factory);
 
-
     /**
      * Returns the maximum allowed size of a complete request, as opposed
      * to {@link #getFileSizeMax()}.
@@ -196,7 +183,6 @@ public abstract class FileUploadBase {
         return sizeMax;
     }
 
-
     /**
      * Sets the maximum allowed size of a complete request, as opposed
      * to {@link #setFileSizeMax(long)}.
@@ -245,7 +231,6 @@ public abstract class FileUploadBase {
         return headerEncoding;
     }
 
-
     /**
      * Specifies the character encoding to be used when reading the headers of
      * individual part. When not specified, or <code>null</code>, the request
@@ -258,10 +243,8 @@ public abstract class FileUploadBase {
         headerEncoding = encoding;
     }
 
-
     // --------------------------------------------------------- Public methods
 
-
     /**
      * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt";>RFC 1867</a>
      * compliant <code>multipart/form-data</code> stream.
@@ -348,10 +331,8 @@ public abstract class FileUploadBase {
         }
     }
 
-
     // ------------------------------------------------------ Protected methods
 
-
     /**
      * Retrieves the boundary from the <code>Content-type</code> header.
      *
@@ -376,7 +357,6 @@ public abstract class FileUploadBase {
         return boundary;
     }
 
-
     /**
      * Retrieves the file name from the <code>Content-disposition</code>
      * header.
@@ -420,7 +400,6 @@ public abstract class FileUploadBase {
         return fileName;
     }
 
-
     /**
      * Retrieves the field name from the <code>Content-disposition</code>
      * header.
@@ -553,34 +532,50 @@ public abstract class FileUploadBase {
      * {@link FileUploadBase#getItemIterator(RequestContext)}.
      */
     private class FileItemIteratorImpl implements FileItemIterator {
+
         /**
          * Default implementation of {@link FileItemStream}.
          */
         class FileItemStreamImpl implements FileItemStream {
-            /** The file items content type.
+
+            /**
+             * The file items content type.
              */
             private final String contentType;
-            /** The file items field name.
+
+            /**
+             * The file items field name.
              */
             private final String fieldName;
-            /** The file items file name.
+
+            /**
+             * The file items file name.
              */
             private final String name;
-            /** Whether the file item is a form field.
+
+            /**
+             * Whether the file item is a form field.
              */
             private final boolean formField;
-            /** The file items input stream.
+
+            /**
+             * The file items input stream.
              */
             private final InputStream stream;
-            /** Whether the file item was already opened.
+
+            /**
+             * Whether the file item was already opened.
              */
             private boolean opened;
-            /** The headers, if any.
+
+            /**
+             * The headers, if any.
              */
             private FileItemHeaders headers;
 
             /**
              * Creates a new instance.
+             *
              * @param pName The items file name, or null.
              * @param pFieldName The items field name.
              * @param pContentType The items content type, or null.
@@ -630,6 +625,7 @@ public abstract class FileUploadBase {
 
             /**
              * Returns the items content type, or null.
+             *
              * @return Content type, if known, or null.
              */
             @Override
@@ -639,6 +635,7 @@ public abstract class FileUploadBase {
 
             /**
              * Returns the items field name.
+             *
              * @return Field name.
              */
             @Override
@@ -648,6 +645,7 @@ public abstract class FileUploadBase {
 
             /**
              * Returns the items file name.
+             *
              * @return File name, if known, or null.
              * @throws InvalidFileNameException The file name contains a NUL 
character,
              *   which might be an indicator of a security attack. If you 
intend to
@@ -661,6 +659,7 @@ public abstract class FileUploadBase {
 
             /**
              * Returns, whether this is a form field.
+             *
              * @return True, if the item is a form field,
              *   otherwise false.
              */
@@ -672,6 +671,7 @@ public abstract class FileUploadBase {
             /**
              * Returns an input stream, which may be used to
              * read the items contents.
+             *
              * @return Opened input stream.
              * @throws IOException An I/O error occurred.
              */
@@ -689,6 +689,7 @@ public abstract class FileUploadBase {
 
             /**
              * Closes the file item.
+             *
              * @throws IOException An I/O error occurred.
              */
             void close() throws IOException {
@@ -697,6 +698,7 @@ public abstract class FileUploadBase {
 
             /**
              * Returns the file item headers.
+             *
              * @return The items header object
              */
             @Override
@@ -706,43 +708,52 @@ public abstract class FileUploadBase {
 
             /**
              * Sets the file item headers.
+             *
              * @param pHeaders The items header object
              */
             @Override
             public void setHeaders(FileItemHeaders pHeaders) {
                 headers = pHeaders;
             }
+
         }
 
         /**
          * The multi part stream to process.
          */
         private final MultipartStream multi;
+
         /**
          * The notifier, which used for triggering the
          * {@link ProgressListener}.
          */
         private final MultipartStream.ProgressNotifier notifier;
+
         /**
          * The boundary, which separates the various parts.
          */
         private final byte[] boundary;
+
         /**
          * The item, which we currently process.
          */
         private FileItemStreamImpl currentItem;
+
         /**
          * The current items field name.
          */
         private String currentFieldName;
+
         /**
          * Whether we are currently skipping the preamble.
          */
         private boolean skipPreamble;
+
         /**
          * Whether the current item may still be read.
          */
         private boolean itemValid;
+
         /**
          * Whether we have seen the end of the file.
          */
@@ -750,6 +761,7 @@ public abstract class FileUploadBase {
 
         /**
          * Creates a new instance.
+         *
          * @param ctx The request context.
          * @throws FileUploadException An error occurred while
          *   parsing the request.
@@ -817,7 +829,8 @@ public abstract class FileUploadBase {
         }
 
         /**
-         * Called for finding the nex item, if any.
+         * Called for finding the next item, if any.
+         *
          * @return True, if an next item was found, otherwise false.
          * @throws IOException An I/O error occurred.
          */
@@ -900,6 +913,7 @@ public abstract class FileUploadBase {
         /**
          * Returns, whether another instance of {@link FileItemStream}
          * is available.
+         *
          * @throws FileUploadException Parsing or processing the
          *   file item failed.
          * @throws IOException Reading the file item failed.
@@ -919,6 +933,7 @@ public abstract class FileUploadBase {
 
         /**
          * Returns the next available {@link FileItemStream}.
+         *
          * @throws java.util.NoSuchElementException No more items are
          *   available. Use {@link #hasNext()} to prevent this exception.
          * @throws FileUploadException Parsing or processing the
@@ -935,6 +950,7 @@ public abstract class FileUploadBase {
             itemValid = false;
             return currentItem;
         }
+
     }
 
     /**
@@ -967,7 +983,9 @@ public abstract class FileUploadBase {
      */
     public static class InvalidContentTypeException
             extends FileUploadException {
-        /** The exceptions UID, for serializing an instance.
+
+        /**
+         * The exceptions UID, for serializing an instance.
          */
         private static final long serialVersionUID = -9073026332015646668L;
 
@@ -988,6 +1006,7 @@ public abstract class FileUploadBase {
         public InvalidContentTypeException(String message) {
             super(message);
         }
+
     }
 
     /**
@@ -1014,11 +1033,13 @@ public abstract class FileUploadBase {
         }
     }
 
-    /** This exception is thrown, if a requests permitted size
+    /**
+     * This exception is thrown, if a requests permitted size
      * is exceeded.
      */
     public abstract static class SizeException extends FileUploadException {
 
+
         private static final long serialVersionUID = -8776225574705254126L;
 
         /**
@@ -1033,6 +1054,7 @@ public abstract class FileUploadBase {
 
         /**
          * Creates a new instance.
+         *
          * @param message The detail message.
          * @param actual The actual number of bytes in the request.
          * @param permitted The requests size limit, in bytes.
@@ -1062,14 +1084,57 @@ public abstract class FileUploadBase {
         public long getPermittedSize() {
             return permitted;
         }
+
     }
 
     /**
+<<<<<<< .working
+=======
+     * Thrown to indicate that the request size is not specified. In other
+     * words, it is thrown, if the content-length header is missing or
+     * contains the value -1.
+     *
+     * @deprecated 1.2 As of commons-fileupload 1.2, the presence of a
+     *   content-length header is no longer required.
+     */
+    @Deprecated
+    public static class UnknownSizeException
+        extends FileUploadException {
+
+        /**
+         * The exceptions UID, for serializing an instance.
+         */
+        private static final long serialVersionUID = 7062279004812015273L;
+
+        /**
+         * Constructs a <code>UnknownSizeException</code> with no
+         * detail message.
+         */
+        public UnknownSizeException() {
+            super();
+        }
+
+        /**
+         * Constructs an <code>UnknownSizeException</code> with
+         * the specified detail message.
+         *
+         * @param message The detail message.
+         */
+        public UnknownSizeException(String message) {
+            super(message);
+        }
+
+    }
+
+    /**
+>>>>>>> .merge-right.r1453817
      * Thrown to indicate that the request size exceeds the configured maximum.
      */
     public static class SizeLimitExceededException
             extends SizeException {
-        /** The exceptions UID, for serializing an instance.
+
+        /**
+         * The exceptions UID, for serializing an instance.
          */
         private static final long serialVersionUID = -2474893167098052828L;
 
@@ -1085,6 +1150,7 @@ public abstract class FileUploadBase {
                 long permitted) {
             super(message, actual, permitted);
         }
+
     }
 
     /**
@@ -1092,7 +1158,9 @@ public abstract class FileUploadBase {
      */
     public static class FileSizeLimitExceededException
             extends SizeException {
-        /** The exceptions UID, for serializing an instance.
+
+        /**
+         * The exceptions UID, for serializing an instance.
          */
         private static final long serialVersionUID = 8150776562029630058L;
 
@@ -1122,6 +1190,7 @@ public abstract class FileUploadBase {
         /**
          * Returns the file name of the item, which caused the
          * exception.
+         *
          * @return File name, if known, or null.
          */
         public String getFileName() {
@@ -1139,6 +1208,7 @@ public abstract class FileUploadBase {
         /**
          * Returns the field name of the item, which caused the
          * exception.
+         *
          * @return Field name, if known, or null.
          */
         public String getFieldName() {
@@ -1152,10 +1222,12 @@ public abstract class FileUploadBase {
         public void setFieldName(String pFieldName) {
             fieldName = pFieldName;
         }
+
     }
 
     /**
      * Returns the progress listener.
+     *
      * @return The progress listener, if any, or null.
      */
     public ProgressListener getProgressListener() {
@@ -1164,9 +1236,11 @@ public abstract class FileUploadBase {
 
     /**
      * Sets the progress listener.
+     *
      * @param pListener The progress listener, if any. Defaults to null.
      */
     public void setProgressListener(ProgressListener pListener) {
         listener = pListener;
     }
+
 }

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java 
(original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItem.java 
Fri Mar 15 11:10:27 2013
@@ -29,6 +29,8 @@ import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.tomcat.util.http.fileupload.DeferredFileOutputStream;
 import org.apache.tomcat.util.http.fileupload.FileItem;
@@ -101,13 +103,12 @@ public class DiskFileItem
      * UID used in unique file name generation.
      */
     private static final String UID =
-            new java.rmi.server.UID().toString()
-                .replace(':', '_').replace('-', '_');
+            UUID.randomUUID().toString().replace('-', '_');
 
     /**
      * Counter used in unique identifier generation.
      */
-    private static int counter = 0;
+    private static final AtomicInteger counter = new AtomicInteger(0);
 
     /**
      * The name of the form field as provided by the browser.
@@ -319,10 +320,10 @@ public class DiskFileItem
         }
 
         byte[] fileData = new byte[(int) getSize()];
-        FileInputStream fis = null;
+        InputStream fis = null;
 
         try {
-            fis = new FileInputStream(dfos.getFile());
+            fis = new BufferedInputStream(new FileInputStream(dfos.getFile()));
             fis.read(fileData);
         } catch (IOException e) {
             fileData = null;
@@ -362,9 +363,9 @@ public class DiskFileItem
      * character encoding.  This method uses {@link #get()} to retrieve the
      * contents of the file.
      *
-     * @return The contents of the file, as a string.
+     * <b>TODO</b> Consider making this method throw 
UnsupportedEncodingException.
      *
-     * TODO Consider making this method throw UnsupportedEncodingException.
+     * @return The contents of the file, as a string.
      */
     @Override
     public String getString() {
@@ -617,10 +618,7 @@ public class DiskFileItem
      */
     private static String getUniqueId() {
         final int limit = 100000000;
-        int current;
-        synchronized (DiskFileItem.class) {
-            current = counter++;
-        }
+        int current = counter.getAndIncrement();
         String id = Integer.toString(current);
 
         // If you manage to get more than 100 million of ids, you'll

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/DiskFileItemFactory.java
 Fri Mar 15 11:10:27 2013
@@ -200,7 +200,7 @@ public class DiskFileItemFactory impleme
                 isFormField, fileName, sizeThreshold, repository);
         FileCleaningTracker tracker = getFileCleaningTracker();
         if (tracker != null) {
-            tracker.track(result.getTempFile(), this);
+            tracker.track(result.getTempFile(), result);
         }
         return result;
     }

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/package-info.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/package-info.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/package-info.java 
(original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/disk/package-info.java 
Fri Mar 15 11:10:27 2013
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /**
  *    <p>
  *      A disk-based implementation of the

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/package-info.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/package-info.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/package-info.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/package-info.java 
Fri Mar 15 11:10:27 2013
@@ -14,6 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+
 /**
  * <p><b>NOTE:</b> This code has been copied from commons-fileupload trunk
  * revision 1xxxxxx and commons-io 1.4 and package renamed to avoid clashes 
with
@@ -83,4 +85,4 @@
  * for further details and examples of how to use this package.
  * </p>
  */
-package org.apache.tomcat.util.http.fileupload;
\ No newline at end of file
+package org.apache.tomcat.util.http.fileupload;

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/ServletRequestContext.java
 Fri Mar 15 11:10:27 2013
@@ -42,7 +42,7 @@ public class ServletRequestContext imple
     /**
      * The request for which the context is being provided.
      */
-    private HttpServletRequest request;
+    private final HttpServletRequest request;
 
     // ----------------------------------------------------------- Constructors
 

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/package-info.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/package-info.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/package-info.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/servlet/package-info.java
 Fri Mar 15 11:10:27 2013
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /**
  *    <p>
  *      An implementation of

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/LimitedInputStream.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/LimitedInputStream.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/LimitedInputStream.java
 (original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/LimitedInputStream.java
 Fri Mar 15 11:10:27 2013
@@ -29,7 +29,7 @@ public abstract class LimitedInputStream
     /**
      * The maximum size of an item, in bytes.
      */
-    private long sizeMax;
+    private final long sizeMax;
 
     /**
      * The current number of bytes.

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/package-info.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/package-info.java?rev=1456895&r1=1456894&r2=1456895&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/package-info.java 
(original)
+++ 
tomcat/trunk/java/org/apache/tomcat/util/http/fileupload/util/package-info.java 
Fri Mar 15 11:10:27 2013
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -15,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 /**
  * This package contains various IO related utility classes
  * or methods, which are basically reusable and not necessarily



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to