allure-java
allure-java copied to clipboard
NullPointerException during compilation in JavaDocDescriptionsProcessor if primitive parameters are used
java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "javax.lang.model.util.Types.asElement(javax.lang.model.type.TypeMirror)" is null
at io.qameta.allure.description.JavaDocDescriptionsProcessor.lambda$null$0 (JavaDocDescriptionsProcessor.java:72)
Seems to be introduced by this commit
https://github.com/allure-framework/allure-java/commit/e5818c79ef3a3c9bf6ffe447c7523213b18d22e2#diff-bd0fd4688cf1711d51b2c9e0be1f676c3c986ff4f18e1c31c3cc9a0d02c635faR72
To Reproduce Steps to reproduce the behavior:
- Create a parameterized test with a primitive parameter
/**
* myDescription.
*/
@Description(useJavaDoc = true)
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void test_mytest(final boolean active) {
}
- Try to compile it
Expected behavior It compiles
Investigation
in the error-line .map(param -> processingEnv.getTypeUtils().asElement(param.asType()).toString())
I see that
param.asType()
is of type boolean
and asElement
will return null in this case:
public Element asElement(TypeMirror t) {
switch (t.getKind()) {
case DECLARED:
case INTERSECTION:
case ERROR:
case TYPEVAR:
Type type = cast(Type.class, t);
return type.asElement();
default:
return null;
}
}
Desktop:
- OS: linux, jdk 17
- Browser does not matter
- Version 2.19.0
Additional context
2.18.1 works. Probably a regression by this commit: https://github.com/allure-framework/allure-java/commit/e5818c79ef3a3c9bf6ffe447c7523213b18d22e2
Workaround
Use Boolean
instead of boolean