You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/11/16 23:12:06 UTC
svn commit: r881000 - in /cxf/branches/2.2.x-fixes: ./
api/src/main/java/org/apache/cxf/message/MessageImpl.java
rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Author: dkulp
Date: Mon Nov 16 22:12:06 2009
New Revision: 881000
URL: http://svn.apache.org/viewvc?rev=881000&view=rev
Log:
Merged revisions 880989 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r880989 | dkulp | 2009-11-16 17:03:31 -0500 (Mon, 16 Nov 2009) | 1 line
[CXF-2543] Add NPE guards to MssageImpl
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/MessageImpl.java
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/MessageImpl.java?rev=881000&r1=880999&r2=881000&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/MessageImpl.java (original)
+++ cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/MessageImpl.java Mon Nov 16 22:12:06 2009
@@ -110,7 +110,7 @@
Object val = get(key);
Exchange ex = getExchange();
- if (val == null) {
+ if (val == null && ex != null) {
val = ex.get(key);
}
@@ -121,7 +121,7 @@
}
}
- if (val == null) {
+ if (val == null && ex != null) {
Endpoint ep = ex.get(Endpoint.class);
if (ep != null) {
val = ep.get(key);
@@ -135,19 +135,17 @@
}
}
- }
-
- if (val == null) {
- Service ep = ex.get(Service.class);
- if (ep != null) {
- val = ep.get(key);
- }
- }
-
- if (val == null) {
- Bus bus = ex.get(Bus.class);
- if (bus != null) {
- val = bus.getProperty(key);
+ if (val == null) {
+ Service sv = ex.get(Service.class);
+ if (sv != null) {
+ val = sv.get(key);
+ }
+ if (val == null) {
+ Bus bus = ex.get(Bus.class);
+ if (bus != null) {
+ val = bus.getProperty(key);
+ }
+ }
}
}
Modified: cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=881000&r1=880999&r2=881000&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java Mon Nov 16 22:12:06 2009
@@ -25,6 +25,11 @@
import java.util.Collection;
import java.util.Iterator;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.helpers.DefaultHandler;
+
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
@@ -299,4 +304,33 @@
assertEquals(-1, m.read(new byte[1000]));
assertEquals(-1, m.read(new byte[1000]));
}
+
+ @Test
+ public void testCXF2542() throws Exception {
+ StringBuffer buf = new StringBuffer();
+ buf.append("------=_Part_0_2180223.1203118300920\n");
+ buf.append("Content-Type: application/xop+xml; charset=UTF-8; type=\"text/xml\"\n");
+ buf.append("Content-Transfer-Encoding: 8bit\n");
+ buf.append("Content-ID: <so...@xfire.codehaus.org>\n");
+ buf.append("\n");
+ buf.append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
+ + "<soap:Body><getNextMessage xmlns=\"http://foo.bar\" /></soap:Body>"
+ + "</soap:Envelope>\n");
+ buf.append("------=_Part_0_2180223.1203118300920--\n");
+
+ InputStream rawInputStream = new ByteArrayInputStream(buf.toString().getBytes());
+ MessageImpl message = new MessageImpl();
+ message.setContent(InputStream.class, rawInputStream);
+ message.put(Message.CONTENT_TYPE,
+ "multipart/related; type=\"application/xop+xml\"; "
+ + "start=\"<so...@xfire.codehaus.org>\"; "
+ + "start-info=\"text/xml\"; boundary=\"----=_Part_0_2180223.1203118300920\"");
+ new AttachmentDeserializer(message).initializeAttachments();
+ InputStream inputStreamWithoutAttachments = message.getContent(InputStream.class);
+ SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+ parser.parse(inputStreamWithoutAttachments, new DefaultHandler());
+ System.out.println("All done.");
+ }
}
\ No newline at end of file