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

XmlConfiguration should prefer exact class match rather than interface match #11895

Closed
janbartel opened this issue Jun 10, 2024 · 2 comments · Fixed by #11901
Closed

XmlConfiguration should prefer exact class match rather than interface match #11895

janbartel opened this issue Jun 10, 2024 · 2 comments · Fixed by #11901
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@janbartel
Copy link
Contributor

jetty-12

When matching xml to class methods to satisfy a <Call> clause, the code currently prefers matching an argument that is an interface rather than an exact class type match.
In other words, given the following java code:

    public class Example
    {
      interfact TestInterface {}
      public class TestImpl implements TestInterface {}
 
      public static void callStaticWithVarArgs(TestInterface i, String... strings)
      {
      }

      public static void callStaticWithVarArgs(TestImpl i, String... strings)
      {
      }
  }

And given the following xml:

   <Call class="Example" name="callStaticWithVarArgs">
    <Arg>
      <New class="Example$TestImpl"/>
    </Arg>
    <Arg>
      <Array type="java.lang.String">
        <Item>A</Item>
        <Item>B</Item>
        <Item>C</Item>
      </Array>
    </Arg>
  </Call>

The method callStaticWithVarArgs(TestInterface i, String... strings) is ranked higher than the alternative method - which is actually an exact match - and thus selected.

@janbartel janbartel added the Bug For general bugs on Jetty side label Jun 10, 2024
@janbartel janbartel self-assigned this Jun 10, 2024
@janbartel
Copy link
Contributor Author

I think this fix probably introduced the behaviour where interface args are preferenced: #10143

@janbartel
Copy link
Contributor Author

Fixed via #11901

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.1.0 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant