[ https://issues.apache.org/jira/browse/HBASE-27995?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751217#comment-17751217 ]
ConfX commented on HBASE-27995: ------------------------------- Hi [~ryakhovskiy.k], Thank you for the reply and also the PR! We tried more values, and it seems that all non-positive values can trigger the failure, e.g., 0. The value is a misconfiguration. However, IMO no matter what the parameter value is the code should not crash on a Null Pointer Exception. A more graceful way is maybe to add a checker for the configuration parameter value and, like you said, just return an empty block instead of a null. We think returning empty block is a more appropriate fix since, in theory, there may be other unchecked misconfigurations causing the same failure. > 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: HBASE-27995.patch, 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)