Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 2a1434e2e -> c5df43c01


[KARAF-3471] Display a warn when etc/config.properties is not write-able and 
don't block the startup


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

Branch: refs/heads/karaf-3.0.x
Commit: c5df43c0102d793300fcbdeb2af1f49456c0dee2
Parents: 2a1434e
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Thu Apr 9 13:39:06 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Thu Apr 9 13:39:06 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/karaf/main/ConfigProperties.java   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/c5df43c0/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
----------------------------------------------------------------------
diff --git a/main/src/main/java/org/apache/karaf/main/ConfigProperties.java 
b/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
index 32947d9..5a88ae8 100644
--- a/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
+++ b/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
@@ -20,6 +20,7 @@ package org.apache.karaf.main;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Arrays;
@@ -240,10 +241,14 @@ public class ConfigProperties {
         System.setProperty(KARAF_DELAY_CONSOLE, new 
Boolean(this.delayConsoleStart).toString());
 
         if (shutdownCommand == null || shutdownCommand.isEmpty()) {
-            shutdownCommand = UUID.randomUUID().toString();
-            Properties temp = new Properties(file);
-            temp.put(KARAF_SHUTDOWN_COMMAND, Arrays.asList("", "#", "# 
Generated command shutdown", "#"), shutdownCommand);
-            temp.save();
+            try {
+                shutdownCommand = UUID.randomUUID().toString();
+                Properties temp = new Properties(file);
+                temp.put(KARAF_SHUTDOWN_COMMAND, Arrays.asList("", "#", "# 
Generated command shutdown", "#"), shutdownCommand);
+                temp.save();
+            } catch (IOException e) {
+                System.err.println("WARN: can't update etc/config.properties 
with the generated command shutdown. We advise to manually add the 
karaf.shutdown.command property.");
+            }
         }
     }
     

Reply via email to