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

Issue #4550 XmlConfiguration argument matching #4599

Merged
merged 7 commits into from Feb 25, 2020

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Feb 22, 2020

Improve #4550 argument matching by:

  • rejecting obviously non matches (with allowance for unboxing)
  • sorting methods so that derived arguments are tried before more generic (eg String before Object)

Signed-off-by: Greg Wilkins gregw@webtide.com

Improve argument matching by:
 + rejecting obviously non matches (with allowance for unboxing)
 + sorting methods so that derived arguments are tried before more generic (eg String before Object)

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested review from sbordet and joakime and removed request for sbordet February 22, 2020 09:29
@gregw
Copy link
Contributor Author

gregw commented Feb 22, 2020

This change is to address the issue noticed by @joakime that:

the was using public boolean AbstractList.add(E e); not the one in Configurations.add(String ... configClassNames)

I think this is kind of a bad class design, but now at least we will deterministically favour a String over Object over String.... Note this doesn't fix the problem @joakime found. We would have to favour String... over Object to do that. Hmmm maybe we should ?

@gregw
Copy link
Contributor Author

gregw commented Feb 22, 2020

I have the order correct as the following test:

    private static class TestOrder
    {
        public void other(Object o)
        {
            System.err.println("object");
        }

        public void other(String... s)
        {
            System.err.println("string varargs");
        }
    }

    @Test
    public void testMethodOrdering() throws Exception
    {
        TestOrder to = new TestOrder();
        to.other("foo");
    }

prints object

@gregw
Copy link
Contributor Author

gregw commented Feb 22, 2020

Dang! still breaks things... stand by...

Improve argument matching by:
 + can unbox from any Number to any Number

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw added this to In progress in Jetty 9.4.27 via automation Feb 24, 2020
Jetty 9.4.27 automation moved this from In progress to Review in progress Feb 24, 2020
Do not check the assignability of the arguments.  Instead rely on the order of the methods.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
unbox test no longer required

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested a review from sbordet February 24, 2020 22:03
Simplified test

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Cleanup comparator

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw requested a review from sbordet February 25, 2020 14:22
Jetty 9.4.27 automation moved this from Review in progress to Reviewer approved Feb 25, 2020
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than a nit in the comparator, LGTM.

if (compare == 0)
{
// favour primitive type over reference
compare = Boolean.compare(t2.isPrimitive(), t1.isPrimitive());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's subtle that t1 and t2 are inverted here.
I would prefer Boolean.compare(!t1.isPrimitive(), !t2.isPrimitive()).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's how I wrote it initially.... switching....

Cleanup comparator

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw merged commit 353dc9b into jetty-9.4.x Feb 25, 2020
Jetty 9.4.27 automation moved this from Reviewer approved to Done Feb 25, 2020
@gregw gregw deleted the jetty-9.4.x-4550-XmlConfiguration-named-args branch February 25, 2020 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Jetty 9.4.27
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants