ToStringStyle registry may retain entries between invocations - is this a 
problem?
----------------------------------------------------------------------------------

                 Key: LANG-792
                 URL: https://issues.apache.org/jira/browse/LANG-792
             Project: Commons Lang
          Issue Type: Bug
            Reporter: Sebb


The class ToStringStyle maintains a registry in order to try to detect object 
cycles (introduced by LANG-69).

Multiple instances in the same thread share the same registry (it's a 
ThreadLocal - not clear why).
Entries can be left in the registry on return from calling various methods on 
the instance.
Is this a bug? Can object cycles cause problems across method calls?
If it is intended for the registered objects to remain across method calls, can 
objects from different instances interfere with each other?

The registry uses a WeakHashMap, so the entries should not cause problems for 
garbage collection.

One solution would be to use an instance field to hold the map instead of 
sharing them.
Would that use more memory, or be otherwise less efficient?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to