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

NPE from ArcAnnotationProcessor when default value() is used #1832

Closed
sarxos opened this issue Apr 3, 2019 · 2 comments · Fixed by #1838
Closed

NPE from ArcAnnotationProcessor when default value() is used #1832

sarxos opened this issue Apr 3, 2019 · 2 comments · Fixed by #1838
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Milestone

Comments

@sarxos
Copy link
Contributor

sarxos commented Apr 3, 2019

Hello @mkouba ,

This is in regards to the issue we discussed today on Zulip.

After using jandex-maven-plugin to generate META-INF/jandex.idx I'm getting errors from all my tests.

Maven plugin I used:

<plugin>
  <groupId>org.jboss.jandex</groupId>
  <artifactId>jandex-maven-plugin</artifactId>
  <version>1.0.5</version>
  <executions>
    <execution>
      <id>make-index</id>
      <goals>
        <goal>jandex</goal>
      </goals>
    </execution>
  </executions>
</plugin>

And the stack trace I'm getting is:

Caused by: java.lang.NullPointerException: Value not set for java.lang.Class<? extends akka.actor.Actor> value()
    at io.quarkus.arc.processor.AnnotationLiteralProcessor.process(AnnotationLiteralProcessor.java:92)
    at io.quarkus.arc.processor.BeanGenerator.initConstructor(BeanGenerator.java:624)
    at io.quarkus.arc.processor.BeanGenerator.createConstructor(BeanGenerator.java:513)
    at io.quarkus.arc.processor.BeanGenerator.generateProducerMethodBean(BeanGenerator.java:371)
    at io.quarkus.arc.processor.BeanGenerator.generate(BeanGenerator.java:124)
    at io.quarkus.arc.processor.BeanProcessor.process(BeanProcessor.java:186)
    at io.quarkus.arc.deployment.ArcAnnotationProcessor.build(ArcAnnotationProcessor.java:259)

The source code (at revision with jandex failure):

https://github.com/sarxos/abberwoult/tree/00dd5d0a182f8ea85657044a4e4a228a7d828756

The problematic annotation is this buddy here:

@Qualifier
@Documented
@Target({ FIELD, PARAMETER, METHOD })
@Retention(RUNTIME)
public @interface ActorByClass {

	final Class<? extends Actor> NO_CLASS = Actor.class;

	@Nonbinding
	Class<? extends Actor> value() default Actor.class;
}

After you suggested to override jandex dependency in corresponding maven plugin to 2.1.1.Final all tests are again passing, which proves that jandex-maven-plugin uses outdated dependency.

The workarounds so far:

  1. Use empty META-INF/beans.xml instead of jandex-maven-plugin, or
  2. Force newer (2.1.1.Final) jandex dependency in jandex-maven-plugin:
<plugin>
  <groupId>org.jboss.jandex</groupId>
  <artifactId>jandex-maven-plugin</artifactId>
  <version>1.0.5</version>
  <executions>
    <execution>
      <id>make-index</id>
      <goals>
        <goal>jandex</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jandex</artifactId>
      <version>2.1.1.Final</version>
    </dependency>
  </dependencies>
</plugin>
@mkouba
Copy link
Contributor

mkouba commented Apr 3, 2019

FYI a PR to upgrade Jandex in the Maven plugin: wildfly/jandex-maven-plugin#13

@mkouba
Copy link
Contributor

mkouba commented Apr 3, 2019

Unfortunately, I see no other way to obtain the default value from the jandex index and so the only thing we could do is to improve the exception message so that a user knows how to fix it.

mkouba added a commit to mkouba/quarkus that referenced this issue Apr 3, 2019
@gsmet gsmet added area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working labels Apr 4, 2019
@gsmet gsmet added this to the 0.13.0 milestone Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants