private static <T> T decodePropertyValue(String fullPropertyName, @Nullable String propertyValue, Class<T> type, PropertyMetadata<?> metadata) { if (metadata.getJavaType() != type) { throw new PrestoException(INVALID_SESSION_PROPERTY, format("Property %s is type %s, but requested type was %s", fullPropertyName, metadata.getJavaType().getName(), type.getName())); } if (propertyValue == null) { return type.cast(metadata.getDefaultValue()); } Object objectValue = deserializeSessionProperty(metadata.getSqlType(), propertyValue); try { return type.cast(metadata.decode(objectValue)); } catch (PrestoException e) { throw e; } catch (Exception e) { // the system property decoder can throw any exception throw new PrestoException(INVALID_SESSION_PROPERTY, format("%s is invalid: %s", fullPropertyName, propertyValue), e); } }
private static <T> T decodePropertyValue(String fullPropertyName, @Nullable String propertyValue, Class<T> type, PropertyMetadata<?> metadata) { if (metadata.getJavaType() != type) { throw new PrestoException(INVALID_SESSION_PROPERTY, format("Property %s is type %s, but requested type was %s", fullPropertyName, metadata.getJavaType().getName(), type.getName())); } if (propertyValue == null) { return type.cast(metadata.getDefaultValue()); } Object objectValue = deserializeSessionProperty(metadata.getSqlType(), propertyValue); try { return type.cast(metadata.decode(objectValue)); } catch (PrestoException e) { throw e; } catch (Exception e) { // the system property decoder can throw any exception throw new PrestoException(INVALID_SESSION_PROPERTY, format("%s is invalid: %s", fullPropertyName, propertyValue), e); } }