[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16137043#comment-16137043
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user asfgit closed the pull request at:

https://github.com/apache/geode/pull/668


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto the parse stack, thus causing the problem.
> These StringBuffers were created and pushed by the {{characters()}} method 
> (https://github.com/apache/geode/blob/develop/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java#L3270).
>  Changing the log level to {{TRACE}} and examining the parse stack showed 
> that these StringBuffers contained the whitespace (including newlines) 
> between the XML tags in {{cache.xml}}.
> When using the Oracle JDK's version of Xerces, these StringBuffers did not 
> appear on the parse stack despite the whitespace.
> I have a proof of concept on GitHub: 
> https://github.com/darrenfoong/geode-parser-poc The {{cache.xml}} file 
> without whitespace between the tags was parsed without errors by both 
> versions of Xerces.
> It could be the case that the JDK Xerces strips out whitespace while Apache 
> Xerces doesn't; but this could be implemented in {{characters()}} by only 
> pushing non-whitespace char arrays in the {{else}} block. However, 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16124826#comment-16124826
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user darrenfoong commented on the issue:

https://github.com/apache/geode/pull/668
  
Thanks Jared! Will find time to make the changes and get feedback on the 
mailing list.


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto the parse stack, thus causing the problem.
> These StringBuffers were created and pushed by the {{characters()}} method 
> (https://github.com/apache/geode/blob/develop/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java#L3270).
>  Changing the log level to {{TRACE}} and examining the parse stack showed 
> that these StringBuffers contained the whitespace (including newlines) 
> between the XML tags in {{cache.xml}}.
> When using the Oracle JDK's version of Xerces, these StringBuffers did not 
> appear on the parse stack despite the whitespace.
> I have a proof of concept on GitHub: 
> https://github.com/darrenfoong/geode-parser-poc The {{cache.xml}} file 
> without whitespace between the tags was parsed without errors by both 
> versions of Xerces.
> It could be the case that the JDK Xerces strips out whitespace while Apache 
> Xerces doesn't; but this could be implemented 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16124825#comment-16124825
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user darrenfoong commented on a diff in the pull request:

https://github.com/apache/geode/pull/668#discussion_r132833299
  
--- Diff: 
geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
 ---
@@ -111,10 +113,31 @@ public void testCacheXmlParserWithSimplePool() {
 InternalDistributedSystem system =
 InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
 when(dm.getSystem()).thenReturn(system);
-InternalDistributedSystem.connect(nonDefault);
 
-CacheXmlParser.parse(getClass()
-
.getResourceAsStream("CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml"));
+Cache cache = new CacheFactory()
+.set("cache-xml-file", 
"CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml")
+.create(InternalDistributedSystem.connect(nonDefault));
+cache.close();
+  }
+
+  /**
+   * Test that {@link CacheXmlParser} can parse the test cache.xml file, 
using the Apache Xerces XML
+   * parser.
+   * 
+   * @since Geode 1.3
+   */
+  @Test
+  public void testCacheXmlParserWithSimplePoolXerces() {
+String prevParserFactory = 
System.setProperty("javax.xml.parsers.SAXParserFactory",
+"org.apache.xerces.jaxp.SAXParserFactoryImpl");
+
+testCacheXmlParserWithSimplePool();
+
+if (prevParserFactory != null) {
--- End diff --

Thanks Jared! Will find time to make the changes and get feedback on the 
mailing list.


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-08 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16118628#comment-16118628
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user jaredjstewart commented on a diff in the pull request:

https://github.com/apache/geode/pull/668#discussion_r131968121
  
--- Diff: 
geode-core/src/test/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParserJUnitTest.java
 ---
@@ -111,10 +113,31 @@ public void testCacheXmlParserWithSimplePool() {
 InternalDistributedSystem system =
 InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
 when(dm.getSystem()).thenReturn(system);
-InternalDistributedSystem.connect(nonDefault);
 
-CacheXmlParser.parse(getClass()
-
.getResourceAsStream("CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml"));
+Cache cache = new CacheFactory()
+.set("cache-xml-file", 
"CacheXmlParserJUnitTest.testSimpleClientCacheXml.cache.xml")
+.create(InternalDistributedSystem.connect(nonDefault));
+cache.close();
+  }
+
+  /**
+   * Test that {@link CacheXmlParser} can parse the test cache.xml file, 
using the Apache Xerces XML
+   * parser.
+   * 
+   * @since Geode 1.3
+   */
+  @Test
+  public void testCacheXmlParserWithSimplePoolXerces() {
+String prevParserFactory = 
System.setProperty("javax.xml.parsers.SAXParserFactory",
+"org.apache.xerces.jaxp.SAXParserFactoryImpl");
+
+testCacheXmlParserWithSimplePool();
+
+if (prevParserFactory != null) {
--- End diff --

This cleanup of system properties can be made simpler by using the 
`RestoreSystemProperties` JUnit rule.  All you need to do is add this member 
variable to your test class: 

```  @Rule
  public final RestoreSystemProperties restoreSystemProperties = new 
RestoreSystemProperties();
```

(For an example, see 
[LocatorLauncherTest](https://github.com/apache/geode/blob/d1db2f02d2ce45a437b34488934e5b1d53c7b5ca/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java).)


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-08 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16118627#comment-16118627
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user jaredjstewart commented on a diff in the pull request:

https://github.com/apache/geode/pull/668#discussion_r131967266
  
--- Diff: 
geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java
 ---
@@ -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("")) {
--- End diff --

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


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto the parse stack, thus causing the problem.
> These StringBuffers were created and pushed by the {{characters()}} method 
> 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16115264#comment-16115264
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user darrenfoong commented on the issue:

https://github.com/apache/geode/pull/668
  
Hi Jared, thank you for your feedback.

The initial use case that I was thinking of involved a user wanting to:

- use Geode with another JDK (which doesn't have the 
`com.sun.org.apache...` Xerces implementation that the Oracle JDK uses), or
- use Geode in an application where he/she wants to use the Apache Xerces 
implementation (which will be a dependency of the application) and sets the 
system property `javax.xml.parsers.SAXParserFactory` to 
`org.apache.xerces.jaxp.SAXParserFactoryImpl`.

In these cases `xercesImpl` is part of the environment (JDK, app) so I 
chose to use `xercesImpl` at only test runtime and "load" it via 
`System.setProperty()` in my unit tests.

I don't see why it's needed at test compile time and I don't really 
understand your point about people building with (and I presume, for) a JDK 
that doesn't include Xerces: in that case, shouldn't `xercesImpl` be a 
dependency for `main` too?

I do symphatise with Xerces hell though!


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16114778#comment-16114778
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user jaredjstewart commented on the issue:

https://github.com/apache/geode/pull/668
  
Hi Darren,

It looks like `xercesImpl` may need to be declared as a `testCompile` 
dependency rather than `testRuntime` in case people are building with a JDK 
which does not include Xerxes.  I also think it would be prudent to solicit 
feedback from the community via d...@geode.apache.org before we add this 
library, since I know that Xerces can sometimes be troublesome.  (See e.g. 
https://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven)
   

Thank you,
Jared Stewart


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto the parse stack, thus causing the problem.
> These StringBuffers were created and pushed by the {{characters()}} method 
> (https://github.com/apache/geode/blob/develop/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java#L3270).
>  Changing the log level to {{TRACE}} and examining the parse stack showed 
> that these StringBuffers contained the whitespace (including newlines) 
> between the XML tags in {{cache.xml}}.
> When using the Oracle JDK's 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-08-03 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16112998#comment-16112998
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

Github user darrenfoong commented on the issue:

https://github.com/apache/geode/pull/668
  
I just realised I'll need to unset the property to prevent any side effects 
in the other tests; working on it now.


> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: management
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
>   at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
>   at server.ServerWhitespace.main(ServerWhitespace.java:8)
> {noformat}
> However, this does not happen when I don't use Apache Xerces, i.e. I rely on 
> the version in the Oracle JDK (1.8).
> After getting the Geode source code and stepping through the parsing using 
> the Eclipse debugger, I realised that there were unexpected StringBuffers 
> pushed onto the parse stack, thus causing the problem.
> These StringBuffers were created and pushed by the {{characters()}} method 
> (https://github.com/apache/geode/blob/develop/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlParser.java#L3270).
>  Changing the log level to {{TRACE}} and examining the parse stack showed 
> that these StringBuffers contained the whitespace (including newlines) 
> between the XML tags in {{cache.xml}}.
> When using the Oracle JDK's version of Xerces, these StringBuffers did not 
> appear on the parse stack despite the whitespace.
> I have a proof of concept on GitHub: 
> https://github.com/darrenfoong/geode-parser-poc The {{cache.xml}} file 
> without whitespace between the tags was parsed without errors by both 
> versions of Xerces.
> It could be the case that the JDK Xerces strips out whitespace while Apache 
> Xerces doesn't; but 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-07-29 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16106199#comment-16106199
 ] 

ASF GitHub Bot commented on GEODE-3306:
---

GitHub user darrenfoong opened a pull request:

https://github.com/apache/geode/pull/668

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

…erces

This commit makes Geode compatible with the official Apache Xerces
implementation, which calls `characters()` when it reads ignorable
whitespace in `cache.xml`.

The while loop is required to handle comments in `cache.xml`, i.e.
a comment with whitespace before and after will generate two
empty StringBuffers (one for each set of whitespace before and after)
on the parse stack. The while loop removes all "consecutive" whitespace
StringBuffers from the top of the stack.

---

Tested with 
https://github.com/darrenfoong/geode-parser-poc/blob/master/src/test/java/server/ServerTest.java

---

Thank you for submitting a contribution to Apache Geode.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced in 
the commit message?

- [x] Has your PR been rebased against the latest commit within the target 
branch (typically `develop`)?

- [x] Is your initial contribution a single, squashed commit?

- [x] Does `gradlew build` run cleanly?

- [ ] Have you written or updated unit tests to verify your changes?

- [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and
submit an update to your PR as soon as possible. If you need help, please 
send an
email to d...@geode.apache.org.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/darrenfoong/geode df-GEODE-3306

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/geode/pull/668.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #668


commit d742c9bb2dc672be4ec01a98423989795748f0d8
Author: Darren Foong 
Date:   2017-07-29T17:52:37Z

GEODE-3306: Remove whitespace StringBuffers/nodes created by Apache Xerces

This commit makes Geode compatible with the official Apache Xerces
implementation, which calls `characters()` when it reads ignorable
whitespace in `cache.xml`.

The while loop is required to handle comments in `cache.xml`, i.e.
a comment with whitespace before and after will generate two
empty StringBuffers (one for each set of whitespace before and after)
on the parse stack. The while loop removes all "consecutive" whitespace
StringBuffers from the top of the stack.




> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> 

[jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces

2017-07-28 Thread Darren Foong (JIRA)

[ 
https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16105269#comment-16105269
 ] 

Darren Foong commented on GEODE-3306:
-

After more investigation, I realise that the Apache Xerces parser doesn't call 
the {{ignorableWhitespace()}} method, but calls the {{characters()}} method 
instead. On the other hand, the JDK Xerces calls the {{ignorableWhitespace()}} 
method, thus not calling the {{characters()}} method and consequently not 
pushing any whitespace StringBuffers on the stack.

Long story short, it seems that the JDK Xerces doesn't strictly conform to the 
SAX specification (https://xerces.apache.org/xerces2-j/faq-sax.html#faq-3), 
because it's calling {{ignorableWhitespace()}} despite the XML file having no 
DTD.

Implementing a fix is more complicated than I had thought: one approach is to 
maintain a parallel stack of whether the state is "inside" or "outside" of an 
element, thus allowing us to determine if any StringBuffers are whitespace 
("outside") or content ("inside"). This would require adding one line to all 
the {{startX()}} and {{endX()}} methods.

Another workaround would be to use the JDK Xerces for Geode by setting a system 
property ({{javax.xml.parsers.SAXParserFactory}}) and then setting it back to 
the Apache Xerces implementation for non-Geode work. For those who are facing 
this issue because they are using some other JDK, they can download the Oracle 
JDK internal Xerces from Maven Central 
(http://central.maven.org/maven2/com/sun/xml/parsers/jaxp-ri/).

Lastly (for completeness), there's also the workaround mentioned before: simply 
remove all ignorable whitespace manually in the XML file, so the underlying 
parser never has to deal with ignorable whitespace.

> Parsing of cache.xml with whitespace fails with Apache Xerces
> -
>
> Key: GEODE-3306
> URL: https://issues.apache.org/jira/browse/GEODE-3306
> Project: Geode
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.2.0
>Reporter: Darren Foong
>Priority: Minor
> Fix For: 1.2.0
>
>
> I am using Geode 1.2.0 and Apache Xerces 2.11.0 (not the one included in the 
> Oracle JDK), and I encountered the following error when I tried to 
> programmatically start a cache:
> {noformat}
> org.apache.geode.InternalGemFireError: Did not expected a 
> java.lang.StringBuffer on top of the stack.
> Exception in thread "main" org.apache.geode.InternalGemFireError: Did not 
> expected a java.lang.StringBuffer on top of the stack.
>   at org.apache.geode.internal.Assert.throwError(Assert.java:94)
>   at org.apache.geode.internal.Assert.assertTrue(Assert.java:117)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endRegionAttributes(CacheXmlParser.java:1257)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.endElement(CacheXmlParser.java:2909)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser$DefaultHandlerDelegate.endElement(CacheXmlParser.java:3374)
>   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
> Source)
>   at 
> org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown 
> Source)
>   at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown 
> Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
>  Source)
>   at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown 
> Source)
>   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>   at javax.xml.parsers.SAXParser.parse(SAXParser.java:195)
>   at 
> org.apache.geode.internal.cache.xmlcache.CacheXmlParser.parse(CacheXmlParser.java:224)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.loadCacheXml(GemFireCacheImpl.java:4287)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initializeDeclarativeCache(GemFireCacheImpl.java:1390)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1195)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
>   at 
> org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
>   at