[ https://issues.apache.org/jira/browse/IGNITE-602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16114287#comment-16114287 ]
Andrey Gura edited comment on IGNITE-602 at 8/4/17 12:13 PM: ------------------------------------------------------------- Hi, [~SomeFire] I think we can improve a couple of things in this implementation^ 1. Need to avoid double look up of value from {{IdentityHashMap}} (the first - {{isSaved()}} method, and the second - {{getPostion()}}). One call of map.get() is enough. 2. It's hard enough to identify what exactly object referenced by {{\{position N\}}} expression. Better solution is referenced object label. For example result string will be look like this {{Node@62101a6c \[name=n1, next=Node \[name=n2, next=Node \[name=n3, next=Node@62101a6c\]]]}} where label starts with {{@}} character and represent hex string of identity hash code: {{Integer.toHexString(System.identityHashCode(some_obj))}}. Could you please tests that checks that resulting string is correct because in current implementation index calculation is wrong. Also please fix code style issues. was (Author: agura): Hi, [~SomeFire] I think we can improve a couple of things in this implementation^ 1. Need to avoid double look up of value from {{IdentityHashMap}} (the first - {{isSaved()}} method, and the second - {{getPostion()}}). One call of map.get() is enough. 2. It's hard enough to identify what exactly object referenced by {{\{position N\}}} expression. Better solution is referenced object label. For example result string will be look like this {{Node@62101a6c \[name=n1, next=Node \[name=n2, next=Node \[name=n3, next=Node@62101a6c\]]]}} where label starts with {{@}} character and represent hex string of identity hash code: {{Integer.toHexString(System.identityHashCode(some_obj))}}. Also please fix code style issues. > [Test] GridToStringBuilder is vulnerable for StackOverflowError caused by > infinite recursion > -------------------------------------------------------------------------------------------- > > Key: IGNITE-602 > URL: https://issues.apache.org/jira/browse/IGNITE-602 > Project: Ignite > Issue Type: Bug > Components: general > Reporter: Artem Shutak > Assignee: Ryabov Dmitrii > Labels: MakeTeamcityGreenAgain, Muted_test > Fix For: 2.2 > > > See test > org.gridgain.grid.util.tostring.GridToStringBuilderSelfTest#_testToStringCheckAdvancedRecursionPrevention > and related TODO in same source file. > Also take a look at > http://stackoverflow.com/questions/11300203/most-efficient-way-to-prevent-an-infinite-recursion-in-tostring > Test should be unmuted on TC after fix. -- This message was sent by Atlassian JIRA (v6.4.14#64029)