Skip to content

Commit 4f993c9

Browse files
kushagraThaparxseeseesee
authored andcommitted
Fixed parsing of consistency level string value from property bag (#6708)
1 parent 39e5340 commit 4f993c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sdk/cosmos/microsoft-azure-cosmos/src/main/java/com/azure/data/cosmos/ConsistencyPolicy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
import com.azure.data.cosmos.internal.Constants;
8+
import com.google.common.base.CaseFormat;
89
import org.apache.commons.lang3.StringUtils;
910

1011
/**
@@ -41,12 +42,12 @@ public ConsistencyPolicy() {
4142
public ConsistencyLevel defaultConsistencyLevel() {
4243

4344
ConsistencyLevel result = ConsistencyPolicy.DEFAULT_DEFAULT_CONSISTENCY_LEVEL;
45+
String consistencyLevelString = super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL);
4446
try {
45-
result = ConsistencyLevel.valueOf(
46-
StringUtils.upperCase(super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL)));
47+
result = ConsistencyLevel.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, consistencyLevelString));
4748
} catch (IllegalArgumentException e) {
4849
// ignore the exception and return the default
49-
this.getLogger().warn("Unknown consistency level {}, value ignored.", super.getString(Constants.Properties.DEFAULT_CONSISTENCY_LEVEL));
50+
this.getLogger().warn("Unknown consistency level {}, value ignored.", consistencyLevelString);
5051
}
5152
return result;
5253
}

0 commit comments

Comments
 (0)