Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flyway 2.2: NumberFormatException thrown when using command line tools. #584

Closed
bobwenx opened this issue Aug 14, 2013 · 5 comments
Closed

flyway 2.2: NumberFormatException thrown when using command line tools. #584

bobwenx opened this issue Aug 14, 2013 · 5 comments

Comments

@bobwenx
Copy link

@bobwenx bobwenx commented Aug 14, 2013

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:

E:\flyway-2.2>flyway info
Flyway (Command-line Tool) v.2.2

ERROR: NumberFormatException: For input string: "  "
ERROR: Occured in java.lang.NumberFormatException.forInputString() at line 65

same as flyway:|any other option|

E:\flyway-2.2>flyway migrate
Flyway (Command-line Tool) v.2.2

ERROR: NumberFormatException: For input string: "  "
ERROR: Occured in java.lang.NumberFormatException.forInputString() at line 65

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).

@bobwenx
Copy link
Author

@bobwenx bobwenx commented Aug 14, 2013

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.
hopefully the next version will be released soon 👍

@bobwenx
Copy link
Author

@bobwenx bobwenx commented Aug 14, 2013

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.
after remove -consoleWidth=%CONSOLE_WIDTH%, the command tools are able to work properly.

axelfontaine added a commit that referenced this issue Aug 20, 2013
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Aug 20, 2013

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
Axel

@bobwenx
Copy link
Author

@bobwenx bobwenx commented Aug 20, 2013

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.

@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Aug 20, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.