aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoraefimov <none@none>2016-03-29 13:16:00 +0300
committeraefimov <none@none>2016-03-29 13:16:00 +0300
commite7ed9a7d642242e012f3b1eeaf19da640cd5ce91 (patch)
tree6b820a6a28a186633d0406d1a8407146709ee3fa /src
parent06ab85e25392041909046ea06330ed591314f1e4 (diff)
downloadjdk8u_jaxws-e7ed9a7d642242e012f3b1eeaf19da640cd5ce91.tar.gz
8073872: Schemagen fails with StackOverflowError if element references containing class
Reviewed-by: lancea
Diffstat (limited to 'src')
-rw-r--r--src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
index 30c80801..a9cb5bed 100644
--- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
+++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -110,6 +110,7 @@ import com.sun.xml.internal.txw2.TypedXmlWriter;
import com.sun.xml.internal.txw2.output.ResultFactory;
import com.sun.xml.internal.txw2.output.XmlSerializer;
import java.util.Collection;
+import java.util.HashSet;
import org.xml.sax.SAXParseException;
/**
@@ -436,7 +437,7 @@ public final class XmlSchemaGenerator<T,C,F,M> {
if(logger.isLoggable(Level.FINE)) {
// debug logging to see what's going on.
- logger.log(Level.FINE,"Wrigin XML Schema for "+toString(),new StackRecorder());
+ logger.log(Level.FINE,"Writing XML Schema for "+toString(),new StackRecorder());
}
// make it fool-proof
@@ -465,6 +466,8 @@ public final class XmlSchemaGenerator<T,C,F,M> {
systemIds.put(n,output.getSystemId());
}
}
+ //Clear the namespace specific set with already written classes
+ n.resetWritten();
}
// then write'em all
@@ -542,6 +545,11 @@ public final class XmlSchemaGenerator<T,C,F,M> {
*/
private boolean useMimeNs;
+ /**
+ * Container for already processed classes
+ */
+ private final Set<ClassInfo> written = new HashSet<ClassInfo>();
+
public Namespace(String uri) {
this.uri = uri;
assert !XmlSchemaGenerator.this.namespaces.containsKey(uri);
@@ -549,6 +557,13 @@ public final class XmlSchemaGenerator<T,C,F,M> {
}
/**
+ * Clear out the set of already processed classes for this namespace
+ */
+ void resetWritten() {
+ written.clear();
+ }
+
+ /**
* Process the given PropertyInfo looking for references to namespaces that
* are foreign to the given namespace. Any foreign namespace references
* found are added to the given namespaces dependency list and an &lt;import>
@@ -853,6 +868,10 @@ public final class XmlSchemaGenerator<T,C,F,M> {
* @param parent the writer of the parent element into which the type will be defined
*/
private void writeClass(ClassInfo<T,C> c, TypeHost parent) {
+ if (written.contains(c)) { // to avoid cycles let's check if we haven't already processed the class
+ return;
+ }
+ written.add(c);
// special handling for value properties
if (containsValueProp(c)) {
if (c.getProperties().size() == 1) {