Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents Locale Code build failures #2967 #2980

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -281,7 +282,7 @@ private ActionListener<Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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;
Expand Down Expand Up @@ -93,7 +94,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<MLBatc
mlTaskManager.add(mlTask);
listener.onResponse(new MLBatchIngestionResponse(taskId, MLTaskType.BATCH_INGEST, MLTaskState.CREATED.name()));
String ingestType = (String) mlBatchIngestionInput.getDataSources().get(TYPE);
Ingestable ingestable = MLEngineClassLoader.initInstance(ingestType.toLowerCase(), client, Client.class);
Ingestable ingestable = MLEngineClassLoader.initInstance(ingestType.toLowerCase(Locale.ROOT), client, Client.class);
threadPool.executor(INGEST_THREAD_POOL).execute(() -> {
executeWithErrorHandling(() -> {
double successRate = ingestable.ingest(mlBatchIngestionInput);
Expand Down Expand Up @@ -185,7 +186,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<String> s3Uris = (List<String>) dataSources.get(SOURCE);
if (s3Uris == null || s3Uris.isEmpty()) {
throw new IllegalArgumentException("The batch ingest input s3Uris is empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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.isValidActionInModelPrediction(actionType)) {
throw new IllegalArgumentException("Wrong action type in the rest request path!");
Expand Down
Loading