Matthias247 / jawampa

Web Application Messaging Protocol (WAMP v2) support for Java
Apache License 2.0
148 stars 56 forks source link

Problem with varargs in Publish method #108

Closed JaiDeves closed 7 years ago

JaiDeves commented 7 years ago

Even though i'm calling this method

public Observable<Long> publish(final String topic, final EnumSet<PublishFlags> flags, final ArrayNode arguments, final ObjectNode argumentsKw){ }

like this,

client.publish(topic, PublishFlags.RequireAcknowledge, tempArray1, tempArray2)

Its calling

public Observable<Long> publish(final String topic, Object... args) { return publish(topic, ArgArrayBuilder.buildArgumentsArray(clientConfig.objectMapper(), args), null); }

Please help me with this........... Is there a problem with the Method overloading since you are using Object as varargs?

Matthias247 commented 7 years ago

You would only call the first method if tempArray1 is of type ArrayNode and tempArray2 is of type ObjectNode. Otherwise obviously the other overload is selected, since the types match there and not for the first overload. That's just how Java overloads work: The best fit wins.

JaiDeves commented 7 years ago

Yes, working properly now, but it's too much widening i think. Thanks for your help.