Elesticsaerch Java API - XContentBuilder::string()

Hi

Regarding the Elasticsearch Java API 6.0.0

The class org.elasticsearch.common.xcontent.XContentBuilder has a method string() and the signature says it throws an IOException. Here is the implementation:

/**
 * Returns a string representation of the builder (only applicable for text based xcontent).
 */
public String string() throws IOException {
    return bytes().utf8ToString();
}

The bytes() nor the utf8ToString() method declare to throw an IOException.
And the string() method itself does not override from the Releasable nor Flushable interfaces which the XContentBuilder implements.

According to me, the string() method does not need to declare to throw an IOException. My question is whether it is possible to change the API accordingly?

At this moment, I've circumvented the need to catch the IOException by just calling bytes().utf8ToString() directly in stead of using the string() method.

Kind regards

Stefaan Neyts

Please create an issue or a PR in the Elasticsearch repo.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.