Skip to content

Mutiny EventBus and Buffer - NoSuchMethodException - io.vertx.mutiny.core.buffer.Buffer.<init>() #541

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

Closed
tmulle opened this issue May 24, 2022 · 2 comments
Milestone

Comments

@tmulle
Copy link

tmulle commented May 24, 2022

Questions

This code should work as is? It works fine using standard "core" Vertx classes.

I was working on a larger project trying to use the new Mutiny classes and ran into this issue.
So, to isolate the problem I made this very simple example just to make sure I wasn't doing anything wrong.

Version

Which version(s) did you encounter this bug ?
4.3.0 vertx
2.22.0 Mutiny bindings

Context

When trying to use the EvenBus to send a Buffer instance it throws an error.

Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: io.vertx.mutiny.core.buffer.Buffer.<init>()
	at io.vertx.core.impl.ClusterSerializableUtils.copy(ClusterSerializableUtils.java:29)
	at io.vertx.core.eventbus.impl.codecs.ClusterSerializableCodec.transform(ClusterSerializableCodec.java:65)
	at io.vertx.core.eventbus.impl.codecs.ClusterSerializableCodec.transform(ClusterSerializableCodec.java:22)
	at io.vertx.core.eventbus.impl.MessageImpl.<init>(MessageImpl.java:65)
	at io.vertx.core.eventbus.impl.MessageImpl.copyBeforeReceive(MessageImpl.java:71)
	at io.vertx.core.eventbus.impl.EventBusImpl.deliverMessageLocally(EventBusImpl.java:375)
	at io.vertx.core.eventbus.impl.EventBusImpl.sendLocally(EventBusImpl.java:341)
	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPub(EventBusImpl.java:329)
	at io.vertx.core.eventbus.impl.OutboundDeliveryContext.execute(OutboundDeliveryContext.java:109)
	at io.vertx.core.eventbus.impl.DeliveryContextBase.next(DeliveryContextBase.java:72)
	at io.vertx.core.eventbus.impl.OutboundDeliveryContext.next(OutboundDeliveryContext.java:28)
	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:422)
	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:428)
	at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:164)
	at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:159)
	at io.vertx.mutiny.core.eventbus.EventBus.publish(EventBus.java:224)

Do you have a reproducer?

Example:

This code fails using the Mutiny versions, but works properly with the standard 'core' versions.

import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.core.buffer.Buffer;

/**
 *
 * @author tmulle
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        
        Vertx v = Vertx.vertx();
        v.eventBus().consumer("testing", message -> System.out.println("Got it!: " + message.body()));
        
        v.eventBus().publish("testing", Buffer.buffer("HEllo BUFFER"));
        
        Thread.sleep(5000);
        v.close();
    }
}

Steps to reproduce

  1. Run example code above
  2. ...
  3. ...
  4. ...

Extra

  • JDK11/JDK17 on Silicon Mac M1 MAX

So I took a look at my original dependencies in my pom and I was using:

<dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>4.3.0</version>
        </dependency>
        <dependency>
            <groupId>io.smallrye.reactive</groupId>
            <artifactId>smallrye-mutiny-vertx-core</artifactId>
            <version>2.22.0</version>
        </dependency>

Realizing that the Mutiny might be pulling in vertx-core I commented it out and now I get a different error when running the 'Mutiny' version. The core version works correctly still.

If I leave both dependencies, then I get the original error of NoSuchMethodException which I am now assuming is a version mismatch between vertx-core and mutiny-vertx

Error I get now:

Exception in thread "main" java.lang.IllegalArgumentException: No message codec for type: class io.vertx.mutiny.core.buffer.Buffer
	at io.vertx.core.eventbus.impl.CodecManager.lookupCodec(CodecManager.java:101)
	at io.vertx.core.eventbus.impl.EventBusImpl.createMessage(EventBusImpl.java:232)
	at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:148)
	at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:143)
	at io.vertx.mutiny.core.eventbus.EventBus.publish(EventBus.java:225)
@cescoffier
Copy link
Contributor

This project is not yet compatible with vertx 4.3

@cescoffier
Copy link
Contributor

Fixed by #552

@cescoffier cescoffier added this to the 2.23.0 milestone Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants