question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException when calling AnnotationInfo#getParameterValues

See original GitHub issue

I want to get the current value from the io.swagger.annotations.ApiOperation annotation. In my use case I must get the value for notes.

final AnnotationInfo annotationInfo = methodInfo.getAnnotationInfo( ApiOperation.class.getName() );
assertThat( annotationInfo ).isNotNull();
final String value = annotationInfo.getParameterValues().get( "notes" ).getValue().toString();

Annotation to get the value from: @ApiOperation(value = "", notes = "${snippetclassifications.findById}", response = RestSnippetClassification.class)

The getParameterValues() call throws the following NullPointerException:

java.lang.NullPointerException
	at io.github.classgraph.ObjectTypedValueWrapper.getArrayValueClassOrName(ObjectTypedValueWrapper.java:291)
	at io.github.classgraph.ObjectTypedValueWrapper.convertWrapperArraysToPrimitiveArrays(ObjectTypedValueWrapper.java:372)
	at io.github.classgraph.AnnotationParameterValue.convertWrapperArraysToPrimitiveArrays(AnnotationParameterValue.java:165)
	at io.github.classgraph.AnnotationParameterValueList.convertWrapperArraysToPrimitiveArrays(AnnotationParameterValueList.java:110)
	at io.github.classgraph.AnnotationInfo.convertWrapperArraysToPrimitiveArrays(AnnotationInfo.java:458)
	at io.github.classgraph.ObjectTypedValueWrapper.convertWrapperArraysToPrimitiveArrays(ObjectTypedValueWrapper.java:362)
	at io.github.classgraph.AnnotationParameterValue.convertWrapperArraysToPrimitiveArrays(AnnotationParameterValue.java:165)
	at io.github.classgraph.AnnotationParameterValueList.convertWrapperArraysToPrimitiveArrays(AnnotationParameterValueList.java:110)
	at io.github.classgraph.AnnotationInfo.getParameterValues(AnnotationInfo.java:136)
	at de.myview.xom.rest.api.AbstractApiControllerTest.checkApiOperationNotesProperty(AbstractApiControllerTest.java:590)
	at de.myview.xom.rest.api.AbstractApiControllerTest.lambda$33(AbstractApiControllerTest.java:578)

This happens when the code tries to get the default-value for the property properties. This property has following definition:

Extension[] extensions() default @Extension(properties = @ExtensionProperty(name = "", value = ""));

I have used ClassGraph 4.8.47 and attached the verbose output of my test. verbose.log

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
torstenkuhnhennecommented, Sep 28, 2019

@lukehutch I can confirm that the current snapshot version is working 😃

Thank you for your quick support and the good work. I use ClassGraph a lot and it works like a charm!

0reactions
lukehutchcommented, Oct 16, 2019

@torstenkuhnhenne After a very long time trying to solve issues with both Sonatype and BinTray, Maven deployment is fixed again, and ClassGraph version 4.8.48 should be in Maven Central in a few hours. Sorry for the delay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
java - What is a NullPointerException, and how do I fix it?
Calling super on a null reference throws a NullPointerException . If you are confused, this is talking about qualified superclass constructor invocations: class ......
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
1. NullPointerException when calling an instance method · 2. Java NullPointerException while accessing/modifying field of a null object · 3. Java ...
Read more >
Null Pointer Exception In Java - GeeksforGeeks
NullPointerException is thrown when program attempts to use an object reference that has the null value.
Read more >
NullPointerException (Java Platform SE 7 ) - Oracle Help Center
Thrown when an application attempts to use null in a case where an object is required. These include: Calling the instance method of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found