cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1038747 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Date Wed, 24 Nov 2010 18:21:53 GMT
Author: sergeyb
Date: Wed Nov 24 18:21:53 2010
New Revision: 1038747

URL: http://svn.apache.org/viewvc?rev=1038747&view=rev
Log:
Merged revisions 1038746 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1038746 | sergeyb | 2010-11-24 18:20:20 +0000 (Wed, 24 Nov 2010) | 1 line
  
  [CXF-3148] Improving the code dealing with explicit collections by applying a fix on behalf
of Dobes Vandermeer
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 24 18:21:53 2010
@@ -1 +1 @@
-/cxf/trunk:1038206,1038374,1038386,1038722
+/cxf/trunk:1038206,1038374,1038386,1038722,1038746

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1038747&r1=1038746&r2=1038747&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Wed Nov 24 18:21:53 2010
@@ -27,6 +27,7 @@ import java.lang.reflect.Type;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -256,11 +257,16 @@ public class JAXBElementProvider extends
                                      Type genericType, String encoding, OutputStream os,
MediaType m) 
         throws Exception {
         
-        Object[] arr = originalCls.isArray() ? (Object[])actualObject : ((Collection)actualObject).toArray();
+        Collection c = originalCls.isArray() ? Arrays.asList((Object[]) actualObject) 
+                                             : (Collection) actualObject;
+
+        Iterator it = c.iterator();
         
+        Object firstObj = it.hasNext() ? it.next() : null;
+
         QName qname = null;
-        if (arr.length > 0 && arr[0] instanceof JAXBElement) {
-            JAXBElement el = (JAXBElement)arr[0];
+        if (firstObj instanceof JAXBElement) {
+            JAXBElement el = (JAXBElement)firstObj;
             qname = el.getName();
             actualClass = el.getDeclaredType();
         } else {
@@ -284,9 +290,15 @@ public class JAXBElementProvider extends
             endTag = "</" + qname.getLocalPart() + ">";
         }
         os.write(startTag.getBytes());
-        for (Object o : arr) {
-            marshalCollectionMember(o instanceof JAXBElement ? ((JAXBElement)o).getValue()
: o, 
-                                    actualClass, genericType, encoding, os, m, qname.getNamespaceURI());
   
+        if (firstObj != null) {
+            marshalCollectionMember(firstObj instanceof JAXBElement 
+                ? ((JAXBElement) firstObj).getValue() : firstObj, actualClass, genericType,
encoding, os, m, 
+                qname.getNamespaceURI());
+            while (it.hasNext()) {
+                Object o = it.next();
+                marshalCollectionMember(o instanceof JAXBElement ? ((JAXBElement)o).getValue()
: o, 
+                                    actualClass, genericType, encoding, os, m, qname.getNamespaceURI());
+            }
         }
         os.write(endTag.getBytes());
     }



Mime
View raw message