Return-Path: Delivered-To: apmail-incubator-abdera-commits-archive@locus.apache.org Received: (qmail 61142 invoked from network); 12 May 2008 16:10:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 May 2008 16:10:00 -0000 Received: (qmail 70022 invoked by uid 500); 12 May 2008 16:10:02 -0000 Delivered-To: apmail-incubator-abdera-commits-archive@incubator.apache.org Received: (qmail 69985 invoked by uid 500); 12 May 2008 16:10:02 -0000 Mailing-List: contact abdera-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: abdera-dev@incubator.apache.org Delivered-To: mailing list abdera-commits@incubator.apache.org Received: (qmail 69974 invoked by uid 99); 12 May 2008 16:10:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2008 09:10:02 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 May 2008 16:09:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B038723889FE; Mon, 12 May 2008 09:09:37 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r655544 - /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java Date: Mon, 12 May 2008 16:09:37 -0000 To: abdera-commits@incubator.apache.org From: jmsnell@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080512160937.B038723889FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jmsnell Date: Mon May 12 09:09:37 2008 New Revision: 655544 URL: http://svn.apache.org/viewvc?rev=655544&view=rev Log: https://issues.apache.org/jira/browse/ABDERA-155 Switch to lazy initialization of the various fields in the Abdera class to eliminate the likelihood of race conditions and NPE's in various environments Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java?rev=655544&r1=655543&r2=655544&view=diff ============================================================================== --- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java (original) +++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java Mon May 12 09:09:37 2008 @@ -67,12 +67,12 @@ } private final Configuration config; - private final Factory factory; - private final Parser parser; - private final XPath xpath; - private final ParserFactory parserFactory; - private final WriterFactory writerFactory; - private final Writer writer; + private Factory factory; + private Parser parser; + private XPath xpath; + private ParserFactory parserFactory; + private WriterFactory writerFactory; + private Writer writer; /** * Initialize using the default Abdera Configuration @@ -87,12 +87,6 @@ */ public Abdera(Configuration config) { this.config = config; - factory = newFactory(); - parser = newParser(); - xpath = newXPath(); - parserFactory = newParserFactory(); - writerFactory = newWriterFactory(); - writer = newWriter(); IRI.preinit(); // initializes the IRI stuff to improve performance later } @@ -147,7 +141,9 @@ * * @return The factory instance */ - public Factory getFactory() { + public synchronized Factory getFactory() { + if (factory == null) + factory = newFactory(); return factory; } @@ -156,7 +152,9 @@ * * @return The parser instance */ - public Parser getParser() { + public synchronized Parser getParser() { + if (parser == null) + parser = newParser(); return parser; } @@ -165,7 +163,9 @@ * * @return The XPath instance */ - public XPath getXPath() { + public synchronized XPath getXPath() { + if (xpath == null) + xpath = newXPath(); return xpath; } @@ -176,7 +176,9 @@ * * @return The ParserFactory instance */ - public ParserFactory getParserFactory() { + public synchronized ParserFactory getParserFactory() { + if (parserFactory == null) + parserFactory = newParserFactory(); return parserFactory; } @@ -187,7 +189,9 @@ * * @return The WriterFactory instance */ - public WriterFactory getWriterFactory() { + public synchronized WriterFactory getWriterFactory() { + if (writerFactory == null) + writerFactory = newWriterFactory(); return writerFactory; } @@ -197,7 +201,9 @@ * * @return The default writer implementation */ - public Writer getWriter() { + public synchronized Writer getWriter() { + if (writer == null) + writer = newWriter(); return writer; }