maedhroz commented on code in PR #3955:
URL: https://github.com/apache/cassandra/pull/3955#discussion_r1989833158
##########
src/java/org/apache/cassandra/exceptions/RequestFailureReason.java:
##########
@@ -53,26 +59,31 @@ public enum RequestFailureReason
this.code = code;
}
- private static final RequestFailureReason[] codeToReasonMap;
+ private static final Map<Integer, RequestFailureReason> codeToReasonMap =
new HashMap<>();
+ private static final Map<Class<? extends Throwable>, RequestFailureReason>
exceptionToReasonMap = new HashMap<>();
static
{
RequestFailureReason[] reasons = values();
- int max = -1;
- for (RequestFailureReason r : reasons)
- max = max(r.code, max);
-
- RequestFailureReason[] codeMap = new RequestFailureReason[max + 1];
-
for (RequestFailureReason reason : reasons)
{
- if (codeMap[reason.code] != null)
+ if (codeToReasonMap.put(reason.code, reason) != null)
throw new RuntimeException("Two RequestFailureReason-s that
map to the same code: " + reason.code);
Review Comment:
```suggestion
throw new RuntimeException("Two RequestFailureReasons that
map to the same code: " + reason.code);
```
Not sure what the dash was doing in there...
--
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]