Skip to content

Fix ColumnSignature error message and jdk17 test issue.#14538

Merged
clintropolis merged 2 commits intoapache:masterfrom
gianm:fix-cidt-test
Jul 6, 2023
Merged

Fix ColumnSignature error message and jdk17 test issue.#14538
clintropolis merged 2 commits intoapache:masterfrom
gianm:fix-cidt-test

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Jul 6, 2023

On jdk17, the "problem" part of the error message could change from NullPointerException to:

  Cannot invoke "String.length()" because "s" is null

Due to the new more-helpful NPEs in Java 17. This broke the expectation and led to test failures on this case.

This patch fixes the problem by improving the error message so it isn't a generic NullPointerException.

On jdk17, the "problem" part of the error message could change from
NullPointerException to:

  Cannot invoke "String.length()" because "s" is null

Due to the new more-helpful NPEs in Java 17. This broke the expectation
and led to test failures on this case.

This patch fixes the problem by improving the error message so it isn't
a generic NullPointerException.
@gianm gianm added the Bug label Jul 6, 2023
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Jul 6, 2023

The test was added in #14531. I'm not sure how jdk17 CI passed for that version. It certainly failed on another PR here: https://github.com/apache/druid/actions/runs/5471321754/jobs/9978180802?pr=14532. Maybe it's flaky; perhaps the helpful NPE message isn't always generated.

@clintropolis clintropolis merged commit dd78e00 into apache:master Jul 6, 2023
// Name must be nonnull, but type can be null (if the type is unknown)
if (name == null || name.isEmpty()) {
throw new IAE(name, "Column name must be non-empty");
throw new IAE("Column name must be provided and non-empty");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by comment, we could've interpolated the name value here:

"Column name [%s] must be provided and non-empty", name

Would help differentiate between empty and null. That said, I wonder if this should be throwing an InvalidInput instead of IAE now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably have been doing InvalidInput. I forgot about those! Somehow!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gianm This leads to a 500 error being thrown if the user hits this error, instead of the 400 (which was the older behavior). Raised a PR yesterday which addresses this and cleans up exception handling of MSQ bits that reside in the broker. (#14534)

@pranavbhole
Copy link
Copy Markdown
Contributor

I pulled master and ran the test on jdk17 in sql compatible mode, it is failing the test.
Added jdk conditional assertion: #14536

@abhishekagarwal87 abhishekagarwal87 added this to the 27.0 milestone Jul 19, 2023
sergioferragut pushed a commit to sergioferragut/druid that referenced this pull request Jul 21, 2023
* Fix ColumnSignature error message and jdk17 test issue.

On jdk17, the "problem" part of the error message could change from
NullPointerException to:

  Cannot invoke "String.length()" because "s" is null

Due to the new more-helpful NPEs in Java 17. This broke the expectation
and led to test failures on this case.

This patch fixes the problem by improving the error message so it isn't
a generic NullPointerException.

* Fix format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants