Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stackoverflow on RealmAny toString #7479

Open
wants to merge 3 commits into
base: releases
Choose a base branch
from

Conversation

clementetb
Copy link
Collaborator

Fixes StackOverflow when converting to string a DynamicRealmObject containing a cycle through a RealmAny field.

@clementetb clementetb requested a review from cmelchior May 20, 2021 11:25
@clementetb clementetb self-assigned this May 20, 2021
@clementetb clementetb changed the base branch from master to support-new-datatypes May 20, 2021 11:25
// if a Realm object don't print the contents as it might end in a cycle.
String tableName = realmAny.asRealmModel(DynamicRealmObject.class).proxyState.getRow$realm().getTable().getClassName();
long objectKey = realmAny.asRealmModel(DynamicRealmObject.class).proxyState.getRow$realm().getObjectKey();
sb.append(String.format(Locale.US, "RealmAny<%s>(id:%d)", tableName, objectKey));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cmelchior , I thought it would be useful to print the object key for discerning between object instances, but not sure if it will confuse users to expose it, ideally we would be showing the PK. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably fine to just show the ObjKey. It is a bit more secret, but easily available. Also, some objects might not have primary keys.

Base automatically changed from support-new-datatypes to master June 14, 2021 20:34
@cmelchior cmelchior changed the base branch from master to releases June 17, 2021 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants