davsclaus commented on code in PR #23021:
URL: https://github.com/apache/camel/pull/23021#discussion_r3206812077
##########
core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java:
##########
@@ -119,34 +124,47 @@ default boolean allowNull() {
}
@Override
- default <T> T convertTo(Class<T> type, Object value) throws
TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Object value)
throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, null, value);
}
@Override
- default <T> T convertTo(Class<T> type, Exchange exchange, Object value)
throws TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Exchange
exchange, @Nullable Object value)
+ throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, exchange, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Object value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException
{
- return mandatoryConvertTo(value.getClass(), type, null, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type,
type, null, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object
value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Exchange
exchange, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException
{
- return mandatoryConvertTo(value.getClass(), type, exchange, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type,
type, exchange, value);
}
@Override
- default <T> T tryConvertTo(Class<T> type, Object value) {
+ default <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Object
value) {
Review Comment:
the value is not null - you cannot converter a null value so this should be
changed
##########
core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java:
##########
@@ -119,34 +124,47 @@ default boolean allowNull() {
}
@Override
- default <T> T convertTo(Class<T> type, Object value) throws
TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Object value)
throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, null, value);
}
@Override
- default <T> T convertTo(Class<T> type, Exchange exchange, Object value)
throws TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Exchange
exchange, @Nullable Object value)
+ throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, exchange, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Object value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException
{
- return mandatoryConvertTo(value.getClass(), type, null, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type,
type, null, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object
value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Exchange
exchange, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException
{
- return mandatoryConvertTo(value.getClass(), type, exchange, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type,
type, exchange, value);
}
@Override
- default <T> T tryConvertTo(Class<T> type, Object value) {
+ default <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Object
value) {
+ if (value == null) {
+ return null;
+ }
return tryConvertTo(value.getClass(), type, null, value);
}
@Override
- default <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value)
{
+ default <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Exchange
exchange, @Nullable Object value) {
Review Comment:
the value is not null - you cannot converter a null value so this should be
changed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]