Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixes potential NPE while reading annotations #115

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

gastaldi
Copy link
Contributor

@gastaldi gastaldi commented Jul 3, 2024

An NPE may happen in methods returning an exception without the @TransformException annotation

[ERROR] java.lang.NullPointerException: Cannot invoke "javax.lang.model.element.TypeElement.asType()" because "type" is null
  	at org.jboss.logging.processor.apt.MessageMethodBuilder$AptMessageMethod.parametersAnnotatedWith(MessageMethodBuilder.java:373)
  	at org.jboss.logging.processor.apt.ThrowableTypeFactory$AptReturnThrowableType.init(ThrowableTypeFactory.java:328)
  	at org.jboss.logging.processor.apt.ThrowableTypeFactory.forReturnType(ThrowableTypeFactory.java:73)
  	at org.jboss.logging.processor.apt.ReturnTypeFactory$AptReturnType.init(ReturnTypeFactory.java:141)
  	at org.jboss.logging.processor.apt.ReturnTypeFactory.of(ReturnTypeFactory.java:61)
  	at org.jboss.logging.processor.apt.MessageMethodBuilder.build(MessageMethodBuilder.java:118)
  	at org.jboss.logging.processor.apt.MessageInterfaceFactory$AptMessageInterface.init(MessageInterfaceFactory.java:191)
  	at org.jboss.logging.processor.apt.MessageInterfaceFactory.of(MessageInterfaceFactory.java:100)
  	at org.jboss.logging.processor.apt.LoggingToolsProcessor.doProcess(LoggingToolsProcessor.java:200)
  	at org.jboss.logging.processor.apt.LoggingToolsProcessor.process(LoggingToolsProcessor.java:165)

@gastaldi gastaldi requested a review from jamezp as a code owner July 3, 2024 13:45
@gastaldi
Copy link
Contributor Author

gastaldi commented Jul 3, 2024

Actually this happens because the jboss-logging-annotations from the parent POM is 2.2.1.Final, explicitly declaring to use 3.0.0.Final makes the error go away.

I'll let you decide if this PR is worth including in the next release ;)

@jamezp jamezp merged commit 0dca8ee into jboss-logging:main Jul 3, 2024
9 checks passed
@gastaldi gastaldi deleted the npe_check branch July 3, 2024 22:48
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants