Skip to content

Commit 9b09f4c

Browse files
committed
Update update calls to directly use update response without parsing
Signed-off-by: Daniel Widdis <[email protected]>
1 parent db031ba commit 9b09f4c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

plugin/src/main/java/org/opensearch/ml/action/connector/UpdateConnectorTransportAction.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
1010
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_TRUSTED_CONNECTOR_ENDPOINTS_REGEX;
1111

12-
import java.io.IOException;
1312
import java.time.Instant;
1413
import java.util.ArrayList;
1514
import java.util.Arrays;
@@ -228,9 +227,8 @@ private void handleUpdateDataObjectCompletionStage(
228227
updateListener.onFailure(cause);
229228
} else {
230229
try {
231-
UpdateResponse updateResponse = r.parser() == null ? null : UpdateResponse.fromXContent(r.parser());
232-
updateListener.onResponse(updateResponse);
233-
} catch (IOException e) {
230+
updateListener.onResponse(r.updateResponse());
231+
} catch (Exception e) {
234232
updateListener.onFailure(e);
235233
}
236234
}

plugin/src/main/java/org/opensearch/ml/action/models/UpdateModelTransportAction.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ private void buildUpdateRequest(
450450
sdkClient.updateDataObjectAsync(updateDataObjectRequest).whenComplete((ur, ut) -> {
451451
if (ut == null) {
452452
try {
453-
UpdateResponse updateResponse = ur.parser() == null ? null : UpdateResponse.fromXContent(ur.parser());
454-
updateListener.onResponse(updateResponse);
453+
updateListener.onResponse(ur.updateResponse());
455454
} catch (Exception e) {
456455
updateListener.onFailure(e);
457456
}
@@ -503,8 +502,7 @@ private void buildUpdateRequest(
503502
sdkClient.updateDataObjectAsync(updateDataObjectRequest).whenComplete((ur, ut) -> {
504503
if (ut == null) {
505504
try {
506-
UpdateResponse updateResponse = ur.parser() == null ? null : UpdateResponse.fromXContent(ur.parser());
507-
updateListener.onResponse(updateResponse);
505+
updateListener.onResponse(ur.updateResponse());
508506
} catch (Exception e) {
509507
updateListener.onFailure(e);
510508
}

plugin/src/main/java/org/opensearch/ml/model/MLModelManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry;
5656

5757
import java.io.File;
58-
import java.io.IOException;
5958
import java.nio.file.Path;
6059
import java.security.PrivilegedActionException;
6160
import java.time.Instant;
@@ -2271,9 +2270,8 @@ private void handleUpdateDataObjectCompletionStage(
22712270
updateListener.onFailure(cause);
22722271
} else {
22732272
try {
2274-
UpdateResponse updateResponse = r.parser() == null ? null : UpdateResponse.fromXContent(r.parser());
2275-
updateListener.onResponse(updateResponse);
2276-
} catch (IOException e) {
2273+
updateListener.onResponse(r.updateResponse());
2274+
} catch (Exception e) {
22772275
updateListener.onFailure(e);
22782276
}
22792277
}

plugin/src/main/java/org/opensearch/ml/task/MLTaskManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,8 @@ private void handleUpdateDataObjectCompletionStage(
505505
updateListener.onFailure(cause);
506506
} else {
507507
try {
508-
UpdateResponse updateResponse = r.parser() == null ? null : UpdateResponse.fromXContent(r.parser());
509-
updateListener.onResponse(updateResponse);
510-
} catch (IOException e) {
508+
updateListener.onResponse(r.updateResponse());
509+
} catch (Exception e) {
511510
updateListener.onFailure(e);
512511
}
513512
}

0 commit comments

Comments
 (0)