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/12/03 10:39:56 UTC

svn commit: r1209868 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java

Author: veithen
Date: Sat Dec  3 09:39:56 2011
New Revision: 1209868

URL: http://svn.apache.org/viewvc?rev=1209868&view=rev
Log:
AXIOM-377: Some clarifications about the PartDataHandler code.

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

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java?rev=1209868&r1=1209867&r2=1209868&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/PartDataHandler.java Sat Dec  3 09:39:56 2011
@@ -32,6 +32,12 @@ class PartDataHandler extends DataHandle
     private DataSource dataSource;
 
     public PartDataHandler(PartImpl part) {
+        // We can't call PartImpl#getDataSource() here because it would fetch the content of the
+        // part and therefore disable streaming. We can't pass null here either because Geronimo's
+        // DataHandler implementation would throw a NullPointerException. Therefore we create the
+        // default PartDataSource. When the DataSource is requested, we check if for there is an
+        // implementation specific to the buffering strategy and return that instead of the default
+        // implementation.
         super(new PartDataSource(part));
         this.part = part;
     }
@@ -39,8 +45,14 @@ class PartDataHandler extends DataHandle
     public DataSource getDataSource() {
         if (dataSource == null) {
             dataSource = part.getDataSource();
+            if (dataSource == null) {
+                // We get here if there is no DataSource implementation specific to the buffering
+                // strategy being used. In this case we use super.getDataSource() to get the
+                // default PartDataSource that we created in the constructor.
+                dataSource = super.getDataSource();
+            }
         }
-        return dataSource == null ? super.getDataSource() : dataSource;
+        return dataSource;
     }
 
     public InputStream readOnce() throws IOException {