You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Matthias Pohl (Jira)" <ji...@apache.org> on 2023/03/28 20:16:00 UTC

[jira] [Created] (CURATOR-663) ZooKeeperServerEmbeddedAdapter.configure might fail with ClassCastException

Matthias Pohl created CURATOR-663:
-------------------------------------

             Summary: 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


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 InstanceSpec instanceSpec = new InstanceSpec(
          zkTmpDir,
          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)