Author: thomasm
Date: Mon Oct  6 12:27:59 2014
New Revision: 1629629

URL: http://svn.apache.org/r1629629
Log:
OAK-2112 DocumentNodeStore: Error calculating the machine id

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java?rev=1629629&r1=1629628&r2=1629629&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ClusterNodeInfo.java
 Mon Oct  6 12:27:59 2014
@@ -74,8 +74,8 @@ public class ClusterNodeInfo {
          */
         ACTIVE;
 
-        static ClusterNodeState fromString(String state){
-            if(state == null){
+        static ClusterNodeState fromString(String state) {
+            if (state == null) {
                 return NONE;
             }
             return valueOf(state);
@@ -96,8 +96,8 @@ public class ClusterNodeInfo {
          */
         ACQUIRED;
 
-        static RecoverLockState fromString(String state){
-            if(state == null){
+        static RecoverLockState fromString(String state) {
+            if (state == null) {
                 return NONE;
             }
             return valueOf(state);
@@ -290,7 +290,7 @@ public class ClusterNodeInfo {
                 success = true;
             }
 
-            if(success){
+            if (success) {
                 return clusterNode;
             }
         }
@@ -424,7 +424,7 @@ public class ClusterNodeInfo {
     /**
      * Resets the clock to the default
      */
-    static void resetClockToDefault(){
+    static void resetClockToDefault() {
         clock = Clock.SIMPLE;
     }
 
@@ -445,16 +445,21 @@ public class ClusterNodeInfo {
      * @return the unique id
      */
     private static String getMachineId() {
+        Exception exception = null;
         try {
             ArrayList<String> list = new ArrayList<String>();
             Enumeration<NetworkInterface> e = NetworkInterface
                     .getNetworkInterfaces();
             while (e.hasMoreElements()) {
                 NetworkInterface ni = e.nextElement();
-                byte[] mac = ni.getHardwareAddress();
-                if (mac != null) {
-                    String x = StringUtils.convertBytesToHex(mac);
-                    list.add(x);
+                try {
+                    byte[] mac = ni.getHardwareAddress();
+                    if (mac != null) {
+                        String x = StringUtils.convertBytesToHex(mac);
+                        list.add(x);
+                    }
+                } catch (Exception e2) {
+                    exception = e2;
                 }
             }
             if (list.size() > 0) {
@@ -464,7 +469,10 @@ public class ClusterNodeInfo {
                 return "mac:" + list.get(0);
             }
         } catch (Exception e) {
-            LOG.error("Error calculating the machine id", e);
+            exception = e;
+        }
+        if (exception != null) {
+            LOG.warn("Error getting the machine id; using a UUID", exception);
         }
         return RANDOM_PREFIX + UUID.randomUUID().toString();
     }


Reply via email to