[
https://issues.apache.org/jira/browse/HBASE-27995?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751004#comment-17751004
]
Konstantin Ryakhovskiy edited comment on HBASE-27995 at 8/4/23 8:00 AM:
------------------------------------------------------------------------
does it make sense to return an empty block instead of null, if there is a
cache miss?
{code:java}
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.getBlock(BlockCacheKey key,
boolean caching, boolean repeat, boolean updateCacheMetrics){code}
then in a few places we will need to change
{code} result = getBlock(...);
if (null != result) ...
{code}
to check if the result is empty (or null or empty)
was (Author: ryakhovskiy.k):
does it make sense to return an empty block instead of null, if there is a
cache miss?
{code:java}
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.getBlock(BlockCacheKey key,
boolean caching, boolean repeat, boolean updateCacheMetrics){code}
> Missing null check in TestHFile
> --------------------------------
>
> Key: HBASE-27995
> URL: https://issues.apache.org/jira/browse/HBASE-27995
> Project: HBase
> Issue Type: Bug
> Reporter: ConfX
> Priority: Critical
> Attachments: reproduce.sh
>
>
> h2. What happened
> After setting
> {{{}hbase.lru.blockcache.hard.capacity.limit.factor=-0.4921875{}}}, running
> test
> {{{}org.apache.hadoop.hbase.io.hfile.TestHFile#testReaderWithAdaptiveLruCombinedBlockCache{}}}results
> in a null pointer exception.
> h2. Where's the problem
> In the test:
> {noformat}
> cachedBlock = combined.getBlock(key, false, false, true);
> try {
> ...
> } finally {
> cachedBlock.release();
> }{noformat}
> However, cacheBlock might not be initialized properly and could be null,
> causing an unhandled NullPointerException.
> h2. How to reproduce
> # set {{hbase.lru.blockcache.hard.capacity.limit.factor}} to {{-0.4921875 }}
> # run
> {{org.apache.hadoop.hbase.io.hfile.TestHFile#testReaderWithAdaptiveLruCombinedBlockCache}}
> you should observe
> {noformat}
> java.lang.NullPointerException
> at
> org.apache.hadoop.hbase.io.hfile.TestHFile.testReaderCombinedCache(TestHFile.java:1052)
> at
> org.apache.hadoop.hbase.io.hfile.TestHFile.testReaderWithAdaptiveLruCombinedBlockCache(TestHFile.java:1011){noformat}
> For an easy reproduction, run the reproduce.sh in the attachment.
> We are happy to provide a patch if this issue is confirmed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)