You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by eb...@apache.org on 2020/12/02 00:40:57 UTC
[tomcat] 01/02: Replace Collections.sort() with List.sort()
This is an automated email from the ASF dual-hosted git repository.
ebourg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 521b3a3e481ae121d5006124611a89a4c4a1302e
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Wed Dec 2 01:28:25 2020 +0100
Replace Collections.sort() with List.sort()
---
java/org/apache/catalina/manager/HTMLManagerServlet.java | 2 +-
java/org/apache/catalina/tribes/group/AbsoluteOrder.java | 2 +-
java/org/apache/el/stream/Stream.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/manager/HTMLManagerServlet.java b/java/org/apache/catalina/manager/HTMLManagerServlet.java
index 53e1ebc..c2e5179 100644
--- a/java/org/apache/catalina/manager/HTMLManagerServlet.java
+++ b/java/org/apache/catalina/manager/HTMLManagerServlet.java
@@ -957,7 +957,7 @@ public final class HTMLManagerServlet extends ManagerServlet {
orderBy = "DESC";
}
try {
- Collections.sort(sessions, comparator);
+ sessions.sort(comparator);
} catch (IllegalStateException ise) {
// at least 1 of the sessions is invalidated
req.setAttribute(APPLICATION_ERROR, "Can't sort session list: one session is invalidated");
diff --git a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
index 974c606..20e8b43 100644
--- a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
+++ b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
@@ -58,7 +58,7 @@ public class AbsoluteOrder {
public static void absoluteOrder(List<Member> members) {
if ( members == null || members.size() <= 1 ) return;
- java.util.Collections.sort(members, comp);
+ members.sort(comp);
}
public static class AbsoluteComparator implements Comparator<Member>,
diff --git a/java/org/apache/el/stream/Stream.java b/java/org/apache/el/stream/Stream.java
index 274369f..c2ac84a 100644
--- a/java/org/apache/el/stream/Stream.java
+++ b/java/org/apache/el/stream/Stream.java
@@ -175,7 +175,7 @@ public class Stream {
while (iterator.hasNext()) {
list.add(iterator.next());
}
- Collections.sort(list, c);
+ list.sort(c);
sorted = list.iterator();
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 04/12/2020 à 02:07, Igal Sapir a écrit :
>> Shall we backport these commits to 9.x and 8.5?
>> It will make it easier to backport future changes in these classes.
>
> +1
>
> No need to diverge the branches unnecessarily.
I've backported the changes to Tomcat 9 and 8.5 (minus the incompatible
changes for the targeted JDK).
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 04/12/2020 à 13:31, Rémy Maucherat a écrit :
> I mean you can add lambda expressions in Tomcat 9, but not Tomcat 8.5,
> right ? Since Tomcat 8.5 is supposed to be Java 7 friendly (
> http://tomcat.apache.org/whichversion.html ). Tomcat 7 would be Java 6
> (ouch).
Oh ok, I thought you were referring to the Java 7 syntax changes. I'll
leave out the lambdas for Tomcat 8.5 of course.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Dec 4, 2020 at 1:04 PM Emmanuel Bourg <eb...@apache.org> wrote:
> Le 04/12/2020 à 12:13, Rémy Maucherat a écrit :
>
> > +1 to backport to 9.0, but not to Tomcat 8.5 since it would need to be
> Java
> > 7 compatible [some of the changes might be fine, but for others it's not
> > possible].
>
> Did you mean Tomcat 7? Because Tomcat 8.5 already depends on Java 7.
>
I mean you can add lambda expressions in Tomcat 9, but not Tomcat 8.5,
right ? Since Tomcat 8.5 is supposed to be Java 7 friendly (
http://tomcat.apache.org/whichversion.html ). Tomcat 7 would be Java 6
(ouch).
Rémy
>
> Emmanuel Bourg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Emmanuel Bourg <eb...@apache.org>.
Le 04/12/2020 à 12:13, Rémy Maucherat a écrit :
> +1 to backport to 9.0, but not to Tomcat 8.5 since it would need to be Java
> 7 compatible [some of the changes might be fine, but for others it's not
> possible].
Did you mean Tomcat 7? Because Tomcat 8.5 already depends on Java 7.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Rémy Maucherat <re...@apache.org>.
On Fri, Dec 4, 2020 at 2:08 AM Igal Sapir <ig...@lucee.org> wrote:
> On Thu, Dec 3, 2020 at 2:48 PM Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi,
> >
> > Shall we backport these commits to 9.x and 8.5?
> > It will make it easier to backport future changes in these classes.
> >
>
> +1
>
> No need to diverge the branches unnecessarily.
>
+1 to backport to 9.0, but not to Tomcat 8.5 since it would need to be Java
7 compatible [some of the changes might be fine, but for others it's not
possible].
Rémy
>
> Igal
>
>
>
> >
> > Martin
> >
> > On Fri, Dec 4, 2020, 00:06 Emmanuel Bourg <eb...@apache.org> wrote:
> >
> > > Hi Christopher,
> > >
> > > Le 03/12/2020 à 21:49, Christopher Schultz a écrit :
> > >
> > > > I'm curious as to why this change is warranted. I'm not suggesting
> it's
> > > > not... just wondering what the benefit is? Avoiding a pass-through
> > > > method call?
> > >
> > > It's the shorter idiom to sort lists with Java 8+, it just improves the
> > > readability. I don't think the method call avoided has any impact, the
> > > actual sorting dominates the time spent anyway.
> > >
> > > Emmanuel Bourg
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: dev-help@tomcat.apache.org
> > >
> > >
> >
>
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Igal Sapir <ig...@lucee.org>.
On Thu, Dec 3, 2020 at 2:48 PM Martin Grigorov <mg...@apache.org> wrote:
> Hi,
>
> Shall we backport these commits to 9.x and 8.5?
> It will make it easier to backport future changes in these classes.
>
+1
No need to diverge the branches unnecessarily.
Igal
>
> Martin
>
> On Fri, Dec 4, 2020, 00:06 Emmanuel Bourg <eb...@apache.org> wrote:
>
> > Hi Christopher,
> >
> > Le 03/12/2020 à 21:49, Christopher Schultz a écrit :
> >
> > > I'm curious as to why this change is warranted. I'm not suggesting it's
> > > not... just wondering what the benefit is? Avoiding a pass-through
> > > method call?
> >
> > It's the shorter idiom to sort lists with Java 8+, it just improves the
> > readability. I don't think the method call avoided has any impact, the
> > actual sorting dominates the time spent anyway.
> >
> > Emmanuel Bourg
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
> >
>
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Shall we backport these commits to 9.x and 8.5?
It will make it easier to backport future changes in these classes.
Martin
On Fri, Dec 4, 2020, 00:06 Emmanuel Bourg <eb...@apache.org> wrote:
> Hi Christopher,
>
> Le 03/12/2020 à 21:49, Christopher Schultz a écrit :
>
> > I'm curious as to why this change is warranted. I'm not suggesting it's
> > not... just wondering what the benefit is? Avoiding a pass-through
> > method call?
>
> It's the shorter idiom to sort lists with Java 8+, it just improves the
> readability. I don't think the method call avoided has any impact, the
> actual sorting dominates the time spent anyway.
>
> Emmanuel Bourg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Emmanuel Bourg <eb...@apache.org>.
Hi Christopher,
Le 03/12/2020 à 21:49, Christopher Schultz a écrit :
> I'm curious as to why this change is warranted. I'm not suggesting it's
> not... just wondering what the benefit is? Avoiding a pass-through
> method call?
It's the shorter idiom to sort lists with Java 8+, it just improves the
readability. I don't think the method call avoided has any impact, the
actual sorting dominates the time spent anyway.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: [tomcat] 01/02: Replace Collections.sort() with List.sort()
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Emmanuel,
I'm curious as to why this change is warranted. I'm not suggesting it's
not... just wondering what the benefit is? Avoiding a pass-through
method call?
Thanks,
-chris
On 12/1/20 19:40, ebourg@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> ebourg pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
> commit 521b3a3e481ae121d5006124611a89a4c4a1302e
> Author: Emmanuel Bourg <eb...@apache.org>
> AuthorDate: Wed Dec 2 01:28:25 2020 +0100
>
> Replace Collections.sort() with List.sort()
> ---
> java/org/apache/catalina/manager/HTMLManagerServlet.java | 2 +-
> java/org/apache/catalina/tribes/group/AbsoluteOrder.java | 2 +-
> java/org/apache/el/stream/Stream.java | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/java/org/apache/catalina/manager/HTMLManagerServlet.java b/java/org/apache/catalina/manager/HTMLManagerServlet.java
> index 53e1ebc..c2e5179 100644
> --- a/java/org/apache/catalina/manager/HTMLManagerServlet.java
> +++ b/java/org/apache/catalina/manager/HTMLManagerServlet.java
> @@ -957,7 +957,7 @@ public final class HTMLManagerServlet extends ManagerServlet {
> orderBy = "DESC";
> }
> try {
> - Collections.sort(sessions, comparator);
> + sessions.sort(comparator);
> } catch (IllegalStateException ise) {
> // at least 1 of the sessions is invalidated
> req.setAttribute(APPLICATION_ERROR, "Can't sort session list: one session is invalidated");
> diff --git a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
> index 974c606..20e8b43 100644
> --- a/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
> +++ b/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
> @@ -58,7 +58,7 @@ public class AbsoluteOrder {
>
> public static void absoluteOrder(List<Member> members) {
> if ( members == null || members.size() <= 1 ) return;
> - java.util.Collections.sort(members, comp);
> + members.sort(comp);
> }
>
> public static class AbsoluteComparator implements Comparator<Member>,
> diff --git a/java/org/apache/el/stream/Stream.java b/java/org/apache/el/stream/Stream.java
> index 274369f..c2ac84a 100644
> --- a/java/org/apache/el/stream/Stream.java
> +++ b/java/org/apache/el/stream/Stream.java
> @@ -175,7 +175,7 @@ public class Stream {
> while (iterator.hasNext()) {
> list.add(iterator.next());
> }
> - Collections.sort(list, c);
> + list.sort(c);
> sorted = list.iterator();
> }
> };
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org