diff --git a/common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java b/common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java index b62337d49f..4a7555d69b 100644 --- a/common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java +++ b/common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java @@ -208,7 +208,7 @@ public static boolean isValidActionInModelPrediction(ActionType actionType) { public static boolean isValidAction(String action) { try { - ActionType.valueOf(action.toUpperCase()); + ActionType.valueOf(action.toUpperCase(Locale.ROOT)); return true; } catch (IllegalArgumentException e) { return false; diff --git a/common/src/main/java/org/opensearch/ml/common/input/parameter/clustering/RCFSummarizeParams.java b/common/src/main/java/org/opensearch/ml/common/input/parameter/clustering/RCFSummarizeParams.java index 3956514b47..68ce2eec78 100644 --- a/common/src/main/java/org/opensearch/ml/common/input/parameter/clustering/RCFSummarizeParams.java +++ b/common/src/main/java/org/opensearch/ml/common/input/parameter/clustering/RCFSummarizeParams.java @@ -8,6 +8,7 @@ import static org.opensearch.core.xcontent.XContentParserUtils.ensureExpectedToken; import java.io.IOException; +import java.util.Locale; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; @@ -97,7 +98,7 @@ public static MLAlgoParams parse(XContentParser parser) throws IOException { parallel = parser.booleanValue(); break; case DISTANCE_TYPE_FIELD: - distanceType = DistanceType.from(parser.text().toUpperCase()); + distanceType = DistanceType.from(parser.text().toUpperCase(Locale.ROOT)); break; default: parser.skipChildren(); diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutor.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutor.java index ec5031b595..73876990ed 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutor.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutor.java @@ -13,6 +13,7 @@ import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import org.opensearch.ResourceNotFoundException; @@ -281,7 +282,7 @@ private ActionListener createAgentActionListener( @VisibleForTesting protected MLAgentRunner getAgentRunner(MLAgent mlAgent) { - final MLAgentType agentType = MLAgentType.from(mlAgent.getType().toUpperCase()); + final MLAgentType agentType = MLAgentType.from(mlAgent.getType().toUpperCase(Locale.ROOT)); switch (agentType) { case FLOW: return new MLFlowAgentRunner(client, settings, clusterService, xContentRegistry, toolFactories, memoryFactoryMap); diff --git a/plugin/src/main/java/org/opensearch/ml/action/batch/TransportBatchIngestionAction.java b/plugin/src/main/java/org/opensearch/ml/action/batch/TransportBatchIngestionAction.java index 6df22475e9..870e8ce97f 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/batch/TransportBatchIngestionAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/batch/TransportBatchIngestionAction.java @@ -15,6 +15,7 @@ import java.time.Instant; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -101,7 +102,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener { executeWithErrorHandling(() -> { double successRate = ingestable.ingest(mlBatchIngestionInput); @@ -193,7 +194,7 @@ private void validateBatchIngestInput(MLBatchIngestionInput mlBatchIngestionInpu if (dataSources.get(TYPE) == null || dataSources.get(SOURCE) == null) { throw new IllegalArgumentException("The batch ingest input data source is missing data type or source"); } - if (((String) dataSources.get(TYPE)).toLowerCase() == "s3") { + if (((String) dataSources.get(TYPE)).equalsIgnoreCase("s3")) { List s3Uris = (List) dataSources.get(SOURCE); if (s3Uris == null || s3Uris.isEmpty()) { throw new IllegalArgumentException("The batch ingest input s3Uris is empty"); diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java index 68c0146ab2..a8a8ba8903 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMLPredictionAction.java @@ -130,7 +130,8 @@ MLPredictionTaskRequest getRequest(String modelId, String algorithm, RestRequest ActionType actionType = ActionType.from(getActionTypeFromRestRequest(request)); if (FunctionName.REMOTE.name().equals(algorithm) && !mlFeatureEnabledSetting.isRemoteInferenceEnabled()) { throw new IllegalStateException(REMOTE_INFERENCE_DISABLED_ERR_MSG); - } else if (FunctionName.isDLModel(FunctionName.from(algorithm.toUpperCase())) && !mlFeatureEnabledSetting.isLocalModelEnabled()) { + } else if (FunctionName.isDLModel(FunctionName.from(algorithm.toUpperCase(Locale.ROOT))) + && !mlFeatureEnabledSetting.isLocalModelEnabled()) { throw new IllegalStateException(LOCAL_MODEL_DISABLED_ERR_MSG); } else if (ActionType.BATCH_PREDICT == actionType && !mlFeatureEnabledSetting.isOfflineBatchInferenceEnabled()) { throw new IllegalStateException(BATCH_INFERENCE_DISABLED_ERR_MSG);