Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package plexus-utils for openSUSE:Factory checked in at 2026-11-16 09:08:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/plexus-utils (Old) and /work/SRC/openSUSE:Factory/.plexus-utils.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "plexus-utils" Mon Nov 16 09:08:46 2026 rev:15 rq:1397666 version:4.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/plexus-utils/plexus-utils.changes 2026-09-11 18:06:49.901640005 +0200 +++ /work/SRC/openSUSE:Factory/.plexus-utils.new.1251/plexus-utils.changes 2026-11-16 09:14:34.026134820 +0100 @@ -1,0 +2,47 @@ +Sun Nov 15 07:22:04 UTC 2026 - Fridrich Strba <[email protected]> + +- Upgrade to upstream version 4.2.0 + * Highlights + + Deleting a tree no longer deletes outside it. FileUtils + .forceDeleteOnExit followed symbolic links to directories, so + a link inside the tree got every file under its target deleted + when the JVM exited. deleteDirectory could empty a link's + target when the link itself could not be removed. Both now + remove only the link. + + Child processes can read the console. When CommandLineUtils + .executeCommandLine gets System.in as the process input, it + now polls it instead of blocking in read(), so the call + returns once the process exits rather than hanging on an idle + terminal. + + translateCommandline splits at tabs and line breaks. Outside + quotes, \t, \n and \r now separate arguments like a space + does. Input that held one of these characters unquoted now + yields more arguments; quoted text is unchanged. + + Clearer FileUtils failures. forceDelete uses Files + .deleteIfExists, so it also removes dangling symbolic links + and skips the Windows retry delay for files that are already + gone. copyDirectoryStructure and cleanDirectoryOnExit report + an unreadable directory as an IOException naming it, instead + of a NullPointerException. + * New features and improvements + + Poll System.in for stdin in CommandLineUtils + .executeCommandLine + * Bug Fixes + + Do not follow symlinks in forceDeleteOnExit and + deleteDirectory + + Split translateCommandline at tabs and line breaks + + Use Files.deleteIfExists in FileUtils.forceDelete + + Report an unlistable directory as IOException instead of + NullPointerException + * Documentation updates + + Drop the Source Xref menu item + + Stop pinning a version in the README snippet + + Advertise 4.1.0 in the README + * Build + + Allow running the release drafter by hand + + Draft the version the labels imply, not always a patch + * Dependency updates + + Bump plexus-xml to 3.1.1 and keep Dependabot on 3.x + + Bump release-drafter/release-drafter from 7.7.0 to 7.10.0 + +------------------------------------------------------------------- @@ -4 +51 @@ -- Upgrade to upsteam version 4.1.0 +- Upgrade to upstream version 4.1.0 Old: ---- plexus-utils-4.1.0.tar.gz New: ---- plexus-utils-4.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ plexus-utils.spec ++++++ --- /var/tmp/diff_new_pack.Feh5fi/_old 2026-11-16 09:14:35.085179220 +0100 +++ /var/tmp/diff_new_pack.Feh5fi/_new 2026-11-16 09:14:35.086179262 +0100 @@ -17,7 +17,7 @@ Name: plexus-utils -Version: 4.1.0 +Version: 4.2.0 Release: 0 Summary: Plexus Common Utilities License: Apache-1.1 AND Apache-2.0 AND xpp AND BSD-3-Clause AND LicenseRef-SUSE-Public-Domain ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.Feh5fi/_old 2026-11-16 09:14:35.117180562 +0100 +++ /var/tmp/diff_new_pack.Feh5fi/_new 2026-11-16 09:14:35.120180688 +0100 @@ -1,6 +1,6 @@ -mtime: 1789106010 -commit: 341998576c5075a6455f1156a26e5d1ae15817c66128f42b7b171378777edf3f +mtime: 1794727672 +commit: 93bd1d8375150abcd3f92377f4955bf49bebb44be02631c6334c05ee0047e351 url: https://src.opensuse.org/java-packages/plexus-utils -revision: 341998576c5075a6455f1156a26e5d1ae15817c66128f42b7b171378777edf3f +revision: 93bd1d8375150abcd3f92377f4955bf49bebb44be02631c6334c05ee0047e351 projectscmsync: https://src.opensuse.org/java-packages/_ObsPrj ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-11-15 08:27:52.000000000 +0100 @@ -0,0 +1 @@ +.osc ++++++ plexus-utils-4.1.0.tar.gz -> plexus-utils-4.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/.github/dependabot.yml new/plexus-utils-plexus-utils-4.2.0/.github/dependabot.yml --- old/plexus-utils-plexus-utils-4.1.0/.github/dependabot.yml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/.github/dependabot.yml 2026-11-15 00:11:22.000000000 +0100 @@ -4,6 +4,10 @@ directory: "/" schedule: interval: "daily" + ignore: + # plexus-xml 4.x depends on the Maven 4 XML API + - dependency-name: "org.codehaus.plexus:plexus-xml" + versions: [">= 4.0.0"] - package-ecosystem: "github-actions" directory: "/" schedule: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/.github/release-drafter.yml new/plexus-utils-plexus-utils-4.2.0/.github/release-drafter.yml --- old/plexus-utils-plexus-utils-4.1.0/.github/release-drafter.yml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/.github/release-drafter.yml 2026-11-15 00:11:22.000000000 +0100 @@ -1,6 +1,11 @@ _extends: .github:/.github/release-drafter.yml -name-template: $NEXT_PATCH_VERSION -tag-template: plexus-utils-$NEXT_PATCH_VERSION + +# tag-prefix is what lets the drafter parse the version out of the last tag. +# Without it the drafter reads what it can from the tag string, and plexus-i18n +# once drafted 18.0.1 by finding the 18 in its own name. +tag-prefix: plexus-utils- +name-template: $RESOLVED_VERSION +tag-template: plexus-utils-$RESOLVED_VERSION version-template: $MAJOR.$MINOR.$PATCH # plexus-utils maintains parallel release lines (master + plexus-utils-3.x), # so drafts must only pick up commits from the branch being released. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/.github/workflows/maven.yml new/plexus-utils-plexus-utils-4.2.0/.github/workflows/maven.yml --- old/plexus-utils-plexus-utils-4.1.0/.github/workflows/maven.yml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/.github/workflows/maven.yml 2026-11-15 00:11:22.000000000 +0100 @@ -17,7 +17,7 @@ name: GitHub CI -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/.github/workflows/release-drafter.yml new/plexus-utils-plexus-utils-4.2.0/.github/workflows/release-drafter.yml --- old/plexus-utils-plexus-utils-4.1.0/.github/workflows/release-drafter.yml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/.github/workflows/release-drafter.yml 2026-11-15 00:11:22.000000000 +0100 @@ -3,11 +3,12 @@ push: branches: - master + workflow_dispatch: jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/[email protected] + - uses: release-drafter/[email protected] with: commitish: master filter-by-range: "4.x.x" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/README.md new/plexus-utils-plexus-utils-4.2.0/README.md --- old/plexus-utils-plexus-utils-4.1.0/README.md 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/README.md 2026-11-15 00:11:22.000000000 +0100 @@ -29,10 +29,11 @@ <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-xml</artifactId> - <version>3.0.2</version> </dependency> ``` +Take the version from [plexus-xml on Central](https://central.sonatype.com/artifact/org.codehaus.plexus/plexus-xml) — the `3.x` line, for the reason below. + **Pick the `plexus-xml` line carefully:** - **`plexus-xml` 3.x** is the straight extraction from `plexus-utils` 4 — same classes, same packages. This is what you want for Maven 3 compatibility. @@ -46,7 +47,6 @@ <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>4.0.3</version> </dependency> ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/pom.xml new/plexus-utils-plexus-utils-4.2.0/pom.xml --- old/plexus-utils-plexus-utils-4.1.0/pom.xml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/pom.xml 2026-11-15 00:11:22.000000000 +0100 @@ -24,7 +24,7 @@ </parent> <artifactId>plexus-utils</artifactId> - <version>4.1.0</version> + <version>4.2.0</version> <name>Plexus Common Utilities</name> <description>A collection of various utility classes to ease working with strings, files, command lines and @@ -42,7 +42,7 @@ <scm> <connection>scm:git:https://github.com/codehaus-plexus/plexus-utils.git</connection> <developerConnection>${project.scm.connection}</developerConnection> - <tag>plexus-utils-4.1.0</tag> + <tag>plexus-utils-4.2.0</tag> <url>https://github.com/codehaus-plexus/plexus-utils/tree/${project.scm.tag}/</url> </scm> <issueManagement> @@ -57,14 +57,14 @@ </distributionManagement> <properties> - <project.build.outputTimestamp>2026-08-19T13:37:03Z</project.build.outputTimestamp> + <project.build.outputTimestamp>2026-11-14T23:11:04Z</project.build.outputTimestamp> </properties> <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-xml</artifactId> - <version>3.1.0</version> + <version>3.1.1</version> <!-- this dependency is optional, only necessary for deprecated Reader/WriterFactory.newXmlReader/Writer(...) --> <optional>true</optional> </dependency> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/FileUtils.java new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/FileUtils.java --- old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/FileUtils.java 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/FileUtils.java 2026-11-15 00:11:22.000000000 +0100 @@ -66,6 +66,7 @@ import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Files; +import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; @@ -1176,23 +1177,20 @@ if (file.isDirectory()) { deleteDirectory(file); } else { - /* - * NOTE: Always try to delete the file even if it appears to be non-existent. This will ensure that a - * symlink whose target does not exist is deleted, too. - */ - boolean filePresent = file.getCanonicalFile().exists(); - if (!deleteFile(file) && filePresent) { - final String message = "File " + file + " unable to be deleted."; - throw new IOException(message); + if (!deleteFile(file)) { + throw new IOException("File " + file + " unable to be deleted."); } } } /** - * Accommodate Windows bug encountered in both Sun and IBM JDKs. Others possible. If the delete does not work, call + * Deletes a file, or a symlink without following it. A file that does not exist (including a dangling symlink, + * which {@link Files#deleteIfExists} removes) counts as deleted and returns immediately. Only if the file still + * exists after a failed attempt, accommodate the Windows bug encountered in both Sun and IBM JDKs: call * System.gc(), wait a little and try again. * * @param file a file + * @return {@code true} if the file no longer exists * @throws IOException if any */ private static boolean deleteFile(File file) throws IOException { @@ -1200,21 +1198,32 @@ throw new IOException("File " + file + " isn't a file."); } - if (!file.delete()) { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - file = file.getCanonicalFile(); - System.gc(); + final Path path = file.toPath(); + try { + Files.deleteIfExists(path); + return true; + } catch (IOException e) { + if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) { + return true; } + } - try { - Thread.sleep(10); - return file.delete(); - } catch (InterruptedException ignore) { - return file.delete(); - } + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + System.gc(); } - return true; + try { + Thread.sleep(10); + } catch (InterruptedException ignore) { + Thread.currentThread().interrupt(); + } + + try { + Files.deleteIfExists(path); + return true; + } catch (IOException e) { + return !Files.exists(path, LinkOption.NOFOLLOW_LINKS); + } } /** @@ -1247,7 +1256,9 @@ } directory.deleteOnExit(); // The hook reverses the list - cleanDirectoryOnExit(directory); + if (!NioFiles.isSymbolicLink(directory)) { + cleanDirectoryOnExit(directory); + } } /** @@ -1270,6 +1281,9 @@ IOException exception = null; final File[] files = directory.listFiles(); + if (files == null) { + throw new IOException("Could not list directory " + directory.getAbsolutePath()); + } for (final File file : files) { try { forceDeleteOnExit(file); @@ -1343,7 +1357,9 @@ return; } - cleanDirectory(directory); + if (!NioFiles.isSymbolicLink(directory)) { + cleanDirectory(directory); + } if (!directory.delete()) { final String message = "Directory " + directory + " unable to be deleted."; throw new IOException(message); @@ -1762,6 +1778,9 @@ } File[] files = sourceDirectory.listFiles(); + if (files == null) { + throw new IOException("Could not list directory " + sourceDirectory.getAbsolutePath()); + } String sourcePath = sourceDirectory.getAbsolutePath(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java --- old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/cli/CommandLineUtils.java 2026-11-15 00:11:22.000000000 +0100 @@ -82,7 +82,8 @@ /** * @param cl The command line to execute - * @param systemIn The input to read from, must be thread safe + * @param systemIn The input to read from, must be thread safe. {@link System#in} is polled for available data, so + * the call does not wait for it once the process has ended * @param systemOut A consumer that receives output, must be thread safe * @param systemErr A consumer that receives system error stream output, must be thread safe * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout. @@ -105,7 +106,8 @@ * Immediately forks a process, returns a callable that will block until process is complete. * * @param cl The command line to execute - * @param systemIn The input to read from, must be thread safe + * @param systemIn The input to read from, must be thread safe. {@link System#in} is polled for available data, so + * the call does not wait for it once the process has ended * @param systemOut A consumer that receives output, must be thread safe * @param systemErr A consumer that receives system error stream output, must be thread safe * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout. @@ -152,7 +154,12 @@ boolean success = false; try { if (systemIn != null) { - inputFeeder = new StreamFeeder(systemIn, p.getOutputStream()); + if (systemIn == System.in) { + // may never deliver data nor end, so poll it instead of blocking in a read + inputFeeder = new StreamPollFeeder(systemIn, p.getOutputStream()); + } else { + inputFeeder = new StreamFeeder(systemIn, p.getOutputStream()); + } inputFeeder.start(); } @@ -356,7 +363,7 @@ final int inQuote = 1; final int inDoubleQuote = 2; int state = normal; - StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true); + StringTokenizer tok = new StringTokenizer(toProcess, "\"\' \t\n\r", true); Vector<String> v = new Vector<String>(); StringBuilder current = new StringBuilder(); @@ -382,7 +389,10 @@ state = inQuote; } else if ("\"".equals(nextTok)) { state = inDoubleQuote; - } else if (" ".equals(nextTok)) { + } else if (" ".equals(nextTok) + || "\t".equals(nextTok) + || "\n".equals(nextTok) + || "\r".equals(nextTok)) { if (current.length() != 0) { v.addElement(current.toString()); current.setLength(0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/cli/StreamPollFeeder.java new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/cli/StreamPollFeeder.java --- old/plexus-utils-plexus-utils-4.1.0/src/main/java/org/codehaus/plexus/util/cli/StreamPollFeeder.java 1970-01-01 01:00:00.000000000 +0100 +++ new/plexus-utils-plexus-utils-4.2.0/src/main/java/org/codehaus/plexus/util/cli/StreamPollFeeder.java 2026-11-15 00:11:22.000000000 +0100 @@ -0,0 +1,144 @@ +package org.codehaus.plexus.util.cli; + +/* + * Copyright The Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Objects; + +/** + * Polls an {@link InputStream} for available data and writes it to an {@link OutputStream}. Unlike + * {@link StreamFeeder} it never blocks in a read, so it can be stopped at any time even when the input is a stream + * such as {@code System.in} that has no data and no end. + * <p> + * Ported from {@code org.apache.maven.shared.utils.cli.StreamPollFeeder} of Apache Maven Shared Utils + * (<a href="https://issues.apache.org/jira/browse/MSHARED-1072">MSHARED-1072</a>). The input stream is never closed + * by this class. + * </p> + */ +class StreamPollFeeder extends StreamFeeder { + + private static final int BUF_LEN = 80; + + private static final long POLL_INTERVAL_MILLIS = 100; + + private final InputStream pollInput; + + private final OutputStream pollOutput; + + private final Object lock = new Object(); + + private volatile Throwable pollException; + + private volatile boolean stop; + + /** + * Create a new StreamPollFeeder. + * + * @param input stream to read from + * @param output stream to write to + */ + StreamPollFeeder(InputStream input, OutputStream output) { + super(input, output); + this.pollInput = Objects.requireNonNull(input); + this.pollOutput = Objects.requireNonNull(output); + setDaemon(true); + } + + @Override + public void run() { + byte[] buf = new byte[BUF_LEN]; + + try { + while (!stop) { + if (pollInput.available() > 0) { + int i = pollInput.read(buf); + if (i > 0) { + if (!isDisabled()) { + pollOutput.write(buf, 0, i); + pollOutput.flush(); + } + } else { + stop = true; + } + } else { + synchronized (lock) { + if (!stop) { + lock.wait(POLL_INTERVAL_MILLIS); + } + } + } + } + } catch (IOException e) { + pollException = e; + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } finally { + closeOutput(); + synchronized (this) { + setDone(); + notifyAll(); + } + } + } + + private void closeOutput() { + try { + pollOutput.close(); + } catch (IOException e) { + if (pollException == null) { + pollException = e; + } + } + } + + /** + * Stops polling and waits for the feeder thread to finish. + */ + @Override + public void waitUntilDone() throws InterruptedException { + stopPolling(); + join(); + } + + @Override + public void disable() { + super.disable(); + stopPolling(); + } + + /** + * The output stream is closed when the thread ends, and the input stream is left open, so there is nothing to do. + */ + @Override + public void close() { + // nothing to close here + } + + @Override + public Throwable getException() { + return pollException; + } + + private void stopPolling() { + synchronized (lock) { + stop = true; + lock.notifyAll(); + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/site/site.xml new/plexus-utils-plexus-utils-4.2.0/src/site/site.xml --- old/plexus-utils-plexus-utils-4.1.0/src/site/site.xml 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/src/site/site.xml 2026-11-15 00:11:22.000000000 +0100 @@ -28,7 +28,6 @@ <menu name="Overview"> <item name="Introduction" href="index.html"/> <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> </menu> <menu ref="parent"/> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java --- old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/FileUtilsTest.java 2026-11-15 00:11:22.000000000 +0100 @@ -29,13 +29,17 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Properties; +import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * This is used to test FileUtils for correctness. @@ -425,6 +429,28 @@ } @Test + void forceDeleteNonExistingFile() throws Exception { + final File missing = new File(getTestDirectory(), "does-not-exist.txt"); + assertFalse(missing.exists()); + FileUtils.forceDelete(missing); + assertFalse(missing.exists()); + } + + @Test + void forceDeleteDanglingSymlink() throws Exception { + final File target = new File(getTestDirectory(), "dangling-target.txt"); + final File symlink = new File(getTestDirectory(), "dangling-link"); + createFile(target, 1); + createSymlink(symlink, target); + assumeTrue(Files.isSymbolicLink(symlink.toPath()), "the platform created a real symlink"); + assertTrue(target.delete()); + // Windows stops reporting a file link as a symlink once its target is gone + assumeTrue(Files.isSymbolicLink(symlink.toPath()), "the platform keeps a dangling symlink"); + FileUtils.forceDelete(symlink); + assertFalse(Files.isSymbolicLink(symlink.toPath()), "Dangling symlink should be removed"); + } + + @Test void copyFile1ToDir() throws Exception { final File directory = new File(getTestDirectory(), "subdir"); if (!directory.exists()) { @@ -680,6 +706,21 @@ } @Test + void copyDirectoryStructureFailsWhenSourceCannotBeListed() throws Exception { + File from = new File(getTestDirectory(), "unlistable"); + from.mkdirs(); + File to = new File(getTestDirectory(), "unlistable-copy"); + assumeTrue(from.setReadable(false) && from.setExecutable(false) && from.listFiles() == null); + try { + IOException e = assertThrows(IOException.class, () -> FileUtils.copyDirectoryStructure(from, to)); + assertTrue(e.getMessage().contains(from.getAbsolutePath())); + } finally { + from.setExecutable(true); + from.setReadable(true); + } + } + + @Test void copyDirectoryStructureWithAEmptyDirectoryStructure() throws Exception { File from = new File(getTestDirectory(), "from"); @@ -1186,6 +1227,66 @@ } @Test + @DisabledOnOs(OS.WINDOWS) + void deleteDirectoryDoesNotFollowDirSymlink() throws Exception { + File outside = new File(getTestDirectory(), "outside"); + outside.mkdir(); + File outsideFile = new File(outside, "keep.txt"); + createFile(outsideFile, 1); + + File directory = new File(getTestDirectory(), "directory"); + File readOnly = new File(directory, "readOnly"); + readOnly.mkdirs(); + File symlink = new File(readOnly, "dirSymlink"); + createSymlink(symlink, outside); + // the symlink cannot be unlinked from a read-only directory + readOnly.setWritable(false); + try { + assumeFalse(Files.isWritable(readOnly.toPath()), "directory permissions are not enforced"); + assertThrows(IOException.class, () -> FileUtils.deleteDirectory(directory)); + } finally { + readOnly.setWritable(true); + symlink.delete(); + } + assertTrue(outsideFile.exists(), "deleteDirectory followed a symlink out of the directory"); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void forceDeleteOnExitDoesNotFollowDirSymlink() throws Exception { + File outside = new File(getTestDirectory(), "outside"); + outside.mkdir(); + File outsideFile = new File(outside, "keep.txt"); + createFile(outsideFile, 1); + + File directory = new File(getTestDirectory(), "directory"); + directory.mkdir(); + createSymlink(new File(directory, "dirSymlink"), outside); + + // deleteOnExit only runs when the JVM exits, so run it in a separate one + String java = new File(System.getProperty("java.home"), "bin/java").getPath(); + Process process = new ProcessBuilder( + java, + "-cp", + System.getProperty("java.class.path"), + ForceDeleteOnExit.class.getName(), + directory.getAbsolutePath()) + .inheritIO() + .start(); + assertTrue(process.waitFor(1, TimeUnit.MINUTES), "JVM did not exit"); + assertEquals(0, process.exitValue()); + + assertFalse(directory.exists(), "Failed to delete directory on exit"); + assertTrue(outsideFile.exists(), "forceDeleteOnExit followed a symlink out of the directory"); + } + + public static final class ForceDeleteOnExit { + public static void main(String[] args) throws IOException { + FileUtils.forceDeleteOnExit(new File(args[0])); + } + } + + @Test void testcopyDirectoryLayoutWithExcludesIncludes() throws Exception { File destination = new File("target", "copyDirectoryStructureWithExcludesIncludes"); if (!destination.exists()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java --- old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java 2026-08-19 15:37:15.000000000 +0200 +++ new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/cli/CommandLineUtilsTest.java 2026-11-15 00:11:22.000000000 +0100 @@ -98,6 +98,23 @@ assertCmdLineArgs(new String[] {"foo", " ' ", "bar"}, "foo \" ' \" bar"); } + @Test + void translateCommandlineSplitsAtTabsAndLineBreaks() throws Exception { + assertCmdLineArgs(new String[] {"foo", "bar"}, "foo\tbar"); + assertCmdLineArgs(new String[] {"foo", "bar"}, "foo\nbar"); + assertCmdLineArgs(new String[] {"foo", "bar"}, "foo\rbar"); + assertCmdLineArgs(new String[] {"foo", "bar"}, "foo\r\nbar"); + assertCmdLineArgs(new String[] {"foo", "bar", "baz"}, " \t foo \t\n bar\r\n\tbaz \n"); + assertCmdLineArgs(new String[] {}, " \t\r\n "); + } + + @Test + void translateCommandlineKeepsWhitespaceInsideQuotes() throws Exception { + assertCmdLineArgs(new String[] {"foo", "a\tb\nc\r", "bar"}, "foo \"a\tb\nc\r\" bar"); + assertCmdLineArgs(new String[] {"foo", "a\tb\nc\r", "bar"}, "foo 'a\tb\nc\r' bar"); + assertCmdLineArgs(new String[] {"a\tb", "c"}, "'a\tb'\tc"); + } + private void assertCmdLineArgs(String[] expected, String cmdLine) throws Exception { String[] actual = CommandLineUtils.translateCommandline(cmdLine); assertNotNull(actual); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/cli/StreamPollFeederTest.java new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/cli/StreamPollFeederTest.java --- old/plexus-utils-plexus-utils-4.1.0/src/test/java/org/codehaus/plexus/util/cli/StreamPollFeederTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/plexus-utils-plexus-utils-4.2.0/src/test/java/org/codehaus/plexus/util/cli/StreamPollFeederTest.java 2026-11-15 00:11:22.000000000 +0100 @@ -0,0 +1,187 @@ +package org.codehaus.plexus.util.cli; + +/* + * Copyright The Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.concurrent.CountDownLatch; + +import org.codehaus.plexus.util.Os; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class StreamPollFeederTest { + + /** An input that never has data and never ends, like an idle terminal. */ + private static final class IdleInputStream extends InputStream { + private final CountDownLatch never = new CountDownLatch(1); + + @Override + public int available() { + return 0; + } + + @Override + public int read() throws IOException { + try { + never.await(); + } catch (InterruptedException e) { + throw new IOException(e); + } + return -1; + } + } + + private static final class CountingOutputStream extends ByteArrayOutputStream { + private volatile boolean closed; + + @Override + public void close() { + closed = true; + } + } + + @Test + void waitUntilDoneWithIdleInput() { + CountingOutputStream out = new CountingOutputStream(); + StreamPollFeeder feeder = new StreamPollFeeder(new IdleInputStream(), out); + + assertTimeoutPreemptively(Duration.ofSeconds(5), () -> { + feeder.start(); + Thread.sleep(150); + feeder.waitUntilDone(); + }); + + assertNull(feeder.getException()); + assertTrue(feeder.isDone()); + assertTrue(out.closed, "output must be closed when feeding ends"); + } + + @Test + void waitUntilDoneWithContinuousData() { + InputStream continuous = new InputStream() { + @Override + public int available() { + return 1; + } + + @Override + public int read() { + return 0; + } + + @Override + public int read(byte[] b, int off, int len) { + return 1; + } + }; + StreamPollFeeder feeder = new StreamPollFeeder(continuous, new ByteArrayOutputStream() { + @Override + public synchronized void write(byte[] b, int off, int len) { + // discard + } + }); + + assertTimeoutPreemptively(Duration.ofSeconds(5), () -> { + feeder.start(); + feeder.waitUntilDone(); + }); + assertNull(feeder.getException()); + } + + @Test + void dataIsCopied() throws Exception { + StringBuilder data = new StringBuilder(); + for (int i = 0; i < 100; i++) { + data.append("TestData"); + } + ByteArrayOutputStream out = new ByteArrayOutputStream(); + StreamPollFeeder feeder = + new StreamPollFeeder(new ByteArrayInputStream(data.toString().getBytes(StandardCharsets.UTF_8)), out); + + assertTimeoutPreemptively(Duration.ofSeconds(10), () -> { + feeder.start(); + while (out.size() < data.length()) { + Thread.sleep(20); + } + feeder.waitUntilDone(); + }); + + assertNull(feeder.getException()); + assertEquals(data.toString(), out.toString("UTF-8")); + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void executeCommandLineDoesNotWaitForIdleSystemIn() throws Exception { + InputStream originalIn = System.in; + System.setIn(new IdleInputStream()); + try { + Commandline cli = new Commandline(); + cli.setExecutable(javaExecutable().getAbsolutePath()); + cli.createArg().setValue("-version"); + + int exitCode = assertTimeoutPreemptively( + Duration.ofSeconds(30), + () -> CommandLineUtils.executeCommandLine( + cli, + System.in, + new CommandLineUtils.StringStreamConsumer(), + new CommandLineUtils.StringStreamConsumer())); + assertEquals(0, exitCode); + } finally { + System.setIn(originalIn); + } + } + + @Test + @DisabledOnOs(OS.WINDOWS) + void executeCommandLineStillDeliversEndOfInputToFiniteStream() throws Exception { + Commandline cli = new Commandline(); + cli.setExecutable("cat"); + CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); + + int exitCode = assertTimeoutPreemptively( + Duration.ofSeconds(30), + () -> CommandLineUtils.executeCommandLine( + cli, + new ByteArrayInputStream("hello".getBytes(StandardCharsets.UTF_8)), + out, + new CommandLineUtils.StringStreamConsumer())); + + assertEquals(0, exitCode); + assertEquals("hello", out.getOutput().trim()); + } + + private static File javaExecutable() { + File java = + new File(System.getProperty("java.home"), Os.isFamily(Os.FAMILY_WINDOWS) ? "bin/java.exe" : "bin/java"); + assertTrue(java.exists(), java + " doesn't exist"); + return java; + } +} ++++++ plexus-utils-build.xml ++++++ --- /var/tmp/diff_new_pack.Feh5fi/_old 2026-11-16 09:14:35.393192133 +0100 +++ /var/tmp/diff_new_pack.Feh5fi/_new 2026-11-16 09:14:35.396192259 +0100 @@ -11,7 +11,7 @@ <property name="project.groupId" value="org.codehaus.plexus"/> <property name="project.fragment" value="utils"/> <property name="project.artifactId" value="plexus-${project.fragment}"/> - <property name="project.version" value="4.1.0"/> + <property name="project.version" value="4.2.0"/> <property name="compiler.release" value="8"/> <property name="compiler.source" value="1.${compiler.release}"/>
