Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException in topic publishAsync result with global ordering enabled #26272

Open
mtillberg opened this issue Mar 3, 2024 · 0 comments

Comments

@mtillberg
Copy link

Describe the bug
Calling publishAsync on a topic returns a CompletionStage. Calling toCompletableFuture().get() on the CompletionStage throws a class cast exception. If global ordering is disabled, the call works without an exception.

java.util.concurrent.ExecutionException: java.lang.ClassCastException: class com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl cannot be cast to class com.hazelcast.topic.impl.TopicService (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl and com.hazelcast.topic.impl.TopicService are in unnamed module of loader 'app')
	at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.returnOrThrowWithGetConventions(InvocationFuture.java:121)
	at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrowIfException(InvocationFuture.java:100)
	at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:618)
	at test.TopicTest.testGlobalOrderedTopic(TopicTest.java:29)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassCastException: class com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl cannot be cast to class com.hazelcast.topic.impl.TopicService (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl and com.hazelcast.topic.impl.TopicService are in unnamed module of loader 'app')
	at com.hazelcast.topic.impl.PublishOperation.run(PublishOperation.java:68)
	at com.hazelcast.spi.impl.operationservice.Operation.call(Operation.java:193)
	at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.call(OperationRunnerImpl.java:299)
	at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:270)
	at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:219)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:180)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:144)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.loop(OperationThread.java:134)
	at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.executeRun(OperationThread.java:115)
	at com.hazelcast.internal.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:111)

Expected behavior
No exception.

To Reproduce

    @Test
    public void testGlobalOrderedTopic() throws Exception {
        Config config = new Config();
        config.getNetworkConfig().getJoin().getAutoDetectionConfig()
            .setEnabled(false);
        config.getProperties()
            .setProperty("hazelcast.phone.home.enabled", "false");
        TopicConfig topicConfig = new TopicConfig();
        topicConfig.setGlobalOrderingEnabled(false);
        topicConfig.setStatisticsEnabled(false);
        topicConfig.setName("test");
        config.addTopicConfig(topicConfig);
        HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);

        ITopic<Integer> topic = instance.getTopic("test");
        CompletionStage<Void> c = topic.publishAsync(Integer.valueOf(42));
        c.toCompletableFuture().get();
        instance.shutdown();
    }

Additional context

Hazelcast version 5.3.6 (also tested with 5.4.0-BETA2)
run via maven 3.8.7 as mvn clean test -DargLine="--add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED" (exception occurs regardless of argline)

$ java -version
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Debian-1deb12u1)
$ uname -srvmo
Linux 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant