Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

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

Merged
rdebusscher merged 2 commits intomicrostream-one:masterfrom
rdebusscher:cdi_lazy
Jul 13, 2022
Merged

Store reference inside Lazy when Lazy is marked (CDI integration)#386
rdebusscher merged 2 commits intomicrostream-one:masterfrom
rdebusscher:cdi_lazy

Conversation

@rdebusscher
Copy link
Copy Markdown

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
{
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants