Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Djaxb.allowNonNillableArray=true #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.logging.Logger;
import java.security.AccessController;

/**
* Finds request/response wrapper and exception bean memebers.
Expand Down Expand Up @@ -212,6 +213,19 @@ public List<A> collectResponseBeanMembers(M method) {
return responseMembers;
}

// When an element is of an array type, the software
// currently sets nillable to true regardless of the value of the
// related annotation. A customer has complained that nillable="false"
// should be allowed for such a type.
//
// Since the current behavior was specifically placed in the code,
// there may be a good reason for it, and we do not want to break
// compatibility.
// Therefore, we are adding a new system property
// -Djaxb.allowNonNillableArray=true
// to implement the behavior requested by the customer.
static final boolean JAXB_ALLOWNONNILLABLEARRAY = getBooleanSystemProperty("jaxb.allowNonNillableArray").booleanValue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Property name should probably start with ‘com.sun.xml.ws...’. Also what is the impact of this change, if one uses MOXy instead of JAXB-RI?


private void processXmlElement(List<Annotation> jaxb, String elemName, String elemNS, T type) {
XmlElement elemAnn = null;
for (Annotation a : jaxb) {
Expand All @@ -227,7 +241,7 @@ private void processXmlElement(List<Annotation> jaxb, String elemName, String el
String ns = (elemAnn != null && !elemAnn.namespace().equals("##default"))
? elemAnn.namespace() : elemNS;

boolean nillable = nav.isArray(type)
boolean nillable = (nav.isArray(type) && !JAXB_ALLOWNONNILLABLEARRAY)
|| (elemAnn != null && elemAnn.nillable());

boolean required = elemAnn != null && elemAnn.required();
Expand Down Expand Up @@ -450,4 +464,15 @@ private static String getPropertyName(String name) {
reservedWords.put("enum", "_enum");
}

// This method is copied from RuntimeModeler.java in the same directory.
private static Boolean getBooleanSystemProperty(final String prop) {
return AccessController.doPrivileged(
new java.security.PrivilegedAction<Boolean>() {
public Boolean run() {
String value = System.getProperty(prop);
return value != null ? Boolean.valueOf(value) : Boolean.FALSE;
}
}
);
}
}