Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x

This commit is contained in:
Joakim Erdfelt 2021-10-27 05:59:25 -05:00
commit 3dbcca5235
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
6 changed files with 52 additions and 35 deletions

View File

@ -18,6 +18,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
import org.eclipse.jetty.util.StringUtil;
import org.slf4j.Logger;
@ -75,9 +76,9 @@ public class JettyDemos
String version = "unknown";
Path pomFile = demosDir.resolve("pom.xml");
try
try (Stream<String> lineStream = Files.lines(pomFile))
{
String versionLine = Files.lines(pomFile)
String versionLine = lineStream
.filter((line) -> line.contains("<version>"))
.findFirst()
.orElseThrow(() ->

View File

@ -195,9 +195,12 @@ public class BaseBuilder
}
};
List<Path> paths = new ArrayList<>();
for (Path path : Files.newDirectoryStream(startd, filter))
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(startd, filter))
{
paths.add(path);
for (Path path : dirStream)
{
paths.add(path);
}
}
paths.sort(new NaturalSort.Paths());

View File

@ -137,11 +137,14 @@ public class DirConfigSource implements ConfigSource
List<Path> paths = new ArrayList<>();
for (Path diniFile : Files.newDirectoryStream(startDdir, filter))
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(startDdir, filter))
{
if (FS.canReadFile(diniFile))
for (Path diniFile : dirStream)
{
paths.add(diniFile);
if (FS.canReadFile(diniFile))
{
paths.add(diniFile);
}
}
}

View File

@ -15,6 +15,7 @@ package org.eclipse.jetty.start.util;
import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
@ -172,19 +173,22 @@ public class RebuildTestResources
{
Files.createDirectories(to);
for (Path path : Files.newDirectoryStream(from))
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(from))
{
String name = renamer.getName(path);
Path dest = to.resolve(name);
if (Files.isDirectory(path))
for (Path path : directoryStream)
{
copyDir(path, dest, fileMatcher, renamer, copier);
}
else
{
if (fileMatcher.matches(path))
String name = renamer.getName(path);
Path dest = to.resolve(name);
if (Files.isDirectory(path))
{
copier.copy(path, dest);
copyDir(path, dest, fileMatcher, renamer, copier);
}
else
{
if (fileMatcher.matches(path))
{
copier.copy(path, dest);
}
}
}
}

View File

@ -677,20 +677,22 @@ public class URIUtilTest
for (Path root : zipFs.getRootDirectories())
{
Stream<Path> entryStream = Files.find(root, 10, (path, attrs) -> true, fileVisitOptions);
entryStream.forEach((path) ->
try (Stream<Path> entryStream = Files.find(root, 10, (path, attrs) -> true, fileVisitOptions))
{
if (path.toString().endsWith("!/"))
entryStream.forEach((path) ->
{
// skip - JAR entry type not supported by Jetty
// TODO: re-enable once we start to use zipfs
LOG.warn("Skipping Unsupported entry: " + path.toUri());
}
else
{
arguments.add(Arguments.of(path.toUri(), TEST_RESOURCE_JAR));
}
});
if (path.toString().endsWith("!/"))
{
// skip - JAR entry type not supported by Jetty
// TODO: re-enable once we start to use zipfs
LOG.warn("Skipping Unsupported entry: " + path.toUri());
}
else
{
arguments.add(Arguments.of(path.toUri(), TEST_RESOURCE_JAR));
}
});
}
}
}

View File

@ -18,6 +18,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Iterator;
import java.util.stream.Stream;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
@ -86,13 +87,16 @@ public class ForcedServletTest
private void copyDir(Path src, Path dest) throws IOException
{
FS.ensureDirExists(dest);
for (Iterator<Path> it = Files.list(src).iterator(); it.hasNext(); )
try (Stream<Path> srcStream = Files.list(src))
{
Path path = it.next();
if (Files.isRegularFile(path))
Files.copy(path, dest.resolve(path.getFileName()));
else if (Files.isDirectory(path))
copyDir(path, dest.resolve(path.getFileName()));
for (Iterator<Path> it = srcStream.iterator(); it.hasNext(); )
{
Path path = it.next();
if (Files.isRegularFile(path))
Files.copy(path, dest.resolve(path.getFileName()));
else if (Files.isDirectory(path))
copyDir(path, dest.resolve(path.getFileName()));
}
}
}