Search in sources :

Example 1 with CodecNotFoundException

use of org.apache.cassandra.cql3.functions.types.exceptions.CodecNotFoundException in project cassandra by apache.

the class CodecRegistry method lookupCodec.

@SuppressWarnings("unchecked")
private <T> TypeCodec<T> lookupCodec(DataType cqlType, TypeToken<T> javaType) {
    checkNotNull(cqlType, "Parameter cqlType cannot be null");
    TypeCodec<?> codec = BUILT_IN_CODECS_MAP.get(cqlType.getName());
    if (codec != null && (javaType == null || codec.accepts(javaType))) {
        logger.trace("Returning built-in codec {}", codec);
        return (TypeCodec<T>) codec;
    }
    if (logger.isTraceEnabled())
        logger.trace("Querying cache for codec [{} <-> {}]", toString(cqlType), toString(javaType));
    try {
        CacheKey cacheKey = new CacheKey(cqlType, javaType);
        codec = cache.get(cacheKey);
    } catch (UncheckedExecutionException e) {
        if (e.getCause() instanceof CodecNotFoundException) {
            throw (CodecNotFoundException) e.getCause();
        }
        throw new CodecNotFoundException(e.getCause());
    } catch (RuntimeException | ExecutionException e) {
        throw new CodecNotFoundException(e.getCause());
    }
    logger.trace("Returning cached codec {}", codec);
    return (TypeCodec<T>) codec;
}
Also used : UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) CodecNotFoundException(org.apache.cassandra.cql3.functions.types.exceptions.CodecNotFoundException) ExecutionException(java.util.concurrent.ExecutionException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException)

Aggregations

UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1 ExecutionException (java.util.concurrent.ExecutionException)1 CodecNotFoundException (org.apache.cassandra.cql3.functions.types.exceptions.CodecNotFoundException)1