From 71a9c7a7a19b5c74ce11ccb9e06484b6bad34050 Mon Sep 17 00:00:00 2001 From: jokercurry <84573424+smallzhongfeng@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:46:01 +0800 Subject: [PATCH] [MINOR][0.7] Avoid returning null in defaultUserApps when quota file does't config user (#822) ### What changes were proposed in this pull request? `map.getOrDefault()` => `map.computeIfAbsent()` ### Why are the changes needed? If do not define the user and app num in the quota configuration file, it will appear that the `defaultUserApps` does not have the corresponding app number for this user, because we did not include the `quotaAppNum` in the `defaultUserApps`. **before** : The log from coordinator is `[ERROR] 2023-03-28 19:24:11,18 Grpc-260 AccessAppQuotaChecker check - Denied by AccessAppQuotaChecker => User: xxxx, current app num is: 3, default app num is: null.` **after** : The log from coordinator is `[ERROR] 2023-03-31 14:32:21,228 Grpc-240 AccessAppQuotaChecker check - Denied by AccessAppQuotaChecker => User: xxxx, current app num is: 3, default app num is: 3.` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Origin uts. --- .../main/java/org/apache/uniffle/coordinator/QuotaManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coordinator/src/main/java/org/apache/uniffle/coordinator/QuotaManager.java b/coordinator/src/main/java/org/apache/uniffle/coordinator/QuotaManager.java index c9bb635afe..f797a832b8 100644 --- a/coordinator/src/main/java/org/apache/uniffle/coordinator/QuotaManager.java +++ b/coordinator/src/main/java/org/apache/uniffle/coordinator/QuotaManager.java @@ -117,7 +117,7 @@ public void parseQuotaFile(DataInputStream fsDataInputStream) { public boolean checkQuota(String user, String uuid) { Map appAndTimes = currentUserAndApp.computeIfAbsent(user, x -> Maps.newConcurrentMap()); - Integer defaultAppNum = defaultUserApps.getOrDefault(user, quotaAppNum); + Integer defaultAppNum = defaultUserApps.computeIfAbsent(user, x -> quotaAppNum); synchronized (this) { int currentAppNum = appAndTimes.size(); if (currentAppNum >= defaultAppNum) {