DomGarguilo commented on code in PR #5876:
URL: https://github.com/apache/accumulo/pull/5876#discussion_r2342325491
##########
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 think things are handled in an improved way in Java 17. If a new enum
is added and we don't update this switch statement, we will get a compile-time
error when trying to build. A null value will still throw a NPE just like
before. So essentially we move from a runtime exception to a compile-time error.
--
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]