Skip to content

Commit 44b9a8d

Browse files
chishuiparv0201
authored andcommitted
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 9946f61 commit 44b9a8d

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

Lines changed: 3 additions & 0 deletions
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)