Skip to content

Commit 33687d3

Browse files
committed
core: Remove useless NPE check for syncContext in PF
It will never throw, because it would only throw if helper is null, but helper is checkNotNull()ed in the constructor. It could have checked for a null return value instead; since it hasn't been, it is clear we don't need this check.
1 parent 8bd9795 commit 33687d3

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

core/src/main/java/io/grpc/internal/PickFirstLeafLoadBalancer.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import io.grpc.EquivalentAddressGroup;
3434
import io.grpc.LoadBalancer;
3535
import io.grpc.Status;
36-
import io.grpc.SynchronizationContext;
3736
import io.grpc.SynchronizationContext.ScheduledHandle;
3837
import java.net.SocketAddress;
3938
import java.util.ArrayList;
@@ -426,16 +425,7 @@ public void run() {
426425
}
427426
}
428427

429-
SynchronizationContext synchronizationContext = null;
430-
try {
431-
synchronizationContext = helper.getSynchronizationContext();
432-
} catch (NullPointerException e) {
433-
// All helpers should have a sync context, but if one doesn't (ex. user had a custom test)
434-
// we don't want to break previously working functionality.
435-
return;
436-
}
437-
438-
scheduleConnectionTask = synchronizationContext.schedule(
428+
scheduleConnectionTask = helper.getSynchronizationContext().schedule(
439429
new StartNextConnection(),
440430
CONNECTION_DELAY_INTERVAL_MS,
441431
TimeUnit.MILLISECONDS,

0 commit comments

Comments
 (0)