From 7823d3a4f3edf348514ef2486ba6819a7ca0c964 Mon Sep 17 00:00:00 2001 From: Zach Date: Wed, 17 Nov 2021 15:28:01 -0600 Subject: [PATCH] locate the pace for cyclic check --- src/main/java/org/json/JSONObject.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index 761df1d..8891673 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -1540,10 +1540,12 @@ public class JSONObject { try { final Object result = method.invoke(bean); if (result != null) { + // check cyclic dependency and throw error if needed + this.map.put(key, wrap(result)); // we don't use the result anywhere outside of wrap // if it's a resource we should be sure to close it - // after calling toString + // after calling toString if (result instanceof Closeable) { try { ((Closeable) result).close();