@@ -66,15 +66,15 @@ static Getters buildGetters(Type type) {
6666 castToShortNotSupported (clazz ),
6767 value -> safeDecimalInt (value .getDecimal ()),
6868 value -> safeDecimalLong (value .getDecimal ()),
69- value -> value .getDecimal (). toBigDecimal ( ).floatValue (),
70- value -> value .getDecimal (). toBigDecimal ( ).doubleValue (),
69+ value -> safeDecimal ( value .getDecimal ()).floatValue (),
70+ value -> safeDecimal ( value .getDecimal ()).doubleValue (),
7171 castToBytesNotSupported (clazz ),
72- value -> value .getDecimal (). toBigDecimal ( ),
72+ value -> safeDecimal ( value .getDecimal ()),
7373 castToClassNotSupported (clazz ),
7474 castToInstantNotSupported (clazz ),
7575 castToNStringNotSupported (clazz ),
7676 castToUrlNotSupported (clazz ),
77- value -> value .getDecimal (). toBigDecimal ( ),
77+ value -> safeDecimal ( value .getDecimal ()),
7878 castToReaderNotSupported (clazz )
7979 );
8080 case VOID :
@@ -235,6 +235,13 @@ private static ValueToBoolean valueToBoolean(PrimitiveType id) {
235235 }
236236 }
237237
238+ private static BigDecimal safeDecimal (DecimalValue value ) throws SQLException {
239+ if (value .isInf () || value .isNegativeInf () || value .isNan ()) {
240+ throw cannotConvert (value .getType (), BigDecimal .class , value .toString ());
241+ }
242+ return value .toBigDecimal ();
243+ }
244+
238245 private static int safeDecimalInt (DecimalValue value ) throws SQLException {
239246 if (value .isInf () || value .isNegativeInf () || value .isNan ()) {
240247 throw cannotConvert (value .getType (), int .class , value .toString ());
0 commit comments