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
ClassCastException #3866
Comments
The issue stems from the fact that Scala wrapper expects System.getProperties to be a Map[String, String]: case class JPropertiesWrapper(underlying: ju.Properties) extends mutable.AbstractMap[String, String]
with mutable.Map[String, String]
with mutable.MapLike[String, String, JPropertiesWrapper] {
def iterator: Iterator[(String, String)] = new AbstractIterator[(String, String)] {
val ui = underlying.entrySet.iterator
def hasNext = ui.hasNext
def next() = {
val e = ui.next()
(e.getKey.asInstanceOf[String], e.getValue.asInstanceOf[String])
}
}
} (as it should be according to https://stackoverflow.com/questions/873510/why-does-java-util-properties-implement-mapobject-object-and-not-mapstring-st), while something puts a Boolean in the untyped Hashtable. Given that changing the Flyway version rectifies the issue we believe that something is Flyway. |
Seems likely, it should be |
|
This has been fixed and will be included in the next release of Flyway. |
Downgrade flyway because of flyway/flyway#3866
…rties` (#1366) `java.util.Properties` extends a `Map<Object, Object>`, which means the `put`/`putAll` etc have `Object` parameters - however [the Javadoc says](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html): > Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. [Flyway recently broke with this convention](flyway/flyway#3866), causing problems in: - [Hazelcast due to the unexpected types](#26310) - [Scala wrapper](flyway/flyway#3866 (comment)) [Flyway subsequently resolved this](flyway/flyway#3866 (comment)). The intent of this PR is to enhance the codebase to use type-safety to prevent these errors being introduced in future, rather than ensuring compliance with this convention. _Most_ uses of `Properties` in Hazelcast are already `String`s: - Changing the non-`String` types is out of scope - When working with `String`s, the more specific `setProperty`/`getProperty` should be used in preference to `put`/`putAll`/`get`, _where possible_ GitOrigin-RevId: 25ada108ca08e37af76338d00650780135cef24c
Which version and edition of Flyway are you using?
Started to see ClassCastException in sbt like in this gist
on our build server in drone
Rolled back from 10.11.0 to 10.10.0 of flyway and it resolved the issue.
Locally on my macbook it was working fine on the new version.
If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
maven dep from sbt
Which database are you using? (Type & version)
postgres 15.5 container
Which operating system are you using?
amazoncorretto 17 container
What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: