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 shouldn't attempt to colorize the log if there is no System.console() #2727

Closed
xdy opened this issue Mar 18, 2020 · 2 comments
Closed

Flyway shouldn't attempt to colorize the log if there is no System.console() #2727

xdy opened this issue Mar 18, 2020 · 2 comments

Comments

@xdy
Copy link

@xdy xdy commented Mar 18, 2020

Which version and edition of Flyway are you using?

6.3.1 community edition (via the official dockerfile)
The problem showed itself when we upgraded from 6.1.4 to 6.3.1

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

DB2 11.5

Which operating system are you using?

Alpine linux

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
We do the following inside the docker image (in a CI environment)
set ANSIBLE_FORCE_COLOR=true
run flyway info

What did you expect to see?

The usual output of flyway info

What did you see instead?

Exception in thread "main" java.lang.NoClassDefFoundError: org/fusesource/jansi/AnsiConsole
at org.flywaydb.commandline.ColorizedConsoleLog.install(ColorizedConsoleLog.java:36)
at org.flywaydb.commandline.ConsoleLogCreator.createLogger(ConsoleLogCreator.java:45)
at org.flywaydb.commandline.MultiLogCreator.createLogger(MultiLogCreator.java:39)
at org.flywaydb.core.api.logging.LogFactory.getLog(LogFactory.java:80)
at org.flywaydb.core.internal.util.ClassUtils.(ClassUtils.java:35)
at org.flywaydb.core.internal.util.FeatureDetector.isSlf4jAvailable(FeatureDetector.java:91)
at org.flywaydb.core.internal.logging.LogCreatorFactory.getLogCreator(LogCreatorFactory.java:39)
at org.flywaydb.core.api.logging.LogFactory.getLog(LogFactory.java:77)
at org.flywaydb.core.internal.util.FeatureDetector.(FeatureDetector.java:25)
at org.flywaydb.core.internal.logging.LogCreatorFactory.getLogCreator(LogCreatorFactory.java:35)
at org.flywaydb.core.api.logging.LogFactory.getLog(LogFactory.java:77)
at org.flywaydb.commandline.Main.initLogging(Main.java:73)
at org.flywaydb.commandline.Main.main(Main.java:83)
Caused by: java.lang.ClassNotFoundException: org.fusesource.jansi.AnsiConsole
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 13 more

Workaround

Unset ANSIBLE_FORCE_COLOR
Well, it ought to work, haven't had a chance to test it yet, and I don't really want to do that anyway.

Suggested fix

The problem seems to have been caused in commit 72cfe7d
Specifically by the following change:

  •  if (System.console() == null) {
    
  •    if (Color.NEVER.equals(color)) {
    

It seems to me that it is still useful to check if System.console() is null, in which case colorization is certainly not useful. I.e. I suggest that line 41 in ConsoleLogCreator be changed as follows:

  •    if (Color.NEVER.equals(color)) {
    
  •  if (System.console() == null && Color.NEVER.equals(color)) {
    
@MikielAgutu
Copy link
Contributor

@MikielAgutu MikielAgutu commented Mar 19, 2020

Fair point. I'll investigate. In the meantime you can specify the colorization behavior you would like by using the color option https://flywaydb.org/documentation/commandline/migrate#color

@juliahayward
Copy link
Member

@juliahayward juliahayward commented Mar 23, 2020

Will be fixed in the 6.3.2 release.

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

No branches or pull requests

3 participants