Skip to content

Commit

Permalink
Modify Custom's fromXContent
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
shiv0408 committed Mar 15, 2024
1 parent adb4cf2 commit 0b38736
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,8 @@ public interface Custom extends NamedDiffable<Custom>, ToXContentFragment, Clust
EnumSet<XContentContext> context();

static Custom fromXContent(XContentParser parser, String name) throws IOException {
try {
return parser.namedObject(Custom.class, name, null);
} catch (NamedObjectNotFoundException e) {
logger.warn("Unknown custom object with type {}", name);
parser.skipChildren();
throw e;
}
// handling any Exception is caller's responsibility
return parser.namedObject(Custom.class, name, null);
}

static Custom fromXContent(XContentParser parser) throws IOException {
Expand Down Expand Up @@ -1849,6 +1844,7 @@ public static Metadata fromXContent(XContentParser parser) throws IOException {
builder.putCustom(custom.getWriteableName(), custom);
} catch (NamedObjectNotFoundException ex) {
logger.warn("Skipping unknown custom object with type {}", currentFieldName);
parser.skipChildren();
}
}
} else if (token.isValue()) {
Expand Down

0 comments on commit 0b38736

Please sign in to comment.