[ 
https://issues.apache.org/jira/browse/AVRO-1923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15523879#comment-15523879
 ] 

Doug Cutting commented on AVRO-1923:
------------------------------------

Elsewhere in Avro we handle circular structures by keeping track of previously 
seen objects, with no limit on the depth of circularity.  So this might instead 
look something like:
{code}
public String toString(Object o, StringBuffer b) {
  return toStringInternal(o, b, new IdentityHashMap());
}
public String toString(Object o, StringBuffer b, Map seen) {
  if (seen.containsKey(o))
    return ... ; // circle detected 
  try {
    seen.put(o, o);
    ... prior toString logic ...
  } finally {
    seen.remove(o);
  }
}
{code}

> Recursive record causes StackOverflow in GenericData.toString
> -------------------------------------------------------------
>
>                 Key: AVRO-1923
>                 URL: https://issues.apache.org/jira/browse/AVRO-1923
>             Project: Avro
>          Issue Type: Bug
>            Reporter: Niels Basjes
>            Assignee: Niels Basjes
>         Attachments: AVRO-1923-Unittest.patch
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to