You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/02/22 18:16:54 UTC

[I] [Bug] ClassCastException in StatisticsCollectJobWorker when ZooKeeper properties are Strings [shardingsphere]

PDGGK opened a new issue, #38151:
URL: https://github.com/apache/shardingsphere/issues/38151

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master (latest)
   
   ### Which project did you use? ShardingSphere-Proxy or ShardingSphere-JDBC?
   ShardingSphere-Proxy
   
   ### Expected behavior
   ZooKeeper configuration properties (retryIntervalMilliseconds, maxRetries, timeToLiveSeconds, operationTimeoutMilliseconds) should be parsed correctly regardless of whether they are stored as String or Integer values.
   
   ### Actual behavior
   `StatisticsCollectJobWorker.getZookeeperConfiguration()` uses `(int) props.get(...)` to read properties. When properties come from YAML configuration or URL parameters, they are stored as Strings (e.g., `"500"` instead of `500`), causing a `ClassCastException: java.lang.String cannot be cast to java.lang.Integer`.
   
   ### Reason analyze
   `Properties` extends `Hashtable<Object, Object>`. Values loaded from YAML config or URL query parameters (via `ShardingSphereURL`) are always Strings. The direct `(int)` cast assumes Integer objects.
   
   **Affected lines in `StatisticsCollectJobWorker.java`:**
   - Line 91: `(int) props.get("retryIntervalMilliseconds")`
   - Line 92: `(int) props.get("maxRetries")`
   - Line 96: `(int) props.get("timeToLiveSeconds")`
   - Line 100: `(int) props.get("operationTimeoutMilliseconds")`
   
   ### Steps to reproduce
   Configure ShardingSphere-Proxy with ZooKeeper mode using YAML configuration that includes numeric properties as strings (which is the default YAML parsing behavior).
   
   ### Fix
   Use `Integer.parseInt(props.get(...).toString())` to safely handle both String and Integer property values.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] ClassCastException in StatisticsCollectJobWorker when ZooKeeper properties are Strings [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #38151: [Bug] ClassCastException in StatisticsCollectJobWorker when ZooKeeper properties are Strings
URL: https://github.com/apache/shardingsphere/issues/38151


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org