Skip to content

Fix jackson NPR assertion in JDK 17#14536

Closed
pranavbhole wants to merge 1 commit intoapache:masterfrom
pranavbhole:fixCalciteIngestionTestJdk17
Closed

Fix jackson NPR assertion in JDK 17#14536
pranavbhole wants to merge 1 commit intoapache:masterfrom
pranavbhole:fixCalciteIngestionTestJdk17

Conversation

@pranavbhole
Copy link
Contributor

Fixes #XXXX.

Description

fixing test in master, Looks like JsonProcessingException from jackson throws more specific assertion with reason in the case of the just null point exception. With older JDK, jackson throws generic NPR in deserialization. Adding the JDK conditional assertions.

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...

Release note


Key changed/added classes in this PR
  • MyFoo
  • OurBar
  • TheirBaz

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

JvmUtils.majorVersion() >= 17
? "Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: Cannot invoke \"String.length()\" because \"s\" is null"
:
"Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: `java.lang.NullPointerException`"
Copy link
Contributor

Choose a reason for hiding this comment

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

Also can change this message contains to

Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature

which I think would be same for all the JVM versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can shorten the message as well. That will also work. I just want to highlight the fact that jackson is not bubbling up the generic NPR for jdk version >17 and giving specific root cause of the NPR exception.

Comment on lines +1642 to +1644
JvmUtils.majorVersion() >= 17
? "Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: Cannot invoke \"String.length()\" because \"s\" is null"
:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the source of the exception to do something that doesn't cause NPEs? There's no way that an end user woudl actually understand what s is and why it needs length called on it. Come to think of it, there's probably no reason to believe that they would even understand what an org.apache.druid.segment.column.ColumnSignature is...

@pranavbhole pranavbhole closed this Jul 7, 2023
@pranavbhole pranavbhole deleted the fixCalciteIngestionTestJdk17 branch July 7, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants