maedhroz commented on code in PR #3955: URL: https://github.com/apache/cassandra/pull/3955#discussion_r1989873378
########## src/java/org/apache/cassandra/exceptions/RequestFailureReason.java: ########## @@ -81,25 +92,18 @@ public static RequestFailureReason fromCode(int code) throw new IllegalArgumentException("RequestFailureReason code must be non-negative (got " + code + ')'); // be forgiving and return UNKNOWN if we aren't aware of the code - for forward compatibility - return code < codeToReasonMap.length ? codeToReasonMap[code] : UNKNOWN; + return codeToReasonMap.getOrDefault(code, UNKNOWN); } public static RequestFailureReason forException(Throwable t) { - if (t instanceof TombstoneOverwhelmingException) - return READ_TOO_MANY_TOMBSTONES; - - if (t instanceof IncompatibleSchemaException) - return INCOMPATIBLE_SCHEMA; - - if (t instanceof NotCMSException) - return NOT_CMS; - - if (t instanceof InvalidRoutingException) - return INVALID_ROUTING; + RequestFailureReason r = exceptionToReasonMap.get(t.getClass()); + if (r != null) + return r; - if (t instanceof CoordinatorBehindException) - return COORDINATOR_BEHIND; + for (Map.Entry<Class<? extends Throwable>, RequestFailureReason> entry : exceptionToReasonMap.entrySet()) + if (entry.getKey().isInstance(t)) + return entry.getValue(); Review Comment: So `forException()` is actually now mapping `TIMEOUT`, `READ_SIZE`, and `INDEX_NOT_AVAILABLE` where it wasn't before, correct? Just wanted to make sure that was intended (and a little curious about why there weren't already mapped...) -- 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: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org