[go: up one dir, main page]

Skip to content
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

createProcedure fails with exception if contains only comment as body #6424

Open
1 of 2 tasks
b-gyula opened this issue Oct 15, 2024 · 0 comments · May be fixed by #6436
Open
1 of 2 tasks

createProcedure fails with exception if contains only comment as body #6424

b-gyula opened this issue Oct 15, 2024 · 0 comments · May be fixed by #6436
Labels
errorReporting needs_guidance Issue author is willing to submit PR and needs guidance PRAssociated

Comments

@b-gyula
Copy link
Contributor
b-gyula commented Oct 15, 2024

Search first

  • I searched and no similar issues were found

Description

If a createProcedure tag contains only block comment as body, then the execution fails with exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: 18
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
	at java.base/java.lang.String.charAt(String.java:693)
	at liquibase.util.StringUtil.getLastBlockComment(StringUtil.java:944)
	at liquibase.util.StringUtil.stripSqlCommentsAndWhitespacesFromTheEnd(StringUtil.java:1019)
	at liquibase.sqlgenerator.core.CreateProcedureGenerator.removeTrailingDelimiter(CreateProcedureGenerator.java:123)
	at liquibase.sqlgenerator.core.CreateProcedureGenerator.generateSql(CreateProcedureGenerator.java:87)
	at liquibase.sqlgenerator.core.CreateProcedureGenerator.generateSql(CreateProcedureGenerator.java:27)
	at liquibase.sqlgenerator.SqlGeneratorChain.generateSql(SqlGeneratorChain.java:32)
	at liquibase.sqlgenerator.SqlGeneratorFactory.generateSql(SqlGeneratorFactory.java:224)
	at liquibase.util.SqlUtil.getSqlString(SqlUtil.java:360)
	at liquibase.changelog.ChangeSet.lambda$addSqlMdc$3(ChangeSet.java:1617)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at liquibase.changelog.ChangeSet.addSqlMdc(ChangeSet.java:1618)
	at liquibase.changelog.ChangeSet.execute(ChangeSet.java:765)

The error is clear: in liquibase.util.StringUtil.getLastBlockComment(StringUtil.java:944)
at the statement char e = reversedString.charAt(i + 1); not checked if the index i has reached the end of the string before advanced +1

Steps To Reproduce

Execute the update command on the following script:

<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
						 xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
						 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.29.xsd">
	<changeSet id="1" author="">
		<createProcedure>
			/*CREATE PROC... */
		</createProcedure>
	</changeSet>
</databaseChangeLog>

Expected/Desired Behavior

It should just complain about empty body: Must specify either 'path' or a nested procedure text in createProcedure

Liquibase Version

4.28.0, 4.29.0

Database Vendor & Version

Liquibase Integration

all

Liquibase Extensions

OS and/or Infrastructure Type/Provider

all

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@fntz fntz linked a pull request Oct 17, 2024 that will close this issue
3 tasks
@tati-qalified tati-qalified added PRAssociated needs_guidance Issue author is willing to submit PR and needs guidance labels Oct 18, 2024
@MalloD12 MalloD12 moved this from New to In Development PR Issues in Liquibase Open Source Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errorReporting needs_guidance Issue author is willing to submit PR and needs guidance PRAssociated
Projects
Status: In Development PR Issues
Development

Successfully merging a pull request may close this issue.

3 participants