Skip to content

Commit c0b97b2

Browse files
committed
Async review
1 parent d67b5c2 commit c0b97b2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/main/java/oracle/kubernetes/operator/work/FiberGate.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@ public void onThrowable(Packet packet, Throwable throwable) {
5555

5656
private static class WaitForOldFiberStep extends Step {
5757
private final AtomicReference<Fiber> old;
58-
private WaitForOldFiberStep current;
58+
private final AtomicReference<WaitForOldFiberStep> current;
5959

6060
public WaitForOldFiberStep(Fiber old, Step next) {
6161
super(next);
6262
this.old = new AtomicReference<>(old);
63-
current = this;
63+
current = new AtomicReference<>(this);
6464
}
6565

6666
@Override
6767
public NextAction apply(Packet packet) {
68-
Fiber o = current != null ? current.old.getAndSet(null) : null;
68+
WaitForOldFiberStep c = current.get();
69+
Fiber o = c != null ? c.old.getAndSet(null) : null;
6970
if (o == null) {
7071
return doNext(packet);
7172
}
@@ -74,13 +75,13 @@ public NextAction apply(Packet packet) {
7475
boolean isWillCall = o.cancelAndExitCallback(true, new ExitCallback() {
7576
@Override
7677
public void onExit() {
77-
current = o.getSPI(WaitForOldFiberStep.class);
78+
current.set(o.getSPI(WaitForOldFiberStep.class));
7879
fiber.resume(packet);
7980
}
8081
});
8182

8283
if (!isWillCall) {
83-
current = o.getSPI(WaitForOldFiberStep.class);
84+
current.set(o.getSPI(WaitForOldFiberStep.class));
8485
fiber.resume(packet);
8586
}
8687
});

src/main/java/oracle/kubernetes/operator/work/Packet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
import java.util.AbstractMap;
77
import java.util.Collections;
8-
import java.util.HashMap;
98
import java.util.Map;
109
import java.util.Set;
10+
import java.util.concurrent.ConcurrentHashMap;
1111

1212
/**
1313
* Context of a single processing flow. Acts as a map and as a registry of components.
1414
*
1515
*/
1616
public class Packet extends AbstractMap<String, Object> implements ComponentRegistry, ComponentEx {
17-
private final Map<String, Component> components = new HashMap<String, Component>();
18-
private final Map<String, Object> delegate = new HashMap<String, Object>();
17+
private final Map<String, Component> components = new ConcurrentHashMap<String, Component>();
18+
private final Map<String, Object> delegate = new ConcurrentHashMap<String, Object>();
1919

2020
public Packet() {}
2121

0 commit comments

Comments
 (0)