You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2012/03/02 14:24:04 UTC
svn commit: r1296195 - in /cxf/branches/2.5.x-fixes: ./
rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/
rt/core/src/main/java/org/apache/cxf/attachment/
rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/
rt/transports/ht...
Author: sergeyb
Date: Fri Mar 2 13:24:04 2012
New Revision: 1296195
URL: http://svn.apache.org/viewvc?rev=1296195&view=rev
Log:
Merged revisions 1296183 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1296183 | sergeyb | 2012-03-02 12:58:48 +0000 (Fri, 02 Mar 2012) | 1 line
[CXF-4142] Checking contextual properties for non-root parts
........
Modified:
cxf/branches/2.5.x-fixes/ (props changed)
cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 2 13:24:04 2012
@@ -1 +1 @@
-/cxf/trunk:1296174
+/cxf/trunk:1296174,1296183
Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java (original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java Fri Mar 2 13:24:04 2012
@@ -199,7 +199,7 @@ public class SAAJInInterceptor extends A
for (Attachment a : atts) {
if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
try {
- ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache();
+ ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(message);
} catch (IOException e) {
throw new Fault(e);
}
Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java Fri Mar 2 13:24:04 2012
@@ -27,6 +27,7 @@ import javax.activation.DataSource;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
public class AttachmentDataSource implements DataSource {
@@ -43,9 +44,10 @@ public class AttachmentDataSource implem
public boolean isCached() {
return cache != null;
}
- public void cache() throws IOException {
+ public void cache(Message message) throws IOException {
if (cache == null) {
cache = new CachedOutputStream();
+ AttachmentUtil.setStreamedAttachmentProperties(message, cache);
IOUtils.copy(ins, cache);
cache.lockOutputStream();
ins.close();
@@ -55,8 +57,8 @@ public class AttachmentDataSource implem
}
}
}
- public void hold() throws IOException {
- cache();
+ public void hold(Message message) throws IOException {
+ cache(message);
cache.holdTempFile();
}
public void release() {
Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java Fri Mar 2 13:24:04 2012
@@ -19,7 +19,6 @@
package org.apache.cxf.attachment;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
@@ -168,37 +167,6 @@ public class AttachmentDeserializer {
return m.find() ? "--" + m.group(1) : null;
}
- private void setStreamedAttachmentProperties(CachedOutputStream bos) throws IOException {
- Object directory = message.getContextualProperty(ATTACHMENT_DIRECTORY);
- if (directory != null) {
- if (directory instanceof File) {
- bos.setOutputDir((File)directory);
- } else {
- bos.setOutputDir(new File((String)directory));
- }
- }
-
- Object threshold = message.getContextualProperty(ATTACHMENT_MEMORY_THRESHOLD);
- if (threshold != null) {
- if (threshold instanceof Long) {
- bos.setThreshold((Long)threshold);
- } else {
- bos.setThreshold(Long.valueOf((String)threshold));
- }
- } else {
- bos.setThreshold(THRESHOLD);
- }
-
- Object maxSize = message.getContextualProperty(ATTACHMENT_MAX_SIZE);
- if (maxSize != null) {
- if (maxSize instanceof Long) {
- bos.setMaxSize((Long) maxSize);
- } else {
- bos.setMaxSize(Long.valueOf((String)maxSize));
- }
- }
- }
-
public AttachmentImpl readNext() throws IOException {
// Cache any mime parts that are currently being streamed
cacheStreamedAttachments();
@@ -237,7 +205,7 @@ public class AttachmentDeserializer {
if (s instanceof AttachmentDataSource) {
AttachmentDataSource ads = (AttachmentDataSource)s;
if (!ads.isCached()) {
- ads.cache();
+ ads.cache(message);
}
} else if (s.getInputStream() instanceof DelegatingInputStream) {
cache((DelegatingInputStream) s.getInputStream(), false);
@@ -256,7 +224,7 @@ public class AttachmentDeserializer {
InputStream origIn = input.getInputStream();
try {
out = new CachedOutputStream();
- setStreamedAttachmentProperties(out);
+ AttachmentUtil.setStreamedAttachmentProperties(message, out);
IOUtils.copy(input, out);
input.setInputStream(out.getInputStream());
origIn.close();
Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java (original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java Fri Mar 2 13:24:04 2012
@@ -47,7 +47,9 @@ import javax.mail.internet.InternetHeade
import org.apache.cxf.helpers.HttpHeaderHelper;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
public final class AttachmentUtil {
@@ -73,6 +75,38 @@ public final class AttachmentUtil {
return COMMAND_MAP;
}
+ public static void setStreamedAttachmentProperties(Message message, CachedOutputStream bos)
+ throws IOException {
+ Object directory = message.getContextualProperty(AttachmentDeserializer.ATTACHMENT_DIRECTORY);
+ if (directory != null) {
+ if (directory instanceof File) {
+ bos.setOutputDir((File)directory);
+ } else {
+ bos.setOutputDir(new File((String)directory));
+ }
+ }
+
+ Object threshold = message.getContextualProperty(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD);
+ if (threshold != null) {
+ if (threshold instanceof Long) {
+ bos.setThreshold((Long)threshold);
+ } else {
+ bos.setThreshold(Long.valueOf((String)threshold));
+ }
+ } else {
+ bos.setThreshold(AttachmentDeserializer.THRESHOLD);
+ }
+
+ Object maxSize = message.getContextualProperty(AttachmentDeserializer.ATTACHMENT_MAX_SIZE);
+ if (maxSize != null) {
+ if (maxSize instanceof Long) {
+ bos.setMaxSize((Long) maxSize);
+ } else {
+ bos.setMaxSize(Long.valueOf((String)maxSize));
+ }
+ }
+ }
+
/**
* @param ns
* @return
Modified: cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java (original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java Fri Mar 2 13:24:04 2012
@@ -53,7 +53,7 @@ public final class JAXBAttachmentSchemaV
if (at.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
AttachmentDataSource ds = (AttachmentDataSource)at.getDataHandler().getDataSource();
try {
- ds.hold();
+ ds.hold(message);
} catch (IOException e) {
throw new Fault(e);
}
Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Fri Mar 2 13:24:04 2012
@@ -453,7 +453,7 @@ public abstract class AbstractHTTPDestin
for (Attachment a : atts) {
if (a.getDataHandler().getDataSource() instanceof AttachmentDataSource) {
try {
- ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache();
+ ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(inMessage);
} catch (IOException e) {
throw new Fault(e);
}
Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java Fri Mar 2 13:24:04 2012
@@ -562,7 +562,31 @@ public class JAXRSMultipartTest extends
post.setRequestHeader("Content-Type", ct);
Part[] parts = new Part[1];
parts[0] = new FilePart("image",
- new ByteArrayPartSource("testfile.png", new byte[1024 * 1024 * 15]),
+ new ByteArrayPartSource("testfile.png", new byte[1024 * 11]),
+ "image/png", null);
+ post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
+
+ HttpClient httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(post);
+ assertEquals(413, result);
+ } finally {
+ // Release current connection to the connection pool once you are done
+ post.releaseConnection();
+ }
+ }
+ @Test
+ public void testMultipartRequestTooLargeManyParts() throws Exception {
+ PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
+ String ct = "multipart/mixed";
+ post.setRequestHeader("Content-Type", ct);
+ Part[] parts = new Part[2];
+ parts[0] = new FilePart("image",
+ new ByteArrayPartSource("testfile.png", new byte[1024 * 9]),
+ "image/png", null);
+ parts[1] = new FilePart("image",
+ new ByteArrayPartSource("testfile2.png", new byte[1024 * 11]),
"image/png", null);
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
Modified: cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java?rev=1296195&r1=1296194&r2=1296195&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java (original)
+++ cxf/branches/2.5.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java Fri Mar 2 13:24:04 2012
@@ -34,7 +34,7 @@ public class MultipartServer extends Abs
sf.setResourceClasses(MultipartStore.class);
sf.setProperties(Collections.<String, Object>singletonMap(
AttachmentDeserializer.ATTACHMENT_MAX_SIZE,
- String.valueOf(1024 * 1024 * 10)));
+ String.valueOf(1024 * 10)));
//default lifecycle is per-request, change it to singleton
sf.setResourceProvider(MultipartStore.class,
new SingletonResourceProvider(new MultipartStore()));