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

GEODE-3306: Remove whitespace StringBuffers/nodes created by Apache X… #668

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,18 @@ private void endDeclarable() {

public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
// This while loop pops all StringBuffers at the top of the stack
// that contain only whitespace; see GEODE-3306
while (!stack.empty()) {
Object o = stack.peek();
if (o instanceof StringBuffer
&& ((StringBuffer) o).toString().replaceAll("\\s", "").equals("")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think StringUtils.isBlank( (StringBuffer o).toString()) might be simpler here as well as in endElement.

stack.pop();
} else {
break;
}
}

if (qName.equals(CACHE)) {
startCache(atts);
} else if (qName.equals(CLIENT_CACHE)) {
Expand Down Expand Up @@ -2872,6 +2884,18 @@ private void startDiskWriteAttributes(Attributes atts) {
}

public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
// This while loop pops all StringBuffers at the top of the stack
// that contain only whitespace; see GEODE-3306
while (!stack.empty()) {
Object o = stack.peek();
if (o instanceof StringBuffer
&& ((StringBuffer) o).toString().replaceAll("\\s", "").equals("")) {
stack.pop();
} else {
break;
}
}

try {
// logger.debug("endElement namespaceURI=" + namespaceURI
// + "; localName = " + localName + "; qName = " + qName);
Expand Down