kaijchen commented on a change in pull request #3206:
URL: https://github.com/apache/ozone/pull/3206#discussion_r830595945



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java
##########
@@ -585,11 +586,15 @@ protected static long sumBlockLengths(OmKeyInfo 
omKeyInfo) {
   /**
    * Return bucket info for the specified bucket.
    */
+  @Nullable
   protected OmBucketInfo getBucketInfo(OMMetadataManager omMetadataManager,
       String volume, String bucket) {
-    return omMetadataManager.getBucketTable().getCacheValue(
-        new CacheKey<>(omMetadataManager.getBucketKey(volume, bucket)))
-        .getCacheValue();
+    String bucketKey = omMetadataManager.getBucketKey(volume, bucket);
+
+    CacheValue<OmBucketInfo> value = omMetadataManager.getBucketTable()
+        .getCacheValue(new CacheKey<>(bucketKey));
+
+    return value != null ? value.getCacheValue() : null;

Review comment:
       When the given `bucketKey` is not exist in cache, or the cached value is 
`null`.
   The original code will throw NPE at `value.getCacheValue()` in the first 
case.




-- 
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]

Reply via email to