Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 045BF8359 for ; Wed, 7 Sep 2011 14:56:38 +0000 (UTC) Received: (qmail 68446 invoked by uid 500); 7 Sep 2011 14:56:37 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 68393 invoked by uid 500); 7 Sep 2011 14:56:37 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 68384 invoked by uid 99); 7 Sep 2011 14:56:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 14:56:36 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2011 14:56:34 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id EAF70854BF for ; Wed, 7 Sep 2011 14:56:12 +0000 (UTC) Date: Wed, 7 Sep 2011 14:56:12 +0000 (UTC) From: "Ferdy (JIRA)" To: common-issues@hadoop.apache.org Message-ID: <2115123542.25863.1315407372958.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <29616151.25589.1315401730726.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (HADOOP-7614) Reloading configuration when using imputstream resources results in org.xml.sax.SAXParseException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-7614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ferdy updated HADOOP-7614: -------------------------- Attachment: HADOOP-7614-v2.patch Fixed issues with first patch. Also using proper LOG instead of system.out. > Reloading configuration when using imputstream resources results in org.xml.sax.SAXParseException > ------------------------------------------------------------------------------------------------- > > Key: HADOOP-7614 > URL: https://issues.apache.org/jira/browse/HADOOP-7614 > Project: Hadoop Common > Issue Type: Bug > Components: conf > Affects Versions: 0.21.0 > Reporter: Ferdy > Priority: Minor > Attachments: HADOOP-7614-v1.patch, HADOOP-7614-v2.patch > > > When using an inputstream as a resource for configuration, reloading this configuration will throw the following exception: > Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException: Premature end of file. > at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:1576) > at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:1445) > at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:1381) > at org.apache.hadoop.conf.Configuration.get(Configuration.java:569) > ... > Caused by: org.xml.sax.SAXParseException: Premature end of file. > at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249) > at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284) > at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) > at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:1504) > ... 4 more > To reproduce see following testcode: > Configuration conf = new Configuration(); > ByteArrayInputStream bais = new ByteArrayInputStream("".getBytes()); > conf.addResource(bais); > System.out.println(conf.get("blah")); > conf.addResource("core-site.xml"); //just add a named resource, doesn't matter which one > System.out.println(conf.get("blah")); > Allowing inputstream resources is flexible, but in cases such as this in can lead to difficult to debug problems. > What do you think is the best solution? We could: > A) reset the inputstream after it is read instead of closing it (but what to do when the stream does not support marking?) > B) leave it up to the client (for example make sure you implement close() so that it resets the steam) > C) when reading the inputstream for the first time, cache or wrap the contents somehow so that is can be read multiple times (let's at least document it) > D) remove inputstream method altogether > e) something else? > For now I have attached a patch for solution A. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira