abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r434239 - in /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera: Abdera.java util/AbderaConfiguration.java
Date Wed, 23 Aug 2006 23:12:20 GMT
Author: rooneg
Date: Wed Aug 23 16:12:19 2006
New Revision: 434239

URL: http://svn.apache.org/viewvc?rev=434239&view=rev
Log:
Be more consistent about synchronization.  This doesn't correct all
the potential thread safety issues in Abdera and AbderaConfiguration,
but it's a step.

For the curious, the remaining problem seems to be that if the Abdera
class is going to be safe to use from multiple threads we're going to
have to figure out how to deal with concurrent threads accessing the
AbderaConfiguration object.  Not sure how best to deal with that yet.

* core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
  (getDefault): synchronize this, since it lazily initializes a static
   variable.

* core/src/main/java/org/apache/abdera/Abdera.java
  (getParser,
   getXPath,
   getParserFactory,
   getWriterFactory,
   getWriter): Mark as synchronized, just like getFactory was, since
   they lazily initialize some members and synchronization is needed
   to ensure proper publication of the object.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/Abdera.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.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=434239&r1=434238&r2=434239&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 Wed Aug 23
16:12:19 2006
@@ -27,7 +27,7 @@
 import org.apache.abdera.xpath.XPath;
 
 public final class Abdera {
-  
+
   private AbderaConfiguration config = null;
   private Factory factory = null;
   private Parser parser = null;
@@ -58,7 +58,7 @@
     return (new Abdera()).newFactory();
   }
 
-  public Parser getParser() {
+  public synchronized Parser getParser() {
     if (parser == null)
       parser = newParser();
     return parser;
@@ -68,7 +68,7 @@
     return (new Abdera()).newParser();
   }
   
-  public XPath getXPath() {
+  public synchronized XPath getXPath() {
     if (xpath == null)
       xpath = newXPath();
     return xpath;
@@ -78,7 +78,7 @@
     return (new Abdera()).newXPath();
   }
 
-  public ParserFactory getParserFactory() {
+  public synchronized ParserFactory getParserFactory() {
     if (parserFactory == null)
       parserFactory = newParserFactory();
     return parserFactory;
@@ -88,7 +88,7 @@
     return (new Abdera()).newParserFactory();
   }
 
-  public WriterFactory getWriterFactory() {
+  public synchronized WriterFactory getWriterFactory() {
     if (writerFactory == null)
       writerFactory = newWriterFactory();
     return writerFactory;
@@ -98,7 +98,7 @@
     return (new Abdera()).newWriterFactory();
   }
 
-  public Writer getWriter() {
+  public synchronized Writer getWriter() {
     if (writer == null)
       writer = newWriter();
     return writer;

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java?rev=434239&r1=434238&r2=434239&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbderaConfiguration.java
Wed Aug 23 16:12:19 2006
@@ -32,7 +32,7 @@
   
   private static AbderaConfiguration instance = null;
   
-  public static AbderaConfiguration getDefault() {
+  public static synchronized AbderaConfiguration getDefault() {
     if (instance == null) {
       try {
         ResourceBundle bundle = ResourceBundle.getBundle("abdera");



Mime
View raw message