[ https://issues.apache.org/jira/browse/CASSANDRA-18484?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17717619#comment-17717619 ]
Stefan Miklosovic commented on CASSANDRA-18484: ----------------------------------------------- [~haozhong] lets give it a week or two to have a chance to report additional issues you may find so we are not returning to this issue again in the future and we fix it all in one shot. > FunctionCall can throw more specific exceptions > ----------------------------------------------- > > Key: CASSANDRA-18484 > URL: https://issues.apache.org/jira/browse/CASSANDRA-18484 > Project: Cassandra > Issue Type: Bug > Reporter: Hao Zhong > Assignee: Stefan Miklosovic > Priority: Normal > Fix For: 5.x > > > FunctionCall has the following code: > {code:java} > private static ByteBuffer executeInternal(ProtocolVersion protocolVersion, > ScalarFunction fun, List<ByteBuffer> params) throws InvalidRequestException > { > ByteBuffer result = fun.execute(protocolVersion, params); > try > { > // Check the method didn't lied on it's declared return type > if (result != null) > fun.returnType().validate(result); > return result; > } > catch (MarshalException e) > { > throw new RuntimeException(String.format("Return of function %s > (%s) is not a valid value for its declared return type %s", > fun, > ByteBufferUtil.bytesToHex(result), fun.returnType().asCQL3Type()), e); > } > } > {code} > When validate throws MarshalException, it rethrows RuntimeException. Other > methods throw more specific exceptions. For example, BytesConversionFcts > throws > {color:#000000}InvalidRequestException:{color} > {code:java} > public ByteBuffer execute(ProtocolVersion protocolVersion, List<ByteBuffer> > parameters) > { > ByteBuffer val = parameters.get(0); > if (val != null) > { > try > { > toType.getType().validate(val); > } > catch (MarshalException e) > { > throw new InvalidRequestException(String.format("In call > to function %s, value 0x%s is not a " + > "valid > binary representation for type %s", > name, > ByteBufferUtil.bytesToHex(val), toType)); > } > } > return val; > } > {code} > {color:#000000}{color:#000000}As another example, Validation also rethrows > this exception:{color}{color} > {code:java} > public static void validateKey(TableMetadata metadata, ByteBuffer key) > { > ... > try > { > metadata.partitionKeyType.validate(key); > } > catch (MarshalException e) > { > throw new InvalidRequestException(e.getMessage()); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org