ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1345461 - in /ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl: ArtifactObjectImpl.java ArtifactRepositoryImpl.java
Date Sat, 02 Jun 2012 08:31:08 GMT
Author: jawi
Date: Sat Jun  2 08:31:07 2012
New Revision: 1345461

URL: http://svn.apache.org/viewvc?rev=1345461&view=rev
Log:
Fixed a potential deadlock when dealing with artifacts.

Modified:
    ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
    ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java

Modified: ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java?rev=1345461&r1=1345460&r2=1345461&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
(original)
+++ ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactObjectImpl.java
Sat Jun  2 08:31:07 2012
@@ -42,7 +42,7 @@ public class ArtifactObjectImpl extends 
      * As a general rule, RepositoryObjects do not know about their repository. However,
since the Helper
      * to be used is dictated by the repository, this rule is broken for this class.
      */
-    private ArtifactRepositoryImpl m_repo;
+    private final ArtifactRepositoryImpl m_repo;
 
     ArtifactObjectImpl(Map<String, String> attributes, String[] mandatoryAttributes,
ChangeNotifier notifier, ArtifactRepositoryImpl repo) {
         super(checkAttributes(attributes, completeMandatoryAttributes(mandatoryAttributes)),
notifier, XML_NODE);
@@ -54,6 +54,11 @@ public class ArtifactObjectImpl extends 
         m_repo = repo;
     }
 
+    ArtifactObjectImpl(HierarchicalStreamReader reader, ChangeNotifier notifier, ArtifactRepositoryImpl
repo) {
+        super(reader, notifier, XML_NODE);
+        m_repo = repo;
+    }
+    
     private static String[] completeMandatoryAttributes(String[] mandatory) {
         String[] result = new String[mandatory.length + 1];
         for (int i = 0; i < mandatory.length; i++) {
@@ -63,11 +68,6 @@ public class ArtifactObjectImpl extends 
         return result;
     }
 
-    ArtifactObjectImpl(HierarchicalStreamReader reader, ChangeNotifier notifier, ArtifactRepositoryImpl
repo) {
-        super(reader, notifier, XML_NODE);
-        m_repo = repo;
-    }
-
     public List<FeatureObject> getFeatures() {
         return getAssociations(FeatureObject.class);
     }
@@ -91,11 +91,6 @@ public class ArtifactObjectImpl extends 
         return getHelper().getComparator();
     }
 
-    @Override
-    String[] getDefiningKeys() {
-        return getHelper().getDefiningKeys().clone();
-    }
-
     public String getURL() {
         return getAttribute(KEY_URL);
     }
@@ -124,11 +119,18 @@ public class ArtifactObjectImpl extends 
         return getAttribute(KEY_ARTIFACT_DESCRIPTION);
     }
 
-    private synchronized ArtifactHelper getHelper() {
-        return m_repo.getHelper(getMimetype());
-    }
-
     public void setDescription(String value) {
         addAttribute(KEY_ARTIFACT_DESCRIPTION, value);
     }
+
+    @Override
+    String[] getDefiningKeys() {
+        return getHelper().getDefiningKeys().clone();
+    }
+    
+    private ArtifactHelper getHelper() {
+        // getMimetype is safe, as is getHelper, and m_repo is final, so no
+        // need to synchronize here...
+        return m_repo.getHelper(getMimetype());
+    }
 }

Modified: ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
URL: http://svn.apache.org/viewvc/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java?rev=1345461&r1=1345460&r2=1345461&view=diff
==============================================================================
--- ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
(original)
+++ ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
Sat Jun  2 08:31:07 2012
@@ -389,7 +389,7 @@ public class ArtifactRepositoryImpl exte
             is = openInputStream(artifact);
         }
         catch (IOException ioe) {
-            throw new IllegalArgumentException("Artifact " + artifact.toString() + " does
not point to a valid file.");
+            throw new IllegalArgumentException("Artifact " + artifact + " does not point
to a valid file.");
         }
         finally {
             if (is != null) {
@@ -403,9 +403,10 @@ public class ArtifactRepositoryImpl exte
         }
 
         // Then, check whether the name is legal.
-        for (byte b : artifact.toString().substring(artifact.toString().lastIndexOf('/')
+ 1).getBytes()) {
+        String artifactName = artifact.toString();
+        for (byte b : artifactName.substring(artifactName.lastIndexOf('/') + 1).getBytes())
{
             if (!(((b >= 'A') && (b <= 'Z')) || ((b >= 'a') && (b
<= 'z')) || ((b >= '0') && (b <= '9')) || (b == '.') || (b == '-') || (b
== '_'))) {
-                throw new IllegalArgumentException("Artifact " + artifact.toString() + "'s
name contains an illegal character '" + new String(new byte[] {b}) + "'");
+                throw new IllegalArgumentException("Artifact " + artifactName + "'s name
contains an illegal character '" + new String(new byte[] {b}) + "'");
             }
         }
     }



Mime
View raw message