This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 293425a8db3 Fix ClassCastException when reading ZooKeeper config
properties (#38152)
293425a8db3 is described below
commit 293425a8db3c2823d120bc15983c1b0a7c46390a
Author: ZIHAN DAI <[email protected]>
AuthorDate: Mon Feb 23 14:58:19 2026 +1100
Fix ClassCastException when reading ZooKeeper config properties (#38152)
Properties values from YAML/URL configuration are stored as Strings,
but getZookeeperConfiguration() casts them directly to int via
(int) props.get(...), which throws ClassCastException.
Use Integer.parseInt(props.get(...).toString()) to safely handle
both String and Integer property values.
---
.../core/job/statistics/collect/StatisticsCollectJobWorker.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
index ea7b984c44f..c7f73ad68a5 100644
---
a/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
+++
b/kernel/schedule/core/src/main/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorker.java
@@ -88,16 +88,16 @@ public final class StatisticsCollectJobWorker {
// TODO Merge registry center code in ElasticJob and ShardingSphere
mode; Use SPI to load impl
ZookeeperConfiguration result = new
ZookeeperConfiguration(repositoryConfig.getServerLists(), namespace);
Properties props = repositoryConfig.getProps();
- int retryIntervalMilliseconds =
props.containsKey("retryIntervalMilliseconds") ? (int)
props.get("retryIntervalMilliseconds") : 500;
- int maxRetries = props.containsKey("maxRetries") ? (int)
props.get("maxRetries") : 3;
+ int retryIntervalMilliseconds =
props.containsKey("retryIntervalMilliseconds") ?
Integer.parseInt(props.get("retryIntervalMilliseconds").toString()) : 500;
+ int maxRetries = props.containsKey("maxRetries") ?
Integer.parseInt(props.get("maxRetries").toString()) : 3;
result.setBaseSleepTimeMilliseconds(retryIntervalMilliseconds);
result.setMaxRetries(maxRetries);
result.setMaxSleepTimeMilliseconds(retryIntervalMilliseconds *
maxRetries);
- int timeToLiveSeconds = props.containsKey("timeToLiveSeconds") ? (int)
props.get("timeToLiveSeconds") : 60;
+ int timeToLiveSeconds = props.containsKey("timeToLiveSeconds") ?
Integer.parseInt(props.get("timeToLiveSeconds").toString()) : 60;
if (0 != timeToLiveSeconds) {
result.setSessionTimeoutMilliseconds(timeToLiveSeconds * 1000);
}
- int operationTimeoutMilliseconds =
props.containsKey("operationTimeoutMilliseconds") ? (int)
props.get("operationTimeoutMilliseconds") : 500;
+ int operationTimeoutMilliseconds =
props.containsKey("operationTimeoutMilliseconds") ?
Integer.parseInt(props.get("operationTimeoutMilliseconds").toString()) : 500;
if (0 != operationTimeoutMilliseconds) {
result.setConnectionTimeoutMilliseconds(operationTimeoutMilliseconds);
}