Skip to content

Commit e26213a

Browse files
authored
RATIS-2336. PeerProxyMap.getProxy() could return null. (#1290)
1 parent 2e34f6e commit e26213a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ratis-common/src/main/java/org/apache/ratis/util/PeerProxyMap.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ RaftPeer getPeer() {
5959
}
6060

6161
PROXY getProxy() throws IOException {
62-
if (proxy == null) {
62+
final PROXY p = proxy;
63+
if (p != null) {
64+
return p;
65+
} else {
6366
synchronized (this) {
6467
if (proxy == null) {
6568
final LifeCycle.State current = lifeCycle.getCurrentState();
@@ -69,9 +72,9 @@ PROXY getProxy() throws IOException {
6972
lifeCycle.startAndTransition(
7073
() -> proxy = createProxyImpl(peer), IOException.class);
7174
}
75+
return Objects.requireNonNull(proxy, "proxy");
7276
}
7377
}
74-
return proxy;
7578
}
7679

7780
Optional<PROXY> setNullProxyAndClose() {

0 commit comments

Comments
 (0)