You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ma...@apache.org on 2005/12/04 07:33:58 UTC

svn commit: r353822 - in /jakarta/commons/proper/fileupload/trunk: fileupload_checks.xml src/java/org/apache/commons/fileupload/MultipartStream.java

Author: martinc
Date: Sat Dec  3 22:33:55 2005
New Revision: 353822

URL: http://svn.apache.org/viewcvs?rev=353822&view=rev
Log:
Fix more Checkstyle warnings.

Modified:
    jakarta/commons/proper/fileupload/trunk/fileupload_checks.xml
    jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/MultipartStream.java

Modified: jakarta/commons/proper/fileupload/trunk/fileupload_checks.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/fileupload/trunk/fileupload_checks.xml?rev=353822&r1=353821&r2=353822&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/fileupload_checks.xml (original)
+++ jakarta/commons/proper/fileupload/trunk/fileupload_checks.xml Sat Dec  3 22:33:55 2005
@@ -165,7 +165,7 @@
         <!-- Checks for blocks. You know, those {}'s         -->
         <!-- See http://checkstyle.sf.net/config_blocks.html -->
         <module name="AvoidNestedBlocks"/>
-        <module name="EmptyBlock"/>
+        <!-- Disabled for FileUpload: module name="EmptyBlock"/ -->
         <module name="LeftCurly"/>
         <module name="NeedBraces"/>
         <module name="RightCurly"/>

Modified: jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/MultipartStream.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/MultipartStream.java?rev=353822&r1=353821&r2=353822&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/MultipartStream.java (original)
+++ jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/MultipartStream.java Sat Dec  3 22:33:55 2005
@@ -142,6 +142,20 @@
             DASH, DASH};
 
 
+    /**
+     * A byte sequence that precedes a boundary (<code>CRLF--</code>).
+     */
+    protected static final byte[] BOUNDARY_PREFIX = {
+            CR, LF, DASH, DASH};
+
+
+    /**
+     * The number of bytes, over and above the boundary size, to use for the
+     * keep region.
+     */
+    private static final int KEEP_REGION_PAD = 3;
+
+
     // ----------------------------------------------------------- Data members
 
 
@@ -245,14 +259,13 @@
 
         // We prepend CR/LF to the boundary to chop trailng CR/LF from
         // body-data tokens.
-        this.boundary = new byte[boundary.length + 4];
-        this.boundaryLength = boundary.length + 4;
-        this.keepRegion = boundary.length + 3;
-        this.boundary[0] = CR;
-        this.boundary[1] = LF;
-        this.boundary[2] = DASH;
-        this.boundary[3] = DASH;
-        System.arraycopy(boundary, 0, this.boundary, 4, boundary.length);
+        this.boundary = new byte[boundary.length + BOUNDARY_PREFIX.length];
+        this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
+        this.keepRegion = boundary.length + KEEP_REGION_PAD;
+        System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0,
+                BOUNDARY_PREFIX.length);
+        System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
+                boundary.length);
 
         head = 0;
         tail = 0;
@@ -396,11 +409,12 @@
      */
     public void setBoundary(byte[] boundary)
         throws IllegalBoundaryException {
-        if (boundary.length != boundaryLength - 4) {
+        if (boundary.length != boundaryLength - BOUNDARY_PREFIX.length) {
             throw new IllegalBoundaryException(
                     "The length of a boundary token can not be changed");
         }
-        System.arraycopy(boundary, 0, this.boundary, 4, boundary.length);
+        System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length,
+                boundary.length);
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org