question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The <property /> definition for column type does not work in version 4.8.0, which works well in 3.x.x

See original GitHub issue

Environment

Liquibase Version: 4.6.1

Liquibase Integration & Version: spring boot

Liquibase Extension(s) & Version: <n/a>

Database Vendor & Version: postgres-12 in container ‘postgres:12-alpine’

Operating System Type & Version: Mac OS

Description

An exception java.lang.ArrayIndexOutOfBoundsException happened when run with below change log.

<databaseChangeLog ...>

    <property name="bytesarray_type" value="BYTEA" global="false" dbms="postgresql" />
    <property name="bytesarray_type" value="java.sql.Types.BLOB" global="false" dbms="hana" />

    <changeSet author="i521084" id="1583641912012-4">
        <createTable tableName="asyncevent">
            <column name="id" type="BIGINT">
                <constraints primaryKey="true" primaryKeyName="asyncevent_pkey"/>
            </column>
            <column name="messagebodybytes" type="${bytesarray_type}"/>
            <!-- ... -->
        </createTable>
    </changeSet>
</databaseChangeLog>

Steps To Reproduce

  1. Using postgres DB in docker image ‘postgres:12-alpine’.
  2. Using a changelog as above.
  3. Run the changelog with ‘liquibase.integration.spring.SpringLiquibase.performUpdate’.
  4. The exception will happened with handle above ‘create table’ change set.

Actual Behavior

An exception ArrayIndexOutOfBoundsException happened.

Expected/Desired Behavior

Relevant table should be created with above change log. And the same change log works well under Liquibase version 3.x.x.

Screenshots (if appropriate)

If applicable, add screenshots to help explain your problem.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JosephCencommented, May 4, 2022

@nvoxland I think it is not just a friendly exception message. The root cause is that 2 properties will be duplicated if they have same target DB and value.

Please look at below liquibase script:

    <property name="bytesarray_type" value="BYTEA" global="false" dbms="postgresql" />        <!-- (1) -->
    <property name="bytesarray_type" value="java.sql.Types.BLOB" global="false" dbms="hana" />
    <property name="messageproperties_type" value="BYTEA" global="false" dbms="postgresql" /> <!-- (2) -->
    <property name="messageproperties_type" value="NCLOB" global="false" dbms="hana" />

The script is expected to support 2 type DB. For postgres, ‘BYTEA’ column should be used for column for ‘bytearray’ and ‘messageproperties’. But in hana DB, these 2 columns should used different DB type.

But due to below isDuplicate logic. (1) & (2) will be classified as duplicated due to they have same target DB, value and label (no label). Finally, only one of (1) & (2) will be left.

            return StringUtil.equalsIgnoreCaseAndEmpty(contextString, otherContextString) &&
                   StringUtil.equalsIgnoreCaseAndEmpty(labelsString, otherLabelsString) &&
                   StringUtil.equalsIgnoreCaseAndEmpty(databases, otherDatabases);

ChangeLogParameter::isDuplicate

I think that key of these 2 parameters should be add to duplicated check as well.

1reaction
dwielandcommented, Mar 19, 2022

The java.lang.ArrayIndexOutOfBoundsException happens when the property placeholder could not be replaced for some reason. In that case the ${bytesarray_type} is forwarded as is to the DataTypeFactory. The DataTypeFactory identifies the curly braces as some kind of embedded information in the type, i.e. int{autoIncrement:true}, and fails accessing the expected “value” after splitting the content of the curly braces by colon.

But: the example you provided works as long as postgresql or hana are used as database.

Question for the maintainers: Is this behaviour actually expected? In my opinion there are only 2 sane solutions:

  1. Fail as soon as a missing property needs to be expanded
  2. Expand missing properties as an empty string

Just leaving the property placeholder in there and failing in later stages is not a good solution tbh.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release notes for SQL Server Management Studio (SSMS)
There is a known problem due to incorrect data in msdb. To resolve, remove backup history. For example EXEC msdb..sp_delete_backuphistory @ ...
Read more >
Release Notes | Liquibase Docs
Reference information for Liquibase release notes.
Read more >
c# - Could not load file or assembly 'System.Data.SqlClient ...
Each library runs under the process of the main application. So the main application needs to know to load the SqlClient DLL.
Read more >
What's new in IBM Cloud Pak for Data?
AI Factsheets is a new service that replaces the Factsheets functionality in Watson™ Knowledge Catalog. Data Virtualization is now Watson Query; RStudio Server ......
Read more >
Cisco IoT Field Network Director User Guide, Release 4.8.x
The troubleshooting report types available are All TLVs, Connectivity, General, Register, ... In IoT FND 4.7.x, this feature is enabled in the software....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found