Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 80E93200CE3 for ; Sun, 13 Aug 2017 08:28:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7F39A1647FC; Sun, 13 Aug 2017 06:28:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9F6DE1647D7 for ; Sun, 13 Aug 2017 08:28:06 +0200 (CEST) Received: (qmail 91222 invoked by uid 500); 13 Aug 2017 06:28:05 -0000 Mailing-List: contact issues-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list issues@geode.apache.org Received: (qmail 91213 invoked by uid 99); 13 Aug 2017 06:28:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Aug 2017 06:28:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 44005C02AA for ; Sun, 13 Aug 2017 06:28:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id QDt8lEyRGVpS for ; Sun, 13 Aug 2017 06:28:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id D2F615FB40 for ; Sun, 13 Aug 2017 06:28:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 0032EE00A7 for ; Sun, 13 Aug 2017 06:28:02 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id DC6B22140A for ; Sun, 13 Aug 2017 06:28:00 +0000 (UTC) Date: Sun, 13 Aug 2017 06:28:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@geode.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GEODE-3306) Parsing of cache.xml with whitespace fails with Apache Xerces MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sun, 13 Aug 2017 06:28:07 -0000 [ https://issues.apache.org/jira/browse/GEODE-3306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=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 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, there could be other XML parsing edge cases that I am unaware of. > There should be others who need Apache Xerces for their projects; a fix would be appreciated. -- This message was sent by Atlassian JIRA (v6.4.14#64029)