[ 
https://issues.apache.org/jira/browse/HBASE-28451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ConfX updated HBASE-28451:
--------------------------
    Description: 
*1. What happened*
After setting `hfile.block.cache.policy=AdaptiveLRU`, running test 
`org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
 results in a casting error.
 

*2. Where's the problem*
In line 64 of `PooledRemoteClient`:
```java
    FirstLevelBlockCache lbc = cbc.l1Cache;
...
    // Force evictions by putting in a block too big.
    final long justTooBigSize = ((LruBlockCache) lbc).acceptableSize() + 1;
```
However, lbc does not necessarily need to be a LruBlockCache, leading to a 
potential `ClassCastException`
 

*3. How to reproduce*
1. set `hfile.block.cache.policy` to `AdaptiveLRU `
2. run 
`org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
you should observe
```
java.lang.ClassCastException: class 
org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache cannot be cast to class 
org.apache.hadoop.hbase.io.hfile.LruBlockCache 
(org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache and 
org.apache.hadoop.hbase.io.hfile.LruBlockCache are in unnamed module of loader 
'app')
at 
org.apache.hadoop.hbase.io.hfile.TestCacheConfig.testBucketCacheConfigL1L2Setup(TestCacheConfig.java:342)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
```

  was:
## What happened
After setting `hfile.block.cache.policy=AdaptiveLRU`, running test 
`org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
 results in a casting error.
 
## Where's the problem
In line 64 of `PooledRemoteClient`:
```java
    FirstLevelBlockCache lbc = cbc.l1Cache;
...
    // Force evictions by putting in a block too big.
    final long justTooBigSize = ((LruBlockCache) lbc).acceptableSize() + 1;
```
However, lbc does not necessarily need to be a LruBlockCache, leading to a 
potential `ClassCastException`
 
## How to reproduce
1. set `hfile.block.cache.policy` to `AdaptiveLRU `
2. run 
`org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
you should observe
```
java.lang.ClassCastException: class 
org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache cannot be cast to class 
org.apache.hadoop.hbase.io.hfile.LruBlockCache 
(org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache and 
org.apache.hadoop.hbase.io.hfile.LruBlockCache are in unnamed module of loader 
'app')
at 
org.apache.hadoop.hbase.io.hfile.TestCacheConfig.testBucketCacheConfigL1L2Setup(TestCacheConfig.java:342)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
```


> Cast without checking in TestCacheConfig
> ----------------------------------------
>
>                 Key: HBASE-28451
>                 URL: https://issues.apache.org/jira/browse/HBASE-28451
>             Project: HBase
>          Issue Type: Bug
>            Reporter: ConfX
>            Priority: Major
>
> *1. What happened*
> After setting `hfile.block.cache.policy=AdaptiveLRU`, running test 
> `org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
>  results in a casting error.
>  
> *2. Where's the problem*
> In line 64 of `PooledRemoteClient`:
> ```java
>     FirstLevelBlockCache lbc = cbc.l1Cache;
> ...
>     // Force evictions by putting in a block too big.
>     final long justTooBigSize = ((LruBlockCache) lbc).acceptableSize() + 1;
> ```
> However, lbc does not necessarily need to be a LruBlockCache, leading to a 
> potential `ClassCastException`
>  
> *3. How to reproduce*
> 1. set `hfile.block.cache.policy` to `AdaptiveLRU `
> 2. run 
> `org.apache.hadoop.hbase.io.hfile.TestCacheConfig#testBucketCacheConfigL1L2Setup`
> you should observe
> ```
> java.lang.ClassCastException: class 
> org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache cannot be cast to 
> class org.apache.hadoop.hbase.io.hfile.LruBlockCache 
> (org.apache.hadoop.hbase.io.hfile.LruAdaptiveBlockCache and 
> org.apache.hadoop.hbase.io.hfile.LruBlockCache are in unnamed module of 
> loader 'app')
> at 
> org.apache.hadoop.hbase.io.hfile.TestCacheConfig.testBucketCacheConfigL1L2Setup(TestCacheConfig.java:342)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)
> at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to