LuciferYang commented on code in PR #43349:
URL: https://github.com/apache/spark/pull/43349#discussion_r1357888098
##########
common/network-common/src/main/java/org/apache/spark/network/util/NettyUtils.java:
##########
@@ -65,38 +65,26 @@ public static ThreadFactory createThreadFactory(String
threadPoolPrefix) {
public static EventLoopGroup createEventLoop(IOMode mode, int numThreads,
String threadPrefix) {
ThreadFactory threadFactory = createThreadFactory(threadPrefix);
- switch (mode) {
- case NIO:
- return new NioEventLoopGroup(numThreads, threadFactory);
- case EPOLL:
- return new EpollEventLoopGroup(numThreads, threadFactory);
- default:
- throw new IllegalArgumentException("Unknown io mode: " + mode);
- }
+ return switch (mode) {
+ case NIO -> new NioEventLoopGroup(numThreads, threadFactory);
+ case EPOLL -> new EpollEventLoopGroup(numThreads, threadFactory);
Review Comment:
Additionally, if IOMode is extended and this method is not updated in sync,
a compile error will occur to remind the developer to add the corresponding
case branch, so, for this enum matching scenario, `default` is not necessary:)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]