aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaluca Sauciuc <ralucas@google.com>2017-06-12 15:03:14 -0700
committerRaluca Sauciuc <ralucas@google.com>2017-06-12 15:03:14 -0700
commit1608370faaf8ca1655f5442d66d2cfd6282747c7 (patch)
tree18092dc4596efc814487d2f9be9e4cb9e741676b
parent7081f557de89b5eba9f7f9f148ecdd01057a7b9a (diff)
parent7f73075be58c5ba6e3ece0be042218b290d1d668 (diff)
downloadjdk8u_jaxws-1608370faaf8ca1655f5442d66d2cfd6282747c7.tar.gz
Merge 'jetbrains-master-mirror' into studio-master-dev
This adds upstream's latest changes from branch 884, see https://github.com/JetBrains/jdk8u_jaxws/compare/736...884
-rw-r--r--.hgtags99
-rw-r--r--ASSEMBLY_EXCEPTION24
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java30
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java33
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java314
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java51
6 files changed, 427 insertions, 124 deletions
diff --git a/.hgtags b/.hgtags
index 3e16f18b..a1183c86 100644
--- a/.hgtags
+++ b/.hgtags
@@ -384,6 +384,7 @@ b6120aaf2aeef7c5608d578e15e82db7eb24fb2e jdk8u40-b25
a5f2cdedb940511674e153dce8d3cbc3a0598c9e jdk8u40-b27
a342e6841e8d3bbef44d4158c980be2ab903e10a jdk8u40-b31
8960bce00f1abecad665291b0077d6e673c0ff64 jdk8u40-b32
+f9e72841a77fe0402da947500359f4d60ecc89df jdk8u40-b33
667a4aee3720373f5c286a50f537afd0ff4b65ae jdk8u45-b00
cb6added4913f4899bd1689e77be1fe4efcff4f1 jdk8u45-b01
855a7b9302053546e4da94b67cc3b8956f5b4985 jdk8u45-b02
@@ -531,17 +532,26 @@ a2473dd1dc0df47425e42d7fed1e4cabdb696154 jdk8u72-b12
4c28352ce19bc25be5de681868a8cddb3f3644a8 jdk8u72-b13
1a523f4b8cc77ef9dfb6d8191742dcd616cd9093 jdk8u72-b14
2f840ac0adf079f0d2f0bac7a9c3fae6ea651271 jdk8u72-b15
+744fab401c4b326f142f5110ad523b1b22f973c8 jdk8u72-b31
8da626c14c138dd41d4c685800351bf675048628 jdk8u73-b00
dfc9feacece48fa8450b997e463afae2c1539ac3 jdk8u73-b01
06fb882f8ed7ff3e58f7aa57e526e55c25ae9992 jdk8u73-b02
4a5f76111c0b056357d4bdd3e015d649de2db591 jdk8u74-b00
621e4ac137cd4a04ac1279e75d7fd0625765fd03 jdk8u74-b01
6cfef18571fd35f45bada34cf4da4b1492ddb878 jdk8u74-b02
+e2d83c243af551722c88fe2dd391364373e2bd3a jdk8u74-b31
+62291bde8b5ea2288c0729982681baec7cd0451f jdk8u74-b32
+a2f8a45d70b21e450fac7ae7d5ca71ce853cf3d0 jdk8u77-b00
+dd34713088c23b7c6ef1adc071dd635bc7bda744 jdk8u77-b01
+7c319d6e0d4c59ebde91b88ba1391ace165b2f01 jdk8u77-b02
+c6f67bea4466783433b1bf1f83a4eb6784a5eb55 jdk8u77-b03
+bedbb9b6cf59d5da68478a4b49bb2fdfc43a4f2c jdk8u77-b31
744fab401c4b326f142f5110ad523b1b22f973c8 jdk8u72-b31
7d7b3488f44e77bedbbcbdee5a4415e5a5bd930c jdk8u75-b00
d0161a6ecd3bf8c9953e979db8318177e4f2aa86 jdk8u75-b01
57eb6af19a97a835b07c618d1c0aea50a0577337 jdk8u75-b02
3412fd49bcbedcc4b0f6ae13a149e53ecde968ae jdk8u75-b03
+6580edbc4511d5a2281138c476700b8ab12165af jdk8u101-b00
6580edbc4511d5a2281138c476700b8ab12165af jdk8u75-b04
31337d5922975e1655764a7db158154d48866c13 jdk8u75-b05
7fca20ec14beec302f7a4d446d1d8646a9a0b74f jdk8u75-b06
@@ -557,6 +567,7 @@ c6f67bea4466783433b1bf1f83a4eb6784a5eb55 jdk8u77-b03
f66ee2329cd21c3485de1b8e0588f55882a56e0d jdk8u91-b00
be5935ee38f1bc5132cf318f7badb61af86e2396 jdk8u91-b13
e71f424e2c966a495b1d47693317288f291a794a jdk8u91-b14
+4c0ed3f71a596277f3c28b3f841d5c4ee7a007e6 jdk8u91-b15
6aba0f814a15966e47aeab61b466894b82c03c70 jdk8u76-b00
60789eebd1fe440255fd3f504221dc8b5553b8c2 jdk8u76-b01
8c7d476c446940edd913ba5a3ca36975febdac28 jdk8u76-b02
@@ -573,6 +584,24 @@ fad3981b329a0d309f4922bbca7335973e32e50f jdk8u76-b12
451d700ba30ee0d3d201090a9d5dd606b988820e jdk8u92-b00
008547c7dd3e324c46c2711b54285ca99e2ae0b9 jdk8u92-b13
759ba92444a9e85434cb381f437aba65e3c9f780 jdk8u92-b14
+38c6262b86559ff589f65f5bcc744b1763e20311 jdk8u92-b31
+b762186ac713fbb0fc759110a1c88bca4b4818cd jdk8u92-b32
+ff694a4e9cae136032855516e5f0cd7f1a0e6957 jdk8u92-b33
+283147c5fcc5027b39ca577250edaec4b4b87c0f jdk8u92-b34
+6580edbc4511d5a2281138c476700b8ab12165af jdk8u81-b00
+0bff22fbd91f48c37f7c5a4544929231b92bd9bf jdk8u101-b01
+31e437ae0354e628a675bc4eb6b9ca67af552fc2 jdk8u101-b02
+2a5ea5a78ae7332b3d13af5580418ca9d186cda7 jdk8u101-b03
+d3b054313ed2d29f9dbbdfd71a7ab3c4ad4eb5b6 jdk8u101-b04
+0a657e4d5ed57bf3216b96915633b661f6532be5 jdk8u101-b05
+8cef2df1e60991bfdd8b2d8a8bad9e3506c1a386 jdk8u101-b06
+96be6de53286422ccbfd1c4fdf36a0490af32edb jdk8u101-b07
+a6ed0b0e8707b7112c99294122d7f3b259707603 jdk8u101-b08
+a93b161995a80cf7b0e599cf2f91e755ab1c7098 jdk8u101-b09
+ea422e4481f6edfb77bb3a4cd74a73e463143ff3 jdk8u101-b10
+5f3dcb815b9715215d086ba0d48a59b23d01d0a4 jdk8u101-b11
+6a0347504d4c4171fcc24bc17749c0559518d862 jdk8u101-b12
+287f9e9d45cc05b902925346bb6f6ee34a5d5813 jdk8u101-b13
6aba0f814a15966e47aeab61b466894b82c03c70 jdk8u76-b00
60789eebd1fe440255fd3f504221dc8b5553b8c2 jdk8u76-b01
8c7d476c446940edd913ba5a3ca36975febdac28 jdk8u76-b02
@@ -584,6 +613,76 @@ c0ad0fa38df0841eaaf81ab40e8b07b42372c5d5 jdk8u102-b01
face9bd6bac2d43d4c423be4fe733689794c2f08 jdk8u102-b02
4e12f131bb0dbe0478aecb7ebdfe24b10d3ece75 jdk8u102-b03
5b1d73ea0eb68cef733eb9379ed71cfb008da72e jdk8u102-b04
+1f512419ae336ce17f1d16384e34669a81db27ae jdk8u102-b05
+c8f5925b8ec9491d95538d94803cf03b2d75d1b6 jdk8u102-b06
+d4bd96ee50976dc9e4cb308d8728e70ecb03a944 jdk8u102-b07
+ca64f5f827251b5c28046f79c3577fbc8991d3d7 jdk8u102-b08
+5b93dc7249127c6beae1a688b6cea204bac3fdd0 jdk8u102-b09
+7a11148c41b867305b153b6b82d75717accea119 jdk8u102-b10
+0305736a8580ad84733878623eda8f770ae04d60 jdk8u102-b11
+d02665ceefe5b12539bcd2bde95d4ada1a135cb0 jdk8u102-b12
+d84434eb3e4e991812a7b0c3c9e6bfdabae910d0 jdk8u102-b13
+81f2d81a48d74d2d4882c11330366517b73ee064 jdk8u102-b14
+de23881ca76c9c69f4e47e9b15d09a91fbb17176 jdk8u102-b31
+f638db3f652d3ec698aad0193c118c8afdaa001b jdk8u102-b32
+c28a73050d99040158ade12858b38d27686800ce jdk8u102-b33
+0cf16c3a71ab070daa1aee4367afdd8c4aa1daa3 jdk8u102-b34
+afa2263b5de8018a2b4a3cd5f66e438cb8ffe0e9 jdk8u102-b35
+d3b054313ed2d29f9dbbdfd71a7ab3c4ad4eb5b6 jdk8u111-b00
+6b861e233c89df49ba9b0357578f556f4953df57 jdk8u111-b01
+a896244473b934376ae7b48a281a0401774c9074 jdk8u111-b02
+d4b631c4844d23a30f11e37696e6f4ac1e9057dd jdk8u111-b03
+9ba3b9700df8b4fc0f5b94b3930d4ba85be3b749 jdk8u111-b04
+452662a83e5bc6dc7e9425ddd10f6c8fc98d50d8 jdk8u111-b05
+cc2f9d823c77cf8f8442a2246edf00f66c2dda8a jdk8u111-b06
+23aa5ab8a2c882d467b8a86d587050de7d523604 jdk8u111-b07
+0a3caaf419ccbf819624f1d438c9fc834682821c jdk8u111-b08
+68b99f65ae7599bc873d20ed150ed8277f2784ff jdk8u111-b09
+11d721e50941b0ba73252f8c8fa333eb1450a317 jdk8u111-b10
+730d8fc6bbfc5c642770b15e4787e1d0545c8f32 jdk8u111-b11
+6ccfdf9a9af5f2df5cbd5ecd5f17aecef289094b jdk8u111-b12
+914f31660407050cb04357f472d8365d5a781cd7 jdk8u111-b13
+1439cb8c6e86560934b9642cf36cddbfcb8f87be jdk8u111-b14
2d1c73175b3a5bd829503734e6eb65426bd12e16 jdk8u112-b00
10388356386d4c6eaf63dc50a05b5a373b4dde98 jdk8u112-b01
903e66791568904247b4181ebe3e05275788f02c jdk8u112-b02
+560d4d5c7a319e4b9316ef922c815307e32accf2 jdk8u112-b03
+da39da2c7a855575acf7bff86e5707c9aa723160 jdk8u112-b04
+454315c9ffd47f1abec15a51ff51f25c92d09254 jdk8u112-b06
+5f7c72e72f8ce44962a27ee24405c52348d1f38e jdk8u112-b07
+f3d512b7322957a8714f04f2d4714065ebca15f6 jdk8u112-b08
+92dbc9db48db7d3f61b1af0d1f8139257c6ae497 jdk8u112-b09
+29aaa22088eeff4e87fccc88318c088a95e2ab35 jdk8u112-b10
+c6d719a4fcd78b692f70f49daf83bf7610f5e0bc jdk8u112-b11
+bb36d2dbebb7d4ebb4de8e666f00187eca81efd9 jdk8u112-b12
+abb5568d79259d63bf349abf7f5e7461eddc2b40 jdk8u112-b13
+14fa3ed278a279dc85c150bf54b2ec4fa29cf347 jdk8u112-b14
+5f84e87f91d5bc36ed026b88d183821e5109d730 jdk8u112-b15
+d82dd7a24a496e26987caa328d1fb4fc794a4770 jdk8u112-b16
+021da5d50285a523d4622a727ea1a7019f2b52e4 jdk8u112-b31
+452662a83e5bc6dc7e9425ddd10f6c8fc98d50d8 jdk8u121-b00
+9cd16be39ca6f2c8f7cc99ad07a77bb9d0696c75 jdk8u121-b01
+f092b9a890ceeca4a2f4d55cf7d6f3f113cdb462 jdk8u121-b02
+c1b0f76c9fe9657d3f5cdd1e23bfd1d499018431 jdk8u121-b03
+44674172423a0d361466e34eedcaec18a8810b13 jdk8u121-b04
+18da635b5919a0b7cdde8573a0d502efdbf3673e jdk8u121-b05
+5b76a2126855f8949ab8fbadfa3ee2f29da9c21c jdk8u121-b06
+f10aa5b29848eab891bdd173540d91fd31f9ff20 jdk8u121-b07
+105d3bbf5e3b2b24da665b332d2dbf44980c87f2 jdk8u121-b08
+9f2588382771f855c4450f59b470d069a1cb1d01 jdk8u121-b09
+c317f0eacd602a8765d25b0fcd382f76af3697a5 jdk8u121-b10
+89aa912be940d6c30f59b80c826f212541912a56 jdk8u121-b11
+52b3f9fb54ee4304a9c34a2fe07f0c9a49472185 jdk8u121-b12
+5b8834cc3bb9e24153319c766e04e194945a61b9 jdk8u121-b13
+ea4b3e983ee708f9323d228044176e52526e9e13 jdk8u122-b00
+2e7f62568785adfe695e0c06f2e88c9d369c3b2c jdk8u122-b01
+b97e1b7f3c92b3e9f75e6aa590e0884c3c3ed33f jdk8u122-b02
+30b5b545a78c0c4fee837664f9c70ef6a2b4f0c1 jdk8u122-b03
+30b5b545a78c0c4fee837664f9c70ef6a2b4f0c1 jdk8u122-b03
+0000000000000000000000000000000000000000 jdk8u122-b03
+0000000000000000000000000000000000000000 jdk8u122-b03
+a127c3268266ba1402343d94c7b19355c2dd1bd7 jdk8u122-b03
+c48501ec74b9b03870b473e5bde656fce230fc36 jdk8u122-b04
+f3b3163dda3c6da9339dba99a2ee74645ad2edc6 jdk8u132-b00
+55cb39946f2f163085ca80413b8cd3b3e196e533 jdk8u152-b00
+cf960a33b0e3093abcb48bfe304d471e3b092dc4 jdk8u152-b01
diff --git a/ASSEMBLY_EXCEPTION b/ASSEMBLY_EXCEPTION
index 8b7ac1d0..065b8d90 100644
--- a/ASSEMBLY_EXCEPTION
+++ b/ASSEMBLY_EXCEPTION
@@ -1,27 +1,27 @@
OPENJDK ASSEMBLY EXCEPTION
-The OpenJDK source code made available by Sun at openjdk.java.net and
-openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the
-GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
+The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
+openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
+General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code
is making a combined work based on this library. Thus, the terms
and conditions of GPL2 cover the whole combination.
- As a special exception, Sun gives you permission to link this
- OpenJDK Code with certain code licensed by Sun as indicated at
+ As a special exception, Oracle gives you permission to link this
+ OpenJDK Code with certain code licensed by Oracle as indicated at
http://openjdk.java.net/legal/exception-modules-2007-05-08.html
("Designated Exception Modules") to produce an executable,
regardless of the license terms of the Designated Exception Modules,
and to copy and distribute the resulting executable under GPL2,
provided that the Designated Exception Modules continue to be
- governed by the licenses under which they were offered by Sun.
+ governed by the licenses under which they were offered by Oracle.
-As such, it allows licensees and sublicensees of Sun's GPL2 OpenJDK Code to
-build an executable that includes those portions of necessary code that Sun
-could not provide under GPL2 (or that Sun has provided under GPL2 with the
-Classpath exception). If you modify or add to the OpenJDK code, that new
-GPL2 code may still be combined with Designated Exception Modules if the
-new code is made subject to this exception by its copyright holder.
+As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
+to build an executable that includes those portions of necessary code that
+Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
+with the Classpath exception). If you modify or add to the OpenJDK code,
+that new GPL2 code may still be combined with Designated Exception Modules
+if the new code is made subject to this exception by its copyright holder.
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java
index 034629e8..bd6727f0 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/DetailImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -47,13 +47,13 @@ public abstract class DetailImpl extends FaultElementImpl implements Detail {
public DetailEntry addDetailEntry(Name name) throws SOAPException {
DetailEntry entry = createDetailEntry(name);
addNode(entry);
- return (DetailEntry) circumventBug5034339(entry);
+ return entry;
}
public DetailEntry addDetailEntry(QName qname) throws SOAPException {
DetailEntry entry = createDetailEntry(qname);
addNode(entry);
- return (DetailEntry) circumventBug5034339(entry);
+ return entry;
}
protected SOAPElement addElement(Name name) throws SOAPException {
@@ -119,28 +119,4 @@ public abstract class DetailImpl extends FaultElementImpl implements Detail {
return true;
}
- //overriding this method since the only two uses of this method
- // are in ElementImpl and DetailImpl
- //whereas the original base impl does the correct job for calls to it inside ElementImpl
- // But it would not work for DetailImpl.
- protected SOAPElement circumventBug5034339(SOAPElement element) {
-
- Name elementName = element.getElementName();
- if (!isNamespaceQualified(elementName)) {
- String prefix = elementName.getPrefix();
- String defaultNamespace = getNamespaceURI(prefix);
- if (defaultNamespace != null) {
- Name newElementName =
- NameImpl.create(
- elementName.getLocalName(),
- elementName.getPrefix(),
- defaultNamespace);
- SOAPElement newElement = createDetailEntry(newElementName);
- replaceChild(newElement, element);
- return newElement;
- }
- }
- return element;
- }
-
}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
index fc2dcfee..6b833370 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/impl/ElementImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -127,8 +127,11 @@ public class ElementImpl
}
public SOAPElement addChildElement(String localName) throws SOAPException {
- return (SOAPElement) addChildElement(
- NameImpl.createFromUnqualifiedName(localName));
+ String nsUri = getNamespaceURI("");
+ Name name = (nsUri == null || nsUri.isEmpty())
+ ? NameImpl.createFromUnqualifiedName(localName)
+ : NameImpl.createFromQualifiedName(localName, nsUri);
+ return addChildElement(name);
}
public SOAPElement addChildElement(String localName, String prefix)
@@ -372,13 +375,13 @@ public class ElementImpl
protected SOAPElement addElement(Name name) throws SOAPException {
SOAPElement newElement = createElement(name);
addNode(newElement);
- return circumventBug5034339(newElement);
+ return newElement;
}
protected SOAPElement addElement(QName name) throws SOAPException {
SOAPElement newElement = createElement(name);
addNode(newElement);
- return circumventBug5034339(newElement);
+ return newElement;
}
protected SOAPElement createElement(Name name) {
@@ -1201,26 +1204,6 @@ public class ElementImpl
return !"".equals(name.getNamespaceURI());
}
- protected SOAPElement circumventBug5034339(SOAPElement element) {
-
- Name elementName = element.getElementName();
- if (!isNamespaceQualified(elementName)) {
- String prefix = elementName.getPrefix();
- String defaultNamespace = getNamespaceURI(prefix);
- if (defaultNamespace != null) {
- Name newElementName =
- NameImpl.create(
- elementName.getLocalName(),
- elementName.getPrefix(),
- defaultNamespace);
- SOAPElement newElement = createElement(newElementName);
- replaceChild(newElement, element);
- return newElement;
- }
- }
- return element;
- }
-
//TODO: This is a temporary SAAJ workaround for optimizing XWS
// should be removed once the corresponding JAXP bug is fixed
// It appears the bug will be fixed in JAXP 1.4 (not by Appserver 9 timeframe)
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java
index 6414593f..f1ed6979 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, 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,8 +25,10 @@
package com.sun.xml.internal.ws.api.message.saaj;
-import java.util.Arrays;
import java.util.Iterator;
+import java.util.Arrays;
+import java.util.List;
+import java.util.LinkedList;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
@@ -42,6 +44,17 @@ import org.w3c.dom.Node;
/**
* SaajStaxWriter builds a SAAJ SOAPMessage by using XMLStreamWriter interface.
*
+ * <p>
+ * Defers creation of SOAPElement until all the aspects of the name of the element are known.
+ * In some cases, the namespace uri is indicated only by the {@link #writeNamespace(String, String)} call.
+ * After opening an element ({@code writeStartElement}, {@code writeEmptyElement} methods), all attributes
+ * and namespace assignments are retained within {@link DeferredElement} object ({@code deferredElement} field).
+ * As soon as any other method than {@code writeAttribute}, {@code writeNamespace}, {@code writeDefaultNamespace}
+ * or {@code setNamespace} is called, the contents of {@code deferredElement} is transformed into new SOAPElement
+ * (which is appropriately inserted into the SOAPMessage under construction).
+ * This mechanism is necessary to fix JDK-8159058 issue.
+ * </p>
+ *
* @author shih-chang.chen@oracle.com
*/
public class SaajStaxWriter implements XMLStreamWriter {
@@ -49,6 +62,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
protected SOAPMessage soap;
protected String envURI;
protected SOAPElement currentElement;
+ protected DeferredElement deferredElement;
static final protected String Envelope = "Envelope";
static final protected String Header = "Header";
@@ -59,6 +73,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
soap = msg;
currentElement = soap.getSOAPPart().getEnvelope();
envURI = currentElement.getNamespaceURI();
+ this.deferredElement = new DeferredElement();
}
public SOAPMessage getSOAPMessage() {
@@ -67,11 +82,8 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeStartElement(final String localName) throws XMLStreamException {
- try {
- currentElement = currentElement.addChildElement(localName);
- } catch (SOAPException e) {
- throw new XMLStreamException(e);
- }
+ currentElement = deferredElement.flushTo(currentElement);
+ deferredElement.setLocalName(localName);
}
@Override
@@ -81,8 +93,10 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeStartElement(final String prefix, final String ln, final String ns) throws XMLStreamException {
- try {
- if (envURI.equals(ns)) {
+ currentElement = deferredElement.flushTo(currentElement);
+
+ if (envURI.equals(ns)) {
+ try {
if (Envelope.equals(ln)) {
currentElement = soap.getSOAPPart().getEnvelope();
fixPrefix(prefix);
@@ -96,13 +110,16 @@ public class SaajStaxWriter implements XMLStreamWriter {
fixPrefix(prefix);
return;
}
+ } catch (SOAPException e) {
+ throw new XMLStreamException(e);
}
- currentElement = (prefix == null) ?
- currentElement.addChildElement(new QName(ns, ln)) :
- currentElement.addChildElement(ln, prefix, ns);
- } catch (SOAPException e) {
- throw new XMLStreamException(e);
+
}
+
+ deferredElement.setLocalName(ln);
+ deferredElement.setNamespaceUri(ns);
+ deferredElement.setPrefix(prefix);
+
}
private void fixPrefix(final String prfx) throws XMLStreamException {
@@ -129,11 +146,13 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeEndElement() throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
if (currentElement != null) currentElement = currentElement.getParentElement();
}
@Override
public void writeEndDocument() throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
}
@Override
@@ -151,19 +170,14 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException {
- try {
- if (ns == null) {
- if (prefix == null && xmlns.equals(ln)) {
- currentElement.addNamespaceDeclaration("", value);
- } else {
- currentElement.setAttributeNS("", ln, value);
- }
+ if (ns == null && prefix == null && xmlns.equals(ln)) {
+ writeNamespace("", value);
+ } else {
+ if (deferredElement.isInitialized()) {
+ deferredElement.addAttribute(prefix, ns, ln, value);
} else {
- QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix);
- currentElement.addAttribute(name, value);
+ addAttibuteToElement(currentElement, prefix, ns, ln, value);
}
- } catch (SOAPException e) {
- throw new XMLStreamException(e);
}
}
@@ -174,16 +188,16 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeNamespace(String prefix, final String uri) throws XMLStreamException {
-
// make prefix default if null or "xmlns" (according to javadoc)
- if (prefix == null || "xmlns".equals(prefix)) {
- prefix = "";
- }
-
- try {
- currentElement.addNamespaceDeclaration(prefix, uri);
- } catch (SOAPException e) {
- throw new XMLStreamException(e);
+ String thePrefix = prefix == null || "xmlns".equals(prefix) ? "" : prefix;
+ if (deferredElement.isInitialized()) {
+ deferredElement.addNamespaceDeclaration(thePrefix, uri);
+ } else {
+ try {
+ currentElement.addNamespaceDeclaration(thePrefix, uri);
+ } catch (SOAPException e) {
+ throw new XMLStreamException(e);
+ }
}
}
@@ -194,35 +208,40 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeComment(final String data) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
Comment c = soap.getSOAPPart().createComment(data);
currentElement.appendChild(c);
}
@Override
public void writeProcessingInstruction(final String target) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
Node n = soap.getSOAPPart().createProcessingInstruction(target, "");
currentElement.appendChild(n);
}
@Override
public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
Node n = soap.getSOAPPart().createProcessingInstruction(target, data);
currentElement.appendChild(n);
}
@Override
public void writeCData(final String data) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
Node n = soap.getSOAPPart().createCDATASection(data);
currentElement.appendChild(n);
}
@Override
public void writeDTD(final String dtd) throws XMLStreamException {
- //TODO ... Don't do anything here
+ currentElement = deferredElement.flushTo(currentElement);
}
@Override
public void writeEntityRef(final String name) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
Node n = soap.getSOAPPart().createEntityReference(name);
currentElement.appendChild(n);
}
@@ -250,6 +269,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeCharacters(final String text) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
try {
currentElement.addTextNode(text);
} catch (SOAPException e) {
@@ -259,6 +279,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException {
+ currentElement = deferredElement.flushTo(currentElement);
char[] chr = (start == 0 && len == text.length) ? text : Arrays.copyOfRange(text, start, start + len);
try {
currentElement.addTextNode(new String(chr));
@@ -274,10 +295,16 @@ public class SaajStaxWriter implements XMLStreamWriter {
@Override
public void setPrefix(final String prefix, final String uri) throws XMLStreamException {
- try {
- this.currentElement.addNamespaceDeclaration(prefix, uri);
- } catch (SOAPException e) {
- throw new XMLStreamException(e);
+ // TODO: this in fact is not what would be expected from XMLStreamWriter
+ // (e.g. XMLStreamWriter for writing to output stream does not write anything as result of
+ // this method, it just rememebers that given prefix is associated with the given uri
+ // for the scope; to actually declare the prefix assignment in the resulting XML, one
+ // needs to call writeNamespace(...) method
+ // Kept for backwards compatibility reasons - this might be worth of further investigation.
+ if (deferredElement.isInitialized()) {
+ deferredElement.addNamespaceDeclaration(prefix, uri);
+ } else {
+ throw new XMLStreamException("Namespace not associated with any element");
}
}
@@ -308,12 +335,12 @@ public class SaajStaxWriter implements XMLStreamWriter {
return currentElement.lookupPrefix(namespaceURI);
}
public Iterator getPrefixes(final String namespaceURI) {
- return new Iterator() {
+ return new Iterator<String>() {
String prefix = getPrefix(namespaceURI);
public boolean hasNext() {
return (prefix != null);
}
- public Object next() {
+ public String next() {
if (!hasNext()) throw new java.util.NoSuchElementException();
String next = prefix;
prefix = null;
@@ -324,4 +351,209 @@ public class SaajStaxWriter implements XMLStreamWriter {
}
};
}
+
+ static void addAttibuteToElement(SOAPElement element, String prefix, String ns, String ln, String value)
+ throws XMLStreamException {
+ try {
+ if (ns == null) {
+ element.setAttributeNS("", ln, value);
+ } else {
+ QName name = prefix == null ? new QName(ns, ln) : new QName(ns, ln, prefix);
+ element.addAttribute(name, value);
+ }
+ } catch (SOAPException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ /**
+ * Holds details of element that needs to be deferred in order to manage namespace assignments correctly.
+ *
+ * <p>
+ * An instance of can be set with all the aspects of the element name (local name, prefix, namespace uri).
+ * Attributes and namespace declarations (special case of attribute) can be added.
+ * Namespace declarations are handled so that the element namespace is updated if it is implied by the namespace
+ * declaration and the namespace was not set to non-{@code null} value previously.
+ * </p>
+ *
+ * <p>
+ * The state of this object can be {@link #flushTo(SOAPElement) flushed} to SOAPElement - new SOAPElement will
+ * be added a child element; the new element will have exactly the shape as represented by the state of this
+ * object. Note that the {@link #flushTo(SOAPElement)} method does nothing
+ * (and returns the argument immediately) if the state of this object is not initialized
+ * (i.e. local name is null).
+ * </p>
+ *
+ * @author ondrej.cerny@oracle.com
+ */
+ static class DeferredElement {
+ private String prefix;
+ private String localName;
+ private String namespaceUri;
+ private final List<NamespaceDeclaration> namespaceDeclarations;
+ private final List<AttributeDeclaration> attributeDeclarations;
+
+ DeferredElement() {
+ this.namespaceDeclarations = new LinkedList<NamespaceDeclaration>();
+ this.attributeDeclarations = new LinkedList<AttributeDeclaration>();
+ reset();
+ }
+
+
+ /**
+ * Set prefix of the element.
+ * @param prefix namespace prefix
+ */
+ public void setPrefix(final String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Set local name of the element.
+ *
+ * <p>
+ * This method initializes the element.
+ * </p>
+ *
+ * @param localName local name {@code not null}
+ */
+ public void setLocalName(final String localName) {
+ if (localName == null) {
+ throw new IllegalArgumentException("localName can not be null");
+ }
+ this.localName = localName;
+ }
+
+ /**
+ * Set namespace uri.
+ *
+ * @param namespaceUri namespace uri
+ */
+ public void setNamespaceUri(final String namespaceUri) {
+ this.namespaceUri = namespaceUri;
+ }
+
+ /**
+ * Adds namespace prefix assignment to the element.
+ *
+ * @param prefix prefix (not {@code null})
+ * @param namespaceUri namespace uri
+ */
+ public void addNamespaceDeclaration(final String prefix, final String namespaceUri) {
+ if (null == this.namespaceUri && null != namespaceUri && prefix.equals(emptyIfNull(this.prefix))) {
+ this.namespaceUri = namespaceUri;
+ }
+ this.namespaceDeclarations.add(new NamespaceDeclaration(prefix, namespaceUri));
+ }
+
+ /**
+ * Adds attribute to the element.
+ * @param prefix prefix
+ * @param ns namespace
+ * @param ln local name
+ * @param value value
+ */
+ public void addAttribute(final String prefix, final String ns, final String ln, final String value) {
+ if (ns == null && prefix == null && xmlns.equals(ln)) {
+ this.addNamespaceDeclaration(prefix, value);
+ } else {
+ this.attributeDeclarations.add(new AttributeDeclaration(prefix, ns, ln, value));
+ }
+ }
+
+ /**
+ * Flushes state of this element to the {@code target} element.
+ *
+ * <p>
+ * If this element is initialized then it is added with all the namespace declarations and attributes
+ * to the {@code target} element as a child. The state of this element is reset to uninitialized.
+ * The newly added element object is returned.
+ * </p>
+ * <p>
+ * If this element is not initialized then the {@code target} is returned immediately, nothing else is done.
+ * </p>
+ *
+ * @param target target element
+ * @return {@code target} or new element
+ * @throws XMLStreamException on error
+ */
+ public SOAPElement flushTo(final SOAPElement target) throws XMLStreamException {
+ try {
+ if (this.localName != null) {
+ // add the element appropriately (based on namespace declaration)
+ final SOAPElement newElement;
+ if (this.namespaceUri == null) {
+ // add element with inherited scope
+ newElement = target.addChildElement(this.localName);
+ } else if (prefix == null) {
+ newElement = target.addChildElement(new QName(this.namespaceUri, this.localName));
+ } else {
+ newElement = target.addChildElement(this.localName, this.prefix, this.namespaceUri);
+ }
+ // add namespace declarations
+ for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
+ target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
+ }
+ // add attribute declarations
+ for (AttributeDeclaration attribute : this.attributeDeclarations) {
+ addAttibuteToElement(newElement,
+ attribute.prefix, attribute.namespaceUri, attribute.localName, attribute.value);
+ }
+ // reset state
+ this.reset();
+
+ return newElement;
+ } else {
+ return target;
+ }
+ // else after reset state -> not initialized
+ } catch (SOAPException e) {
+ throw new XMLStreamException(e);
+ }
+ }
+
+ /**
+ * Is the element initialized?
+ * @return boolean indicating whether it was initialized after last flush
+ */
+ public boolean isInitialized() {
+ return this.localName != null;
+ }
+
+ private void reset() {
+ this.localName = null;
+ this.prefix = null;
+ this.namespaceUri = null;
+ this.namespaceDeclarations.clear();
+ this.attributeDeclarations.clear();
+ }
+
+ private static String emptyIfNull(String s) {
+ return s == null ? "" : s;
+ }
+ }
+
+ static class NamespaceDeclaration {
+ final String prefix;
+ final String namespaceUri;
+
+ NamespaceDeclaration(String prefix, String namespaceUri) {
+ this.prefix = prefix;
+ this.namespaceUri = namespaceUri;
+ }
+ }
+
+ static class AttributeDeclaration {
+ final String prefix;
+ final String namespaceUri;
+ final String localName;
+ final String value;
+
+ AttributeDeclaration(String prefix, String namespaceUri, String localName, String value) {
+ this.prefix = prefix;
+ this.namespaceUri = namespaceUri;
+ this.localName = localName;
+ this.value = value;
+ }
+ }
}
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java
index a16ec36b..a579a3c7 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/server/ServerMgr.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -81,24 +81,37 @@ final class ServerMgr {
synchronized(servers) {
state = servers.get(inetAddress);
if (state == null) {
- logger.fine("Creating new HTTP Server at "+inetAddress);
- // Creates server with default socket backlog
- server = HttpServer.create(inetAddress, 0);
- server.setExecutor(Executors.newCachedThreadPool());
- String path = url.toURI().getPath();
- logger.fine("Creating HTTP Context at = "+path);
- HttpContext context = server.createContext(path);
- server.start();
-
- // we have to get actual inetAddress from server, which can differ from the original in some cases.
- // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
- // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
- inetAddress = server.getAddress();
-
- logger.fine("HTTP server started = "+inetAddress);
- state = new ServerState(server, path);
- servers.put(inetAddress, state);
- return context;
+ final int finalPortNum = port;
+ for (ServerState s: servers.values()) {
+ if (s.getServer()
+ .getAddress()
+ .getPort() == finalPortNum) {
+ state = s;
+ break;
+ }
+ }
+
+ if (!inetAddress.getAddress().isAnyLocalAddress() ||
+ state == null) {
+ logger.fine("Creating new HTTP Server at "+inetAddress);
+ // Creates server with default socket backlog
+ server = HttpServer.create(inetAddress, 0);
+ server.setExecutor(Executors.newCachedThreadPool());
+ String path = url.toURI().getPath();
+ logger.fine("Creating HTTP Context at = "+path);
+ HttpContext context = server.createContext(path);
+ server.start();
+
+ // we have to get actual inetAddress from server, which can differ from the original in some cases.
+ // e.g. A port number of zero will let the system pick up an ephemeral port in a bind operation,
+ // or IP: 0.0.0.0 - which is used to monitor network traffic from any valid IP address
+ inetAddress = server.getAddress();
+
+ logger.fine("HTTP server started = "+inetAddress);
+ state = new ServerState(server, path);
+ servers.put(inetAddress, state);
+ return context;
+ }
}
}
server = state.getServer();