[
https://issues.apache.org/jira/browse/CURATOR-663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17907642#comment-17907642
]
Zili Chen edited comment on CURATOR-663 at 12/21/24 8:58 PM:
-------------------------------------------------------------
Seems change the type of {{InstanceSpec#customProperties}} could resolve this?
was (Author: tison):
Seems change the type of InstanceSpec could resolve this?
> ZooKeeperServerEmbeddedAdapter.configure might fail with ClassCastException
> ---------------------------------------------------------------------------
>
> Key: CURATOR-663
> URL: https://issues.apache.org/jira/browse/CURATOR-663
> Project: Apache Curator
> Issue Type: Bug
> Components: Framework
> Affects Versions: 5.4.0
> Reporter: Matthias Pohl
> Priority: Major
> Fix For: 5.8.0
>
>
> There might be a {{ClassCastException}} happening when starting the
> {{TestingZooKeeper}} instance. The following test reproduces the issue:
> {code}
> @Test
> public void testTestingZooKeeperServer() throws Exception
> {
> final Map<String, Object> customProperties = new HashMap<>();
> customProperties.put("maxSessionTimeout", 60_000);
> final Path tmpDirPath = Files.createTempDirectory("tmp-");
> final InstanceSpec instanceSpec = new InstanceSpec(tmpDirPath.toFile(), 0,
> 0, 0, true, 0, 10, 1, customProperties, "host-name");
> final QuorumConfigBuilder quorumConfigBuilder = new
> QuorumConfigBuilder(instanceSpec);
> final TestingZooKeeperServer zkServer = new
> TestingZooKeeperServer(quorumConfigBuilder);
> zkServer.start();
> }
> {code}
> The test above will fail with a {{ClassCastException}} because
> {{InstantSpec}} allows a {{Map<String, Object>}} for custom properties, i.e.
> a non-String value like Integer can be used.
> This {{Map}} is then passed over into a {{Properties}} instance in
> [QuorumConfigBuilder:163|https://github.com/apache/curator/blob/master/curator-test/src/main/java/org/apache/curator/test/QuorumConfigBuilder.java#L163].
> These {{Properties}} are then written to a temporary file in ZooKeeper's
> [ZooKeeperServerEmbeddedImpl:58|https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/server/embedded/ZooKeeperServerEmbeddedImpl.java#L58]
> which expects only to have String values. The previously set Integer value
> isn't converted to a String anywhere, though.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)