Skip to content

Commit

Permalink
MID-7030: Fixed thread safety in AbstractLazy
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed May 3, 2021
1 parent 2c893ac commit 296daf6
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -8,20 +8,21 @@

public abstract class AbstractLazy<T> {

private Object value;
private volatile Object value;

AbstractLazy(Object supplier) {
value = supplier;
}

T unwrap() {
if (value instanceof Lazy.Supplier<?>) {
Object val = this.value;
if (val instanceof Lazy.Supplier<?>) {
//noinspection unchecked
value = ((Lazy.Supplier<T>) value).get();
this.value = ((Lazy.Supplier<T>) val).get();
return unwrap();
}
//noinspection unchecked
return (T) value;
return (T) val;
}

@Override
Expand Down

0 comments on commit 296daf6

Please sign in to comment.