Skip to content

avoid accidental duplication of editing target impls - #7236

Merged
kevinushey merged 1 commit into
masterfrom
bugfix/data-viewer-duplicate-instantiations
Jun 26, 2020
Merged

kevinushey merged 1 commit into
masterfrom
bugfix/data-viewer-duplicate-instantiations

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

This PR fixes a somewhat long-standing issue, where calling getDefaultNamePrefix() could cause the instantiation of a separate, standalone EditingTarget; separate from the one actually used. See #7066 (comment) for extra investigation.

If I understand correctly, the assumption we were making was that, for a single Provider<Foo> foo instance, calling foo.get() would return a reference to the same Foo instance. This appears to not be the case; each invocation of get() may return a reference to a separate instance entirely.

We resolve this issue by de-coupling name provision from the editing target source class. Instead, we create a simple interface that takes an EditingTarget, and returns a default name prefix given that target. That interface can then just delegate back to target.getDefaultNamePrefix(), which helps ensure that we're using the same already-initialized target as opposed to a separate instance provided by dependency injection.

@adamconroy

Copy link
Copy Markdown
Contributor

This makes it much more clear what's going on and gives us a straighter line from the function call to the object we like. Thank you! Are we able to also push this into Water Lily for the release or would you prefer to keep it a v1.4 fix? Thoughts @jmcphers ?

@jmcphers jmcphers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This LGTM but is a little scary to take for 1.3. Do we know why 1.3 (and 1.3 only, not 1.1, 1.2, or 1.4) repros bug #7066? I'm wondering if the fact that this isn't broken everywhere suggests that there is something much simpler we could change that would work around the issue without this more fundamental change. If this is indeed the simplest change then I think we should hold off until Giant Goldenrod.

Also wonder if we should create our own version of Provider<T> that caches the object for the first get() and serves it for subsequent get() invocations so we have a generalized approach to this problem.

@kevinushey

Copy link
Copy Markdown
Collaborator Author

I just tried porting this change locally to v1.3 and while it fixes the exception here it doesn't actually fix the issue with the data viewer failing to update. 😞

At least that signals that this is safe to take for v1.4 and ignore for v1.3 (since something else must be going on there)

@kevinushey

Copy link
Copy Markdown
Collaborator Author

Also wonder if we should create our own version of Provider that caches the object for the first get() and serves it for subsequent get() invocations so we have a generalized approach to this problem.

Definitely agree this is worth doing. I'll file a separate v1.4 issue for this.

@adamconroy

adamconroy commented Jun 26, 2020 •

Copy link
Copy Markdown
Contributor

Ok if this doesn't actually fix the DataViewer updating then something else is going on (likely after the exception), and probably something I can now more easily debug and fix. I propose that we get this change into Giant Goldenrod and I'll fix #7066 in there since I think this exception is blocking the underlying issue at the moment.

I'm cherry-picking this commit into Water Lily right now and seeing if my original theories about the updating are correct.

@jmcphers

Copy link
Copy Markdown
Member

I propose that we get this change into Giant Goldenrod and I'll fix #7066 in there since I think this exception is blocking the underlying issue at the moment.

👍

@adamconroy

Copy link
Copy Markdown
Contributor

Great thanks, I'll move it the bug milestone and cherry pick this change into GG when we start building it.

@kevinushey

Copy link
Copy Markdown
Collaborator Author

I'll merge this to master for now -- @adamconroy feel free to cherry-pick after.

@kevinushey
kevinushey merged commit 1e1a0bd into master Jun 26, 2020
@valerie-rstudio
valerie-rstudio deleted the bugfix/data-viewer-duplicate-instantiations branch January 21, 2022 17:35
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.

3 participants