Skip to content

Commit

Permalink
Merge pull request #25032 from geoand/arc-allocations
Browse files Browse the repository at this point in the history
Save AtomicBoolean allocation in Arc
  • Loading branch information
gastaldi authored Apr 20, 2022
2 parents 7004f79 + dda7265 commit 957ed4e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.enterprise.context.BeforeDestroyed;
Expand Down Expand Up @@ -168,7 +167,7 @@ public void destroy(ContextState state) {
}
if (state instanceof RequestContextState) {
RequestContextState reqState = ((RequestContextState) state);
reqState.isValid.set(false);
reqState.isValid = false;
synchronized (state) {
Map<Contextual<?>, ContextInstanceHandle<?>> map = ((RequestContextState) state).map;
// Fire an event with qualifier @BeforeDestroyed(RequestScoped.class) if there are any observers for it
Expand Down Expand Up @@ -228,11 +227,12 @@ private static Notifier<Object> createDestroyedNotifier() {
static class RequestContextState implements ContextState {

private final Map<Contextual<?>, ContextInstanceHandle<?>> map;
private final AtomicBoolean isValid;

private volatile boolean isValid;

RequestContextState(ConcurrentMap<Contextual<?>, ContextInstanceHandle<?>> value) {
this.map = Objects.requireNonNull(value);
this.isValid = new AtomicBoolean(true);
this.isValid = true;
}

@Override
Expand All @@ -243,7 +243,7 @@ public Map<InjectableBean<?>, Object> getContextualInstances() {

@Override
public boolean isValid() {
return isValid.get();
return isValid;
}

}
Expand Down

0 comments on commit 957ed4e

Please sign in to comment.