Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

commandLine: flyway.consoleWidth property should be optional

  • Loading branch information...
commit 3163d63f7dc755341be7f70c0570dd57b683f7f0 1 parent 19ded0e
Alex Panchenko authored
2  flyway-commandline/src/main/java/com/googlecode/flyway/commandline/Main.java
View
@@ -81,7 +81,7 @@ public static void main(String[] args) {
Flyway flyway = new Flyway();
flyway.configure(properties);
- int consoleWidth = Integer.parseInt(properties.getProperty("flyway.consoleWidth"));
+ int consoleWidth = PropertiesUtils.getIntProperty(properties, "flyway.consoleWidth", 80, true);
executeOperation(flyway, operation, consoleWidth);
} catch (Exception e) {
18 flyway-core/src/main/java/com/googlecode/flyway/core/util/PropertiesUtils.java
View
@@ -15,6 +15,8 @@
*/
package com.googlecode.flyway.core.util;
+import com.googlecode.flyway.core.util.logging.LogFactory;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
@@ -104,4 +106,20 @@ private static String unescape(String str) {
}
return outBuffer.toString();
}
+
+ public static int getIntProperty(Properties properties, String key, int defaultValue, boolean useDefaultOnError) {
+ final String value = properties.getProperty(key);
+ if (value != null) {
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ if (useDefaultOnError) {
+ LogFactory.getLog(PropertiesUtils.class).debug(e.toString());
+ } else {
+ throw e;
+ }
+ }
+ }
+ return defaultValue;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.