Skip to content

Commit bf43678

Browse files
authored
Add comment to XContentBuilder.toString() (opensearch-project#13809)
* Add comment to XContentBuilder.toString Signed-off-by: Liyun Xiu <xiliyun@amazon.com> * Fix typo Signed-off-by: Liyun Xiu <xiliyun@amazon.com> --------- Signed-off-by: Liyun Xiu <xiliyun@amazon.com>
1 parent 896b127 commit bf43678

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libs/core/src/main/java/org/opensearch/core/xcontent/XContentBuilder.java

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ public static XContentBuilder builder(XContent xContent, Set<String> includes, S
157157

158158
/**
159159
* Returns a string representation of the builder (only applicable for text based xcontent).
160+
* Note: explicitly or implicitly (from debugger) calling toString() could cause XContentBuilder
161+
* to close which is a side effect done by @see BytesReference#bytes().
162+
* Trying to write more contents after toString() will cause NPE. Use it with caution.
160163
*/
161164
@Override
162165
public String toString() {

0 commit comments

Comments
 (0)