cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: [CXF-6217] Make sure we use XMLStreamReader for unmarshalling
Date Fri, 23 Jan 2015 17:54:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes ea6d2f7dd -> 3c874549a


[CXF-6217] Make sure we use XMLStreamReader for unmarshalling


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/3c874549
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/3c874549
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/3c874549

Branch: refs/heads/3.0.x-fixes
Commit: 3c874549a1c9653482f83f874003b1442d7379ae
Parents: ea6d2f7
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Jan 23 12:46:31 2015 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Jan 23 12:54:08 2015 -0500

----------------------------------------------------------------------
 .../cxf/jaxrs/provider/atom/AtomPojoProvider.java     | 14 +++++++++++++-
 .../java/org/apache/cxf/wsn/jms/JmsPullPoint.java     |  6 +++++-
 .../java/org/apache/cxf/wsn/jms/JmsSubscription.java  |  6 +++++-
 3 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/3c874549/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
index 4e670f6..c1c7237 100644
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
+++ b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
@@ -47,6 +47,8 @@ import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.factory.Factory;
@@ -63,6 +65,7 @@ import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
 import org.apache.cxf.jaxrs.utils.ExceptionUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.staxutils.StaxUtils;
 
 @Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/atom+xml;type=entry"
})
 @Consumes({"application/atom+xml", "application/atom+xml;type=feed", "application/atom+xml;type=entry"
})
@@ -658,12 +661,21 @@ public class AtomPojoProvider extends AbstractConfigurableProvider
         }
         String entryContent = entry.getContent();
         if (entryContent != null) {
+            XMLStreamReader xreader = StaxUtils.createXMLStreamReader(new StringReader(entryContent));
             try {
                 Unmarshaller um = 
                     jaxbProvider.getJAXBContext(cls, cls).createUnmarshaller();
-                return cls.cast(um.unmarshal(new StringReader(entryContent)));
+                return cls.cast(um.unmarshal(xreader));
             } catch (Exception ex) {
                 reportError("Object of type " + cls.getName() + " can not be deserialized
from Entry", ex, 400);
+            } finally {
+                try {
+                    if (xreader != null) {
+                        StaxUtils.close(xreader);
+                    }
+                } catch (XMLStreamException e) {
+                    //ignore
+                }
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3c874549/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
----------------------------------------------------------------------
diff --git a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
index 4dc25c7..1ac5c00 100644
--- a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
+++ b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsPullPoint.java
@@ -35,8 +35,10 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.wsn.AbstractPullPoint;
 import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
 import org.oasis_open.docs.wsn.b_2.Notify;
@@ -120,7 +122,9 @@ public class JmsPullPoint extends AbstractPullPoint {
                 }
                 TextMessage txtMsg = (TextMessage) msg;
                 StringReader reader = new StringReader(txtMsg.getText());
-                Notify notify = (Notify) jaxbContext.createUnmarshaller().unmarshal(reader);
+                XMLStreamReader xreader = StaxUtils.createXMLStreamReader(reader);
+                Notify notify = (Notify) jaxbContext.createUnmarshaller().unmarshal(xreader);
+                reader.close();
                 messages.addAll(notify.getNotificationMessage());
             }
             return messages;

http://git-wip-us.apache.org/repos/asf/cxf/blob/3c874549/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
----------------------------------------------------------------------
diff --git a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
index f8b542f..a7e539e 100644
--- a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
+++ b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
@@ -35,6 +35,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
@@ -45,6 +46,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.wsn.AbstractSubscription;
 import org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType;
 import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
@@ -189,8 +191,10 @@ public abstract class JmsSubscription extends AbstractSubscription implements
Me
     public void onMessage(Message jmsMessage) {
         try {
             TextMessage text = (TextMessage) jmsMessage;
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(text.getText()));

             Notify notify = (Notify) jaxbContext.createUnmarshaller()
-                    .unmarshal(new StringReader(text.getText()));
+                    .unmarshal(reader);
+            reader.close();
             for (Iterator<NotificationMessageHolderType> ith = notify.getNotificationMessage().iterator();
                 ith.hasNext();) {
                 NotificationMessageHolderType h = ith.next();


Mime
View raw message