LiquiBase LockHandler.listLocks Oracle bug? - ClassCastException

View: New views
1 Messages — Rating Filter:   Alert me  

LiquiBase LockHandler.listLocks Oracle bug? - ClassCastException

by Alan Savage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'd like to report a possible bug in the LiquiBase LockHandler.listLocks method. I'm using LiquiBase 1.6 with Oracle (although the problem appears to be present in 1.7 as well).

Here's the scenario:

- A lock is already present in the DatabaseChangeLogLock table (a row is present with column Locked = 1).
- I run LiquiBase to apply a database patch.
- LiquiBase throws the following exception when unable to acquire a lock:

java.lang.ClassCastException: java.math.BigDecimal at liquibase.lock.LockHandler.listLocks(LockHandler.java:124)

The problem code is in LockHandler.listLocks, line 124:
Boolean locked = (Boolean) columnMap.get("LOCKED");

For Oracle, the LOCKED column is defined as NUMBER(1). The JDBC query to retrieve the current locks returns the LOCKED column as a java.math.BigDecimal, which causes a ClassCastExpression when LiquiBase casts the column to a Boolean type.

Note that LockHandler.acquireLock(), line 48 appears to be handling the Oracle NUMBER(1) column type correctly:

locked = (Boolean) database.getJdbcTemplate().queryForObject(database.getSelectChangeLogLockSQL(), Boolean.class);

So listLocks probably needs to do the same when retrieving the LOCKED column result.

Let me know if anymore information is needed. Thanks!

- Alan
LightInTheBox - Buy quality products at wholesale price