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

Most upvoted comments

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:

Also, with the implementation of the new mechanism, a getObject(columnIndex) call on a DATETIME column returns a LocalDateTime object now instead of a String. To receive a String like before, use getObject(columnIndex, String.class) instead.

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 the getObject(..., String.class) variant.

@molivasdat wait a second!

It looks like the bug is in the mysql jar file and not with Liquibase.

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 a LocalDateTime as returned from the MySQL connector instead of blindly casting the tmpDateExecuted to a String:

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 type LocalDateTime.

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 upgrade 3.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.