ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From magyari_san...@apache.org
Subject ambari git commit: AMBARI-17618. Fix ConcurrentModificationException in Resource.Type (magyari_sandor)
Date Mon, 11 Jul 2016 15:10:24 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 15e58ecc2 -> e8bfdb924


AMBARI-17618. Fix ConcurrentModificationException in Resource.Type (magyari_sandor)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e8bfdb92
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e8bfdb92
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e8bfdb92

Branch: refs/heads/trunk
Commit: e8bfdb9248d8b305650555c7a7d2b230a163639b
Parents: 15e58ec
Author: Sandor Magyari <smagyari@hortonworks.com>
Authored: Mon Jul 11 14:14:29 2016 +0200
Committer: Sandor Magyari <smagyari@hortonworks.com>
Committed: Mon Jul 11 17:02:45 2016 +0200

----------------------------------------------------------------------
 .../org/apache/ambari/server/controller/spi/Resource.java    | 8 ++++++--
 .../ambari/server/controller/utilities/PropertyHelper.java   | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e8bfdb92/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index 6853266..bb452bb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -19,8 +19,12 @@
 package org.apache.ambari.server.controller.spi;
 
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListMap;
 
 /**
  * The resource object represents a requested resource.  The resource
@@ -185,7 +189,7 @@ public interface Resource {
     /**
      * Map of all registered types.
      */
-    private static Map<String, Type> types = new LinkedHashMap<String, Type>();
+    private static Map<String, Type> types = new ConcurrentHashMap<String, Type>();
 
     /**
      * Ordinal number counter for registering external types.
@@ -442,7 +446,7 @@ public interface Resource {
     }
 
     // register the type by name
-    private static synchronized void setType(String name, Type type) {
+    private static void setType(String name, Type type) {
       types.put(name, type);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e8bfdb92/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
index bddce28..4ded10e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
@@ -499,7 +499,7 @@ public class PropertyHelper {
         Map<Resource.Type, String> innerMap = new HashMap<Resource.Type, String>();
 
         for (Map.Entry<Resource.InternalType, String> entry1 : entry.getValue().entrySet())
{
-          innerMap.put(Resource.Type.values()[entry1.getKey().ordinal()], entry1.getValue());
+          innerMap.put(Resource.Type.valueOf(entry1.getKey().name()), entry1.getValue());
         }
         returnMap.put(entry.getKey(), innerMap);
       }


Mime
View raw message