You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Andrey Gura (JIRA)" <ji...@apache.org> on 2017/08/04 12:11:00 UTC

[jira] [Commented] (IGNITE-602) [Test] GridToStringBuilder is vulnerable for StackOverflowError caused by infinite recursion

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

Andrey Gura commented on IGNITE-602:
------------------------------------

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)