From 216ef6e03266708ccc71b98049659f5c928df48d Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Mon, 9 Dec 2019 09:17:22 -0800 Subject: [PATCH] Fixed parsing of consistency level string value from property bag --- .../main/java/com/azure/data/cosmos/ConsistencyPolicy.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java index 17f12bf13097..d4ea30605bd2 100644 --- a/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java +++ b/sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java @@ -5,6 +5,7 @@ import com.azure.data.cosmos.internal.Constants; +import com.google.common.base.CaseFormat; import org.apache.commons.lang3.StringUtils; /** @@ -41,12 +42,12 @@ public ConsistencyPolicy() { public ConsistencyLevel defaultConsistencyLevel() { ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL; + String consistencyLevelString = super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL); try { - result = ConsistencyLevel.valueOf( - StringUtils.upperCase(super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL))); + result = ConsistencyLevel.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, consistencyLevelString)); } catch (IllegalArgumentException e) { // ignore the exception and return the default - this.getLogger().warn("Unknown consistency level {}, value ignored.", super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL)); + this.getLogger().warn("Unknown consistency level {}, value ignored.", consistencyLevelString); } return result; }