Issue #3319 - Applying changes from review with @sbordet
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
ca77bd384a
commit
b929f5c2db
|
@ -30,7 +30,6 @@ import java.net.URL;
|
|||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
@ -515,8 +514,8 @@ public abstract class Resource implements ResourceFactory, Closeable
|
|||
if (base==null || !isDirectory())
|
||||
return null;
|
||||
|
||||
String[] ls = list();
|
||||
if (ls == null)
|
||||
String[] rawListing = list();
|
||||
if (rawListing == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -555,9 +554,9 @@ public abstract class Resource implements ResourceFactory, Closeable
|
|||
|
||||
// Gather up entries
|
||||
List<Resource> items = new ArrayList<>();
|
||||
for (int i=0 ; i< ls.length ; i++)
|
||||
for (String l : rawListing)
|
||||
{
|
||||
Resource item = addPath(ls[i]);
|
||||
Resource item = addPath(l);
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
|
@ -575,8 +574,6 @@ public abstract class Resource implements ResourceFactory, Closeable
|
|||
Collections.sort(items, ResourceCollators.byName(sortOrderAscending));
|
||||
}
|
||||
|
||||
Arrays.sort(ls);
|
||||
|
||||
String decodedBase = URIUtil.decodePath(base);
|
||||
String title = "Directory: " + deTag(decodedBase);
|
||||
|
||||
|
|
|
@ -18,18 +18,22 @@
|
|||
|
||||
package org.eclipse.jetty.util.resource;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ResourceCollators
|
||||
{
|
||||
private static Comparator<? super Resource> BY_NAME_ASCENDING =
|
||||
new Comparator<Resource>()
|
||||
{
|
||||
private final Collator collator = Collator.getInstance(Locale.ENGLISH);
|
||||
|
||||
@Override
|
||||
public int compare(Resource o1, Resource o2)
|
||||
{
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
return collator.compare(o1.getName(), o2.getName());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,7 +46,7 @@ public class ResourceCollators
|
|||
@Override
|
||||
public int compare(Resource o1, Resource o2)
|
||||
{
|
||||
return (int) (o1.lastModified() - o2.lastModified());
|
||||
return Long.compare(o1.lastModified(), o2.lastModified());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,7 +59,7 @@ public class ResourceCollators
|
|||
@Override
|
||||
public int compare(Resource o1, Resource o2)
|
||||
{
|
||||
return (int) (o1.length() - o2.length());
|
||||
return Long.compare(o1.length(), o2.length());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue