Skip to content

Commit

Permalink
Reflective Bean Converter and APT (ParamDefinition) have inconsistent…
Browse files Browse the repository at this point in the history
… Nullable/NonNull logic. fix #3408
  • Loading branch information
jknack committed May 12, 2024
1 parent ea3298c commit f521422
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.jooby.ValueNode;
import io.jooby.annotation.EmptyBean;
import io.jooby.exception.BadRequestException;
import io.jooby.exception.MissingValueException;
import io.jooby.exception.ProvisioningException;
import io.jooby.internal.reflect.$Types;
import jakarta.inject.Inject;
Expand Down Expand Up @@ -236,19 +235,21 @@ private static Object value(Parameter parameter, ValueNode node, ValueNode value
}
}
}
} catch (MissingValueException x) {
throw new ProvisioningException(parameter, x);
} catch (BadRequestException x) {
throw new ProvisioningException(parameter, x);
}
}

private static boolean isNullable(Parameter parameter) {
var type = parameter.getType();
if (type.isPrimitive()) {
if (hasAnnotation(parameter, ".Nullable")) {
return true;
}
boolean nonnull = hasAnnotation(parameter, ".NonNull");
if (nonnull) {
return false;
}
return !hasAnnotation(parameter, "NotNull", "NonNull");
return !type.isPrimitive();
}

private static boolean hasAnnotation(AnnotatedElement element, String... names) {
Expand Down

0 comments on commit f521422

Please sign in to comment.