Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 02DBD182F4 for ; Wed, 29 Jul 2015 16:47:06 +0000 (UTC) Received: (qmail 30972 invoked by uid 500); 29 Jul 2015 16:47:05 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 30949 invoked by uid 500); 29 Jul 2015 16:47:05 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 30940 invoked by uid 99); 29 Jul 2015 16:47:05 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2015 16:47:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4CB20193889 for ; Wed, 29 Jul 2015 16:47:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 0pGWFbGH12Ke for ; Wed, 29 Jul 2015 16:46:54 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id D5FCA20DD8 for ; Wed, 29 Jul 2015 16:46:53 +0000 (UTC) Received: (qmail 29679 invoked by uid 99); 29 Jul 2015 16:46:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Jul 2015 16:46:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6F1F4DFFEF; Wed, 29 Jul 2015 16:46:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: upthewaterspout@apache.org To: commits@geode.incubator.apache.org Message-Id: <9668d09d5b764d3babfeaa5ef3599cd3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: GEODE-135: Added UnclosableInputStream for SAX parser Date: Wed, 29 Jul 2015 16:46:52 +0000 (UTC) Repository: incubator-geode Updated Branches: refs/heads/develop 94939c1f9 -> 405daf57e GEODE-135: Added UnclosableInputStream for SAX parser This closes #12 In order to block the parser from closing the stream, we wrap the InputStream in a filter, i.e., UnclosableInputStream, whose close() function does nothing. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/405daf57 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/405daf57 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/405daf57 Branch: refs/heads/develop Commit: 405daf57eea94560e5700c026095b837cf823c93 Parents: 94939c1 Author: lzh Authored: Tue Jul 28 13:46:48 2015 -0400 Committer: Dan Smith Committed: Wed Jul 29 09:46:31 2015 -0700 ---------------------------------------------------------------------- .../internal/cache/xmlcache/CacheXmlParser.java | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/405daf57/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java index 9f2cbc0..9b2f5ed 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java @@ -182,13 +182,37 @@ public class CacheXmlParser extends CacheXml implements ContentHandler { * */ public static CacheXmlParser parse(InputStream is) { + + /** + * The API doc + * http://java.sun.com/javase/6/docs/api/org/xml/sax/InputSource.html for + * the SAX InputSource says: "... standard processing of both byte and + * character streams is to close them on as part of end-of-parse cleanup, so + * applications should not attempt to re-use such streams after they have + * been handed to a parser." + * + * In order to block the parser from closing the stream, we wrap the + * InputStream in a filter, i.e., UnclosableInputStream, whose close() + * function does nothing. + * + */ + class UnclosableInputStream extends BufferedInputStream { + public UnclosableInputStream(InputStream stream) { + super(stream); + } + + @Override + public void close() { + } + } + CacheXmlParser handler = new CacheXmlParser(); try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true); factory.setValidating(true); factory.setNamespaceAware(true); - BufferedInputStream bis = new BufferedInputStream(is); + UnclosableInputStream bis = new UnclosableInputStream(is); try { SAXParser parser = factory.newSAXParser(); // Parser always reads one buffer plus a little extra worth before