flyway 2.2: NumberFormatException thrown when using command line tools. #584
Comments
after disassemble the flyway-commandline-2.2.jar, i see the -X option, so this time i add it to run: E:\flyway-2.2>flyway info -X
Flyway (Command-line Tool) v.2.2
DEBUG: Adding location to classpath: E:\flyway-2.2\bin\..\jars\h2-1.3.173.jar
ERROR: Unexpected error
java.lang.NumberFormatException: For input string: " "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
at com.googlecode.flyway.core.util.PropertiesUtils.getIntProperty(PropertiesUtils.
java:119)
at com.googlecode.flyway.commandline.Main.main(Main.java:84) seems it caused by the parse logical of "flyway.consoleWidth" property: Flyway flyway = new Flyway();
flyway.configure(properties);
int consoleWidth = PropertiesUtils.getIntProperty(properties, "flyway.consoleWidth", 80); i don't known what reason cause the "flyway.consoleWidth" have a value (" "). so the parse logical will failed due to format the (" ") value. i will try to write the migration tools using flyway API by myself to temporarily get around this problem. |
ok, i known what happen under the hood, the problem caused by the "flyway.cmd" batch file.\ @REM Detect the width of the console
for /F "usebackq tokens=2* skip=4 delims=: " %%A in (`mode con`) do (
set CONSOLE_WIDTH=%%A
goto ExitLoop
)
:ExitLoop
%JAVA_CMD% -cp bin\flyway-commandline-2.2.jar;bin\flyway-core-2.2.jar com.googlecode.flyway.commandline.Main %* -consoleWidth=%CONSOLE_WIDTH% the environment variable %CONSOLE_WIDTH% can't get correct value in my environment. |
Hi Bob, I'm sorry to hear you're having so many issues with Flyway. I tried to reproduce this one but couldn't. What is the output of mode con on your system? Thanks |
well, the "mode con" command output followings: Microsoft Windows [版本 6.2.9200]
(c) 2012 Microsoft Corporation。保留所有权利。
C:\Users\wenbo>mode con
设备状态 CON:
---------
行: 5000
列: 90
键盘速度: 31
键盘延迟: 1
代码页: 936
C:\Users\wenbo> it's caused by the OS language i am using? it's Chinese character encoding: GBK. |
Thanks, that explains it :-) If you can come up with a fix that works in the batch file I'll gladly accept a pull request. Either way I'll make the code more robust to default to 80 in case of an exception. |
first i using maven 3.1, and duing to Issue #571, i can't using maven-flyway-plugin. so i need to using command-line tools. but when i configured it and type
flyway:info
the exception thrown:
same as flyway:|any other option|
then, i do exactly steps specified by: http://flywaydb.org/getstarted/firststeps/commandline.html
and the results are same as above.
the environments i using: windows 8 x64 & java version "1.7.0_15" & H2 1.3.173.
BTW: now i was unable to using any flyway tools(both maven & command-line).
The text was updated successfully, but these errors were encountered: