This is an automated email from the ASF dual-hosted git repository.
virajjasani pushed a commit to branch 5.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.3 by this push:
new 885663b7bc PHOENIX-7933 Avoid using reflection to initialize
ServerCacheFactory (#2539)
885663b7bc is described below
commit 885663b7bc8c47ef835c5b8fbe6343870701df2b
Author: Viraj Jasani <[email protected]>
AuthorDate: Sat Jun 20 17:24:11 2026 -0700
PHOENIX-7933 Avoid using reflection to initialize ServerCacheFactory (#2539)
---
.../phoenix/coprocessor/ServerCachingEndpointImpl.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
index 3e616d10a0..eb8921086d 100644
---
a/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
+++
b/phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
@@ -23,6 +23,7 @@ import com.google.protobuf.Service;
import java.io.IOException;
import java.util.Collections;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.coprocessor.CoprocessorException;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
@@ -36,6 +37,8 @@ import
org.apache.phoenix.coprocessor.generated.ServerCachingProtos.RemoveServer
import
org.apache.phoenix.coprocessor.generated.ServerCachingProtos.ServerCachingService;
import
org.apache.phoenix.coprocessorclient.ServerCachingProtocol.ServerCacheFactory;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
+import org.apache.phoenix.index.IndexMetaDataCacheFactory;
+import org.apache.phoenix.join.HashCacheFactory;
import org.apache.phoenix.protobuf.ProtobufUtil;
import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.ClientUtil;
@@ -68,10 +71,15 @@ public class ServerCachingEndpointImpl extends
ServerCachingService implements R
request.hasTxState() ? request.getTxState().toByteArray() :
ByteUtil.EMPTY_BYTE_ARRAY;
try {
- @SuppressWarnings("unchecked")
- Class<ServerCacheFactory> serverCacheFactoryClass =
- (Class<ServerCacheFactory>)
Class.forName(request.getCacheFactory().getClassName());
- ServerCacheFactory cacheFactory = serverCacheFactoryClass.newInstance();
+ String factoryClassName = request.getCacheFactory().getClassName();
+ ServerCacheFactory cacheFactory;
+ if (HashCacheFactory.class.getName().equals(factoryClassName)) {
+ cacheFactory = new HashCacheFactory();
+ } else if
(IndexMetaDataCacheFactory.class.getName().equals(factoryClassName)) {
+ cacheFactory = new IndexMetaDataCacheFactory();
+ } else {
+ throw new DoNotRetryIOException("Disallowed ServerCacheFactory class:
" + factoryClassName);
+ }
tenantCache.addServerCache(new
ImmutableBytesPtr(request.getCacheId().toByteArray()),
cachePtr, txState, cacheFactory,
request.hasHasProtoBufIndexMaintainer() &&
request.getHasProtoBufIndexMaintainer(),