Remove accidental usage of Plexus's CollectionUtils
See gh-16655 and 8f5777cf
This commit is contained in:
@@ -18,9 +18,9 @@ package org.springframework.boot.loader;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.codehaus.plexus.util.CollectionUtils;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.loader.archive.Archive;
|
import org.springframework.boot.loader.archive.Archive;
|
||||||
@@ -40,7 +40,8 @@ class JarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
|||||||
void explodedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
|
void explodedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
|
||||||
File explodedRoot = explode(createJarArchive("archive.jar", "BOOT-INF"));
|
File explodedRoot = explode(createJarArchive("archive.jar", "BOOT-INF"));
|
||||||
JarLauncher launcher = new JarLauncher(new ExplodedArchive(explodedRoot, true));
|
JarLauncher launcher = new JarLauncher(new ExplodedArchive(explodedRoot, true));
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).hasSize(2);
|
assertThat(archives).hasSize(2);
|
||||||
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(),
|
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(),
|
||||||
new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL());
|
new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL());
|
||||||
@@ -54,7 +55,8 @@ class JarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
|||||||
File jarRoot = createJarArchive("archive.jar", "BOOT-INF");
|
File jarRoot = createJarArchive("archive.jar", "BOOT-INF");
|
||||||
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
|
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
|
||||||
JarLauncher launcher = new JarLauncher(archive);
|
JarLauncher launcher = new JarLauncher(archive);
|
||||||
List<Archive> classPathArchives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> classPathArchives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(classPathArchives::add);
|
||||||
assertThat(classPathArchives).hasSize(2);
|
assertThat(classPathArchives).hasSize(2);
|
||||||
assertThat(getUrls(classPathArchives)).containsOnly(
|
assertThat(getUrls(classPathArchives)).containsOnly(
|
||||||
new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/classes!/"),
|
new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/classes!/"),
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import java.util.jar.Manifest;
|
|||||||
|
|
||||||
import org.assertj.core.api.Condition;
|
import org.assertj.core.api.Condition;
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.codehaus.plexus.util.CollectionUtils;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -140,7 +139,8 @@ class PropertiesLauncherTests {
|
|||||||
System.setProperty("loader.path", "jars/");
|
System.setProperty("loader.path", "jars/");
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString()).isEqualTo("[jars/]");
|
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString()).isEqualTo("[jars/]");
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,8 @@ class PropertiesLauncherTests {
|
|||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString())
|
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString())
|
||||||
.isEqualTo("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
|
.isEqualTo("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
@@ -179,7 +180,8 @@ class PropertiesLauncherTests {
|
|||||||
void testUserSpecifiedRootOfJarPathWithDot() throws Exception {
|
void testUserSpecifiedRootOfJarPathWithDot() throws Exception {
|
||||||
System.setProperty("loader.path", "nested-jars/app.jar!/./");
|
System.setProperty("loader.path", "nested-jars/app.jar!/./");
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
@@ -188,7 +190,8 @@ class PropertiesLauncherTests {
|
|||||||
void testUserSpecifiedRootOfJarPathWithDotAndJarPrefix() throws Exception {
|
void testUserSpecifiedRootOfJarPathWithDotAndJarPrefix() throws Exception {
|
||||||
System.setProperty("loader.path", "jar:file:./src/test/resources/nested-jars/app.jar!/./");
|
System.setProperty("loader.path", "jar:file:./src/test/resources/nested-jars/app.jar!/./");
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +200,8 @@ class PropertiesLauncherTests {
|
|||||||
System.setProperty("loader.path", "nested-jars/app.jar");
|
System.setProperty("loader.path", "nested-jars/app.jar");
|
||||||
System.setProperty("loader.main", "demo.Application");
|
System.setProperty("loader.main", "demo.Application");
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
|
||||||
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
assertThat(archives).areExactly(1, endingWith("app.jar"));
|
||||||
}
|
}
|
||||||
@@ -207,7 +211,8 @@ class PropertiesLauncherTests {
|
|||||||
System.setProperty("loader.path", "nested-jars/app.jar!/foo.jar");
|
System.setProperty("loader.path", "nested-jars/app.jar!/foo.jar");
|
||||||
System.setProperty("loader.main", "demo.Application");
|
System.setProperty("loader.main", "demo.Application");
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).hasSize(1).areExactly(1, endingWith("foo.jar!/"));
|
assertThat(archives).hasSize(1).areExactly(1, endingWith("foo.jar!/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +341,8 @@ class PropertiesLauncherTests {
|
|||||||
loaderPath.mkdir();
|
loaderPath.mkdir();
|
||||||
System.setProperty("loader.path", loaderPath.toURI().toURL().toString());
|
System.setProperty("loader.path", loaderPath.toURI().toURL().toString());
|
||||||
PropertiesLauncher launcher = new PropertiesLauncher();
|
PropertiesLauncher launcher = new PropertiesLauncher();
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives.size()).isEqualTo(1);
|
assertThat(archives.size()).isEqualTo(1);
|
||||||
File archiveRoot = (File) ReflectionTestUtils.getField(archives.get(0), "root");
|
File archiveRoot = (File) ReflectionTestUtils.getField(archives.get(0), "root");
|
||||||
assertThat(archiveRoot).isEqualTo(loaderPath);
|
assertThat(archiveRoot).isEqualTo(loaderPath);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ package org.springframework.boot.loader;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.codehaus.plexus.util.CollectionUtils;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.loader.archive.Archive;
|
import org.springframework.boot.loader.archive.Archive;
|
||||||
@@ -40,7 +40,8 @@ class WarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
|||||||
void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath() throws Exception {
|
void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath() throws Exception {
|
||||||
File explodedRoot = explode(createJarArchive("archive.war", "WEB-INF"));
|
File explodedRoot = explode(createJarArchive("archive.war", "WEB-INF"));
|
||||||
WarLauncher launcher = new WarLauncher(new ExplodedArchive(explodedRoot, true));
|
WarLauncher launcher = new WarLauncher(new ExplodedArchive(explodedRoot, true));
|
||||||
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> archives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
|
||||||
assertThat(archives).hasSize(2);
|
assertThat(archives).hasSize(2);
|
||||||
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "WEB-INF/classes").toURI().toURL(),
|
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "WEB-INF/classes").toURI().toURL(),
|
||||||
new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL());
|
new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL());
|
||||||
@@ -54,7 +55,8 @@ class WarLauncherTests extends AbstractExecutableArchiveLauncherTests {
|
|||||||
File jarRoot = createJarArchive("archive.war", "WEB-INF");
|
File jarRoot = createJarArchive("archive.war", "WEB-INF");
|
||||||
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
|
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
|
||||||
WarLauncher launcher = new WarLauncher(archive);
|
WarLauncher launcher = new WarLauncher(archive);
|
||||||
List<Archive> classPathArchives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
|
List<Archive> classPathArchives = new ArrayList<>();
|
||||||
|
launcher.getClassPathArchivesIterator().forEachRemaining(classPathArchives::add);
|
||||||
assertThat(classPathArchives).hasSize(2);
|
assertThat(classPathArchives).hasSize(2);
|
||||||
assertThat(getUrls(classPathArchives)).containsOnly(
|
assertThat(getUrls(classPathArchives)).containsOnly(
|
||||||
new URL("jar:" + jarRoot.toURI().toURL() + "!/WEB-INF/classes!/"),
|
new URL("jar:" + jarRoot.toURI().toURL() + "!/WEB-INF/classes!/"),
|
||||||
|
|||||||
Reference in New Issue
Block a user