adoroszlai commented on code in PR #6926:
URL: https://github.com/apache/ozone/pull/6926#discussion_r1675332588
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/ValidatorRegistry.java:
##########
@@ -178,13 +179,8 @@ private EnumMap<RequestProcessingPhase, List<Method>>
newPhaseMap() {
return new EnumMap<>(RequestProcessingPhase.class);
}
- private <K, V> V getAndInitialize(K key, V defaultValue, Map<K, V> from) {
- V inMapValue = from.get(key);
- if (inMapValue == null || !from.containsKey(key)) {
- from.put(key, defaultValue);
- return defaultValue;
- }
- return inMapValue;
+ private <K, V> V getAndInitialize(K key, Supplier<V> defaultSupplier, Map<K,
V> from) {
+ return from.computeIfAbsent(key, k -> defaultSupplier.get());
Review Comment:
Yes, it can be inlined. I kept it to make the change easier to see.
--
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]