You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2011/08/01 19:59:14 UTC

svn commit: r1152878 - in /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments: MIMEMessage.java impl/PartFactory.java

Author: veithen
Date: Mon Aug  1 17:59:13 2011
New Revision: 1152878

URL: http://svn.apache.org/viewvc?rev=1152878&view=rev
Log:
AXIOM-326: Improved error handling.

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java?rev=1152878&r1=1152877&r2=1152878&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/MIMEMessage.java Mon Aug  1 17:59:13 2011
@@ -366,10 +366,13 @@ class MIMEMessage extends AttachmentsImp
                                       attachmentRepoDir, 
                                       contentLength);  // content-length for the whole message
         try {
-            if (parser.next() == EntityState.T_EPILOGUE) {
+            EntityState state = parser.next();
+            if (state == EntityState.T_EPILOGUE) {
                 while (parser.next() != EntityState.T_END_MULTIPART) {
                     // Just loop
                 }
+            } else if (state != EntityState.T_START_BODYPART && state != EntityState.T_END_MULTIPART) {
+                throw new IllegalStateException("Internal error: unexpected parser state " + state);
             }
         } catch (IOException ex) {
             throw new OMException(ex);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java?rev=1152878&r1=1152877&r2=1152878&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl/PartFactory.java Mon Aug  1 17:59:13 2011
@@ -61,10 +61,10 @@ public class PartFactory {
     // Dynamic Threshold = availMemory / THRESHOLD_FACTOR
     private static final int THRESHOLD_FACTOR = 5;
     
-    private static void checkParserState(EntityState expected, EntityState actual) throws IllegalStateException {
-        if (expected != actual) {
+    private static void checkParserState(EntityState state, EntityState expected) throws IllegalStateException {
+        if (expected != state) {
             throw new IllegalStateException("Internal error: expected parser to be in state "
-                    + expected + ", but got " + actual);
+                    + expected + ", but got " + state);
         }
     }
     
@@ -97,6 +97,8 @@ public class PartFactory {
         }
         
         try {
+            checkParserState(parser.getState(), EntityState.T_START_BODYPART);
+            
             // Read enough of the InputStream to build the headers 
             // The readHeaders returns some extra bits that were read, but are part
             // of the data section.