Skip to content

Commit

Permalink
Implement Custom interface parse method in Connector interface
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed May 10, 2024
1 parent d3fdbdb commit 79b2e1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ static Connector createConnector(XContentBuilder builder, String connectorProtoc
throw illegalArgumentException;
}
}


@Override
default Custom parse(XContentParser parser) throws IOException {
return createConnector(parser);
}

@SuppressWarnings("removal")
static Connector createConnector(XContentParser parser) throws IOException {
Expand Down
4 changes: 3 additions & 1 deletion common/src/main/java/org/opensearch/sdk/Custom.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentParser;

import java.io.IOException;

/**
* Custom metadata.
*/
public interface Custom extends ToXContentObject {
Custom parse(XContentParser parser);
Custom parse(XContentParser parser) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public CompletionStage<GetCustomResponse> getCustom(GetCustomRequest request) {
.complete(
new GetCustomResponse.Builder().id(r.getId()).custom(request.clazz().cast(new Object()).parse(parser)).build()
);
} catch (Exception e) {
} catch (IOException e) {
// Parsing error
future.completeExceptionally(e);
}
Expand Down

0 comments on commit 79b2e1f

Please sign in to comment.