8038966: JAX-WS handles wrongly xsd:any arguments for Web services
authormkos
Thu, 25 Sep 2014 10:02:12 +0200
changeset 26775 810bea25280c
parent 26668 1b1ec4291abc
child 26776 a54a9b558134
8038966: JAX-WS handles wrongly xsd:any arguments for Web services Reviewed-by: coffeys
jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/ContentHandlerAdaptor.java
jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/ContentHandlerAdaptor.java	Wed Jul 05 20:01:50 2017 +0200
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/ContentHandlerAdaptor.java	Thu Sep 25 10:02:12 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,6 @@
 
 package com.sun.xml.internal.bind.v2.runtime;
 
-import java.io.IOException;
-
-import javax.xml.stream.XMLStreamException;
-
 import com.sun.istack.internal.FinalArrayList;
 import com.sun.istack.internal.SAXException2;
 
@@ -36,6 +32,9 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 
+import javax.xml.stream.XMLStreamException;
+import java.io.IOException;
+
 /**
  * Receives SAX2 events and send the equivalent events to
  * {@link XMLSerializer}
@@ -70,14 +69,14 @@
     private boolean containsPrefixMapping(String prefix, String uri) {
         for( int i=0; i<prefixMap.size(); i+=2 ) {
             if(prefixMap.get(i).equals(prefix)
-            && prefixMap.get(i+1).equals(uri))
+                    && prefixMap.get(i+1).equals(uri))
                 return true;
         }
         return false;
     }
 
     public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
-        throws SAXException {
+            throws SAXException {
         try {
             flushText();
 
@@ -92,13 +91,13 @@
                 serializer.startElement(namespaceURI,localName, p,null);
 
             // declare namespace events
-            for( int i=0; i<prefixMap.size(); i+=2 ) {
+            for (int i = 0; i < prefixMap.size(); i += 2) {
                 // forcibly set this binding, instead of using declareNsUri.
                 // this guarantees that namespaces used in DOM will show up
                 // as-is in the marshalled output (instead of reassigned to something else,
                 // which may happen if you'd use declareNsUri.)
                 serializer.getNamespaceContext().force(
-                    prefixMap.get(i+1), prefixMap.get(i) );
+                        prefixMap.get(i + 1), prefixMap.get(i));
             }
             // make sure namespaces needed by attributes are bound
             for( int i=0; i<len; i++ ) {
@@ -108,7 +107,7 @@
                 String prefix = getPrefix(qname);
 
                 serializer.getNamespaceContext().declareNamespace(
-                    atts.getURI(i), prefix, true );
+                        atts.getURI(i), prefix, true );
             }
 
             serializer.endNamespaceDecls(null);
@@ -128,9 +127,10 @@
         }
     }
 
+    // make sure namespaces needed by attributes are bound
     private String getPrefix(String qname) {
         int idx = qname.indexOf(':');
-        String prefix = (idx==-1)?qname:qname.substring(0,idx);
+        String prefix = (idx == -1) ? "" : qname.substring(0, idx);
         return prefix;
     }
 
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java	Wed Jul 05 20:01:50 2017 +0200
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java	Thu Sep 25 10:02:12 2014 +0200
@@ -70,7 +70,7 @@
         // Quick hack until SJSXP fixes 6270116
         boolean isZephyr = readerClass.getName().equals("com.sun.xml.internal.stream.XMLReaderImpl");
         if (getBoolProp(reader,"org.codehaus.stax2.internNames") &&
-            getBoolProp(reader,"org.codehaus.stax2.internNsUris"))
+                getBoolProp(reader,"org.codehaus.stax2.internNsUris"))
             ; // no need for interning
         else
         if (isZephyr)
@@ -219,8 +219,8 @@
         int nsCount = staxStreamReader.getNamespaceCount();
         for (int i = 0; i < nsCount; i++) {
             visitor.startPrefixMapping(
-                fixNull(staxStreamReader.getNamespacePrefix(i)),
-                fixNull(staxStreamReader.getNamespaceURI(i)));
+                    fixNull(staxStreamReader.getNamespacePrefix(i)),
+                    fixNull(staxStreamReader.getNamespaceURI(i)));
         }
 
         // fire startElement
@@ -310,13 +310,13 @@
     protected void handleCharacters() throws XMLStreamException, SAXException {
         if( predictor.expectText() )
             buffer.append(
-                staxStreamReader.getTextCharacters(),
-                staxStreamReader.getTextStart(),
-                staxStreamReader.getTextLength() );
+                    staxStreamReader.getTextCharacters(),
+                    staxStreamReader.getTextStart(),
+                    staxStreamReader.getTextLength() );
     }
 
     private void processText( boolean ignorable ) throws SAXException {
-        if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer))) {
+        if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) {
             if(textReported) {
                 textReported = false;
             } else {