-
Notifications
You must be signed in to change notification settings - Fork 36
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
Incorrect constructor selected #91
Comments
j4rs/java/src/main/java/org/astonbitecode/j4rs/api/instantiation/NativeInstantiationImpl.java Lines 119 to 123 in d361dd0
The issue seems to be here, any ParameterizedType in a constructor will always match. This must be causing the Optional to always match. The non-deterministic part of the problem is probably because the list of constructors can be in any order. I think the solution might be to call some of the methods here https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/ParameterizedType.html in order to get at the types making up the ParameterizedType. |
Indeed, there was an issue when handling the parameterized types to match constructors. Thanks. |
I can confirm the example I gave works now. Thanks for the quick resolution! |
I am using j4rs to test the java kafka driver against my application.
I have the following code:
It creates a NewTopic as documented here: https://docs.confluent.io/platform/current/clients/javadocs/javadoc/org/apache/kafka/clients/admin/NewTopic.html
And the source code is here: https://github.com/a0x8o/kafka/blob/master/clients/src/main/java/org/apache/kafka/clients/admin/NewTopic.java
The correct constructor here is
NewTopic(String name, int numPartitions, short replicationFactor)
.In my test this constructor will often be selected.
However sometimes it will instead select the constructor:
NewTopic(String name, Optional<Integer> numPartitions, Optional<Short> replicationFactor)
In the code snippet I pasted, it seems to always select the incorrect constructor, but given the non-deterministic nature of the problem it might behave differently on your machine.
When the code snippet is run I get the following error:
The text was updated successfully, but these errors were encountered: