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

Store reference inside Lazy when Lazy is marked (CDI integration) #386

Merged
merged 2 commits into from
Jul 13, 2022
Merged

Store reference inside Lazy when Lazy is marked (CDI integration) #386

merged 2 commits into from
Jul 13, 2022

Conversation

rdebusscher
Copy link

When a Lazy reference is marked by developer, the instance inside the Lazy is also stored as that is probably the intention (and makes working and clearing with Lazy references easier).

@rdebusscher rdebusscher added this to the 07.01.00 milestone Jul 11, 2022
@rdebusscher rdebusscher requested a review from fh-ms July 11, 2022 12:47
@rdebusscher rdebusscher self-assigned this Jul 11, 2022
@@ -155,6 +155,10 @@ void initializePump()

public void storeChanged(final Object dirtyInstance, final boolean clearLazy)
{
if (dirtyInstance instanceof Lazy) {
// When a Lazy is marked, the developer probably wants to store the referenced instance in the Lazy.
this.manager.store(((Lazy<?>) dirtyInstance).get());
Copy link
Contributor

Choose a reason for hiding this comment

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

Lazy#get always loads the reference. I would recommend to use Lazy#peek

Object lazyRef = ((Lazy<?>)dirtyInstance).peek();
if(lazyRef != null)
{
  this.manager.store(lazyRef);
}

@rdebusscher rdebusscher marked this pull request as ready for review July 12, 2022 08:00
@rdebusscher rdebusscher merged commit 4a99c88 into microstream-one:master Jul 13, 2022
@rdebusscher rdebusscher deleted the cdi_lazy branch August 10, 2022 10:15
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