ctubbsii commented on code in PR #5876:
URL: https://github.com/apache/accumulo/pull/5876#discussion_r2342363261


##########
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletAvailabilityUtil.java:
##########
@@ -25,55 +25,37 @@
 public class TabletAvailabilityUtil {
 
   public static TabletAvailability fromThrift(TTabletAvailability 
tAvailability) {
-    switch (tAvailability) {
-      case HOSTED:
-        return TabletAvailability.HOSTED;
-      case UNHOSTED:
-        return TabletAvailability.UNHOSTED;
-      case ONDEMAND:
-        return TabletAvailability.ONDEMAND;
-      default:
-        throw new IllegalArgumentException("Unhandled value for TAvailability: 
" + tAvailability);
-    }
+    return switch (tAvailability) {
+      case HOSTED -> TabletAvailability.HOSTED;
+      case UNHOSTED -> TabletAvailability.UNHOSTED;
+      case ONDEMAND -> TabletAvailability.ONDEMAND;
+    };

Review Comment:
   So, I guess the new syntax requires that the set be exhaustive. So, you 
don't need a default case if you specify all the possible enums. However, you 
still need a default case if you want to handle `null` in the same way. So, 
effectively, many of these have stopped throwing IllegalStateException, and now 
probably throw NullPointerException instead. That is probably okay in many 
places... but I haven't looked at all of them to be sure that it's okay in all 
cases.



-- 
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]

Reply via email to