Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-19734

JAX-RS Validator NPEs with wildcard type arguments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.3.0.Beta2
    • 4.2.0.Final
    • webservices
    • None
    • Hide

      1. Enter the following code in a project with JAX-RS validation enabled, and save.

      import javax.ws.rs.Path;

      @Path( "/" )
      public class BugTest {
      public static void bug( final Class< ? > clazz )

      { clazz.getAnnotation( Path.class ); }

      }

      2. An error dialog should pop-up/be added to the error log with the message "Failed to (re)build the JAX-RS metamodel for project <project>".

      Show
      1. Enter the following code in a project with JAX-RS validation enabled, and save. import javax.ws.rs.Path; @Path( "/" ) public class BugTest { public static void bug( final Class< ? > clazz ) { clazz.getAnnotation( Path.class ); } } 2. An error dialog should pop-up/be added to the error log with the message "Failed to (re)build the JAX-RS metamodel for project <project>".

      JBoss JAX-RS Tools feature version: 1.8.0.Beta1-v20150417-0152-B698

      The JAX-RS validator throws an NPE when using generic types with wildcards. Specifically, the call to typeArgumentBinding.getJavaElement() in SourceType.from(VariableDeclaration) can return null, which the SourceType constructor then tries to use, resulting in the following stack trace. Depending on the code, the validator could trigger this exception as frequently as every pause in typing, resulting in a modal error box popping up constantly. The sample code provided only triggers it on save though.

      java.lang.NullPointerException
      at org.jboss.tools.ws.jaxrs.core.jdt.SourceType.<init>(SourceType.java:157)
      at org.jboss.tools.ws.jaxrs.core.jdt.SourceType.from(SourceType.java:49)
      at org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils.resolveMethodSignature(JdtUtils.java:1109)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource$Builder.build(JaxrsResource.java:169)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsResource.update(JaxrsResource.java:273)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel.processJavaElement(JaxrsMetamodel.java:647)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel.processResourceChange(JaxrsMetamodel.java:608)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.domain.JaxrsMetamodel.processAffectedResources(JaxrsMetamodel.java:574)
      at org.jboss.tools.ws.jaxrs.core.internal.metamodel.builder.ResourceChangedBuildJob.run(ResourceChangedBuildJob.java:77)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

            xcoulon@redhat.com Xavier Coulon
            vulcannis Kory Markevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: