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

Underlying JCOBridge can report an exception when the method invoked contains params keyword and no param are passed #160

Closed
mariomastrodicasa opened this issue Jan 24, 2023 · 1 comment · Fixed by #163
Assignees
Labels
bug Something isn't working KNet KNet related issue

Comments

@mariomastrodicasa
Copy link
Contributor

Describe the bug
When a method containing the keyword params is invoked without any param, an exception is raised from underlying JCOBridge; the exception raised reports it is impossible to identify the Java class without any instance on .NET side.
An example is the one below:

public Topology AddSource(string name, params string[] topics)

To Reproduce
Steps to reproduce the behavior:

  1. Use any method with variadic argument
  2. Avoid to add any element in the variadic argument
  3. Execute the code
  4. See error

Expected behavior
The method with variadic argument shall be executed with or without params in the variadic argument

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: ANY
  • Version: latest

Additional context
The problem seems that:

  • the external method invokes IExecute that is another method with variadic arguments
  • when the execution reaches IExecute the variadic argument becomes an empty array when no argument are passed to the external method
  • the empty array is sent to underlying system which is not able to identify the type
@mariomastrodicasa mariomastrodicasa added bug Something isn't working KNet KNet related issue labels Jan 24, 2023
@masesdevelopers
Copy link
Contributor

The solution identified is to verify if any parameter is passed to the variadic argument and execute different codes: if no variadic arguments are available, the underlying method avoids the variadic argument. A proposal for the method reported in the issue is:

        public Topology AddSource(string name, params string[] topics)
        {
            return topics.Length == 0 ? IExecute<Topology>("addSource", name)
                                      : IExecute<Topology>("addSource", name, topics);
        }

The modification will be applied on next release when JCOBridge 2.5.0 will be available. An issue will be opened in masesgroup/JNet to cover similar problems.

masesdevelopers added a commit that referenced this issue Feb 8, 2023
* #160: updates body of variadic methods

* Update README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working KNet KNet related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants