liquibase: ClassCastException on moving to mysql-connector-java version 8.0.23
Environment
Liquibase Version: 3.6.3
Liquibase Integration & Version: spring boot
Liquibase Extension(s) & Version:
Database Vendor & Version: mysql Ver 14.14 Distrib 5.7.28, for osx10.14 (x86_64) mysql-connector-java version 8.0.23
Operating System Type & Version: All
Description
While trying to move from mysql-connector-java version 8.0.18 to 8.0.23, getting an ClassCastException on bootup.
Caused by: java.lang.ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String at liquibase.changelog.StandardChangeLogHistoryService.getRanChangeSets(StandardChangeLogHistoryService.java:324) at liquibase.changelog.AbstractChangeLogHistoryService.upgradeChecksums(AbstractChangeLogHistoryService.java:66) at liquibase.changelog.StandardChangeLogHistoryService.upgradeChecksums(StandardChangeLogHistoryService.java:293) at liquibase.Liquibase.checkLiquibaseTables(Liquibase.java:1221) at liquibase.Liquibase.update(Liquibase.java:193) at liquibase.Liquibase.update(Liquibase.java:179) at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:353) at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:305) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1830) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1767) ... 108 common frames omitted
Steps To Reproduce (CLI)
Add the mysql-connector 8.0.23 jar to your lib directory and attempt to run liquibase operations against a mysql database.
Steps To Reproduce (Spring Boot)
List the steps to reproduce the behavior. this is the pom.xml used,
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>3.6</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Liquibase Internal QA Requirements
- Manually validate the fix with the CLi.
- Locally execute all functional MySQL tests.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 25 (7 by maintainers)
Commits related to this issue
- Fixes #1639 and upgrade MySQL Driver to 8.0.23 - upgrade MySQL Driver to 8.0.23 - fix typos in comment to be able to run MySQL integration tests - fix assertion in AbstractIntegrationTest.testContext... — committed to morphean-sa/liquibase by deleze 3 years ago
- Update version to 3.10.4 with fix for #1639 in 3.10.X — committed to vjrj/liquibase by vjrj 2 years ago
Any news on 3.10.4?
My suggestion would be to use 8.0.22 until MySQL fixes this especially if there is nothing critical in 8.0.23 that is not in 8.0.22.
Hello, are there plans for a 3.10.4 with the fix?
As written in the mysql connector j change log , they changed the contract of getObject:
So, i assume, they do not consider this as a bug, but as a new feature or at least as a changed implementation detail. In order to get Liquibase working properly with mysql connector 8.0.23 and onwards, liquibase code must be changed either to include an “
instanceof LocalDateTime
”, or to call thegetObject(..., String.class)
variant.@molivasdat wait a second!
I completely disagree.
If I understand the thread correctly, I think @pioneer2k was saying that the changes made under https://bugs.mysql.com/bug.php?id=102321 which shipped in
mysql-connector-java:8.0.23
is the cause of the bug in LB. MySQL changed the contract a bit, and therefore, LB needs to update too.It appears to me that the LB code in
StandardChangeLogHistoryService
needs to be updated to now also handle aLocalDateTime
as returned from the MySQL connector instead of blindly casting thetmpDateExecuted
to aString
:https://github.com/liquibase/liquibase/blob/6986dffb9f67c613db89f2aee72ad82a71a68d26/liquibase-core/src/main/java/liquibase/changelog/StandardChangeLogHistoryService.java#L317-L328
LB is already checking for
instanceof Date
so I think it needs to do the same for returned objects of typeLocalDateTime
.Are you saying that LB won’t change and I have to force my stack to
mysql-connector-java:8.0.22
until MySQL fixes this?hey @ashwin-nutanix and @jasontrublu – we just released 4.3.0 yesterday, and are wrapping some of these related issues into 4.3.1 aimed for two weeks from now. i see desire for getting this backported into 3.10.4 as well, so let me go check with the team, and i ll get you a date estimate. thanks!
@mariochampion We are on
3.6.3
. Can you confirm if there will be a fix for this version ? Are there any breaking changes to upgrade3.10.4
?Thanks all for the feedback. We have reopened this issue and are looking at how and where we can fix it. It looks to be an intentional change on the latest MySQL Connector/J as of 8.0.23.
Thanks @pioneer2k . It looks like the bug is in the mysql jar file and not with Liquibase. Closing this as not in Liquibase. @markkolich @ashwin-nutanix , please follow the MySQL jar bug reference from @pioneer2k above.