You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing the handling of circular references during JSON serialization, I encountered a StackOverflowError when attempting to serialize a HashMap containing a circular reference via an ArrayList.
@TestpublicvoidtestCircularReferenceHandling() {
// Create a dictionary with a circular reference by appending the dictionary to a list it contains.java.util.HashMap<String, Object> dict = newjava.util.HashMap<>();
java.util.ArrayList<Object> list = newjava.util.ArrayList<>();
dict.put("list", list);
list.add(dict);
// Attempt to serialize the dictionary using a JSON serialization method.JsonWriterwriter = newJsonWriter();
StringWriterstringWriter = newStringWriter();
try {
writer.on(stringWriter).value(dict);
fail("Expected a ValueError to be raised during serialization of dictionary with circular references.");
} catch (IllegalArgumentExceptione) {
}
}
Proposed Solution:
To address this issue, the JsonWriter should implement a mechanism to track visited objects during serialization. If a circular reference is detected, an exception should be thrown to prevent infinite recursion and provide a clear error message.
The text was updated successfully, but these errors were encountered:
Thank you for taking the time to review my issue. I understand it was marked as "not planned," but I’d like to clarify if this is indeed an issue or if it’s due to my misunderstanding of the library’s implementation.
I’m working on a test migration experiment, and the test case is based on a real test from the Java Gson library. I’d greatly appreciate your simple feedback on this.
Thank you for your work on this project, and I look forward to your response!
I’m currently working on an experiment involving test code migration and have spent significant time verifying whether these tests can provide some positive impact for the target library. Your feedback would be very valuable and helpful for my work.
I sincerely hope to hear from you. Thank you so much for your time and consideration!
While testing the handling of circular references during JSON serialization, I encountered a StackOverflowError when attempting to serialize a HashMap containing a circular reference via an ArrayList.
Proposed Solution:
To address this issue, the JsonWriter should implement a mechanism to track visited objects during serialization. If a circular reference is detected, an exception should be thrown to prevent infinite recursion and provide a clear error message.
The text was updated successfully, but these errors were encountered: