Skip to content

Commit

Permalink
Merge branch 'master' into JENKINS-30175
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck authored May 27, 2024
2 parents a507e2e + 5af668d commit 32f9807
Show file tree
Hide file tree
Showing 126 changed files with 1,039 additions and 541 deletions.
2 changes: 1 addition & 1 deletion .gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM gitpod/workspace-full

ARG MAVEN_VERSION=3.9.6
ARG MAVEN_VERSION=3.9.7

RUN brew install gh && \
bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION} && sdk default maven ${MAVEN_VERSION}"
2 changes: 1 addition & 1 deletion ath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -o xtrace
cd "$(dirname "$0")"

# https://github.com/jenkinsci/acceptance-test-harness/releases
export ATH_VERSION=5814.vdc5d6d484b_40
export ATH_VERSION=5858.v4b_c4e3b_16099

if [[ $# -eq 0 ]]; then
export JDK=17
Expand Down
52 changes: 44 additions & 8 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ THE SOFTWARE.
<description>The module contains dependencies that are used by a specific Jenkins version</description>

<properties>
<commons-fileupload2.version>2.0.0-M2</commons-fileupload2.version>
<slf4jVersion>2.0.13</slf4jVersion>
<stapler.version>1860.vb_89682cf8d96</stapler.version>
<stapler.version>1870.v48cc46ef5fee</stapler.version>
<groovy.version>2.4.21</groovy.version>
</properties>

Expand All @@ -55,7 +56,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.34</version>
<version>5.3.36</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -119,11 +120,6 @@ THE SOFTWARE.
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -149,6 +145,11 @@ THE SOFTWARE.
<artifactId>jenkins-stapler-support</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
Expand Down Expand Up @@ -189,6 +190,41 @@ THE SOFTWARE.
<artifactId>commons-compress</artifactId>
<version>1.26.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-core</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-distribution</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta-servlet5</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta-servlet6</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-javax</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-portlet</artifactId>
<version>${commons-fileupload2.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
Expand Down Expand Up @@ -340,7 +376,7 @@ THE SOFTWARE.
<!-- provided by jcl-over-slf4j -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
13 changes: 8 additions & 5 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ THE SOFTWARE.
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -284,6 +280,14 @@ THE SOFTWARE.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-javax</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
Expand Down Expand Up @@ -439,7 +443,6 @@ THE SOFTWARE.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
30 changes: 24 additions & 6 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
Expand Down Expand Up @@ -235,7 +236,11 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
dependencyLoader = getBaseClassLoader(atts, dependencyLoader);

return new PluginWrapper(pluginManager, archive, manifest, baseResourceURL,
createClassLoader(paths, dependencyLoader, atts), disableFile, dependencies, optionalDependencies);
createClassLoader(computeClassLoaderName(manifest, archive), paths, dependencyLoader, atts), disableFile, dependencies, optionalDependencies);
}

private static String computeClassLoaderName(Manifest mf, File archive) {
return "PluginClassLoader for " + PluginWrapper.computeShortName(mf, archive.getName());
}

private void fix(Attributes atts, List<PluginWrapper.Dependency> optionalDependencies) {
Expand Down Expand Up @@ -263,15 +268,28 @@ public static List<PluginWrapper.Dependency> getImpliedDependencies(String plugi
return DetachedPluginsUtil.getImpliedDependencies(pluginName, jenkinsVersion);
}

@Deprecated
/**
* @deprecated since TODO use {@link #createClassLoader(String, List, ClassLoader, Attributes)}
*/
@Deprecated(since = "TODO")
protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent) throws IOException {
return createClassLoader(paths, parent, null);
}

/**
* Creates the classloader that can load all the specified jar files and delegate to the given parent.
* @deprecated since TODO use {@link #createClassLoader(String, List, ClassLoader, Attributes)}
*/
@Deprecated(since="TODO")
protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent, Attributes atts) throws IOException {
// generate a legacy id so at least we can track to something
return createClassLoader("unidentified-" + UUID.randomUUID(), paths, parent, atts);
}

/**
* Creates a classloader that can load all the specified jar files and delegate to the given parent.
* @since TODO
*/
protected ClassLoader createClassLoader(String name, List<File> paths, ClassLoader parent, Attributes atts) throws IOException {
boolean usePluginFirstClassLoader =
atts != null && Boolean.parseBoolean(atts.getValue("PluginFirstClassLoader"));

Expand All @@ -285,9 +303,9 @@ protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent, At
}
URLClassLoader2 classLoader;
if (usePluginFirstClassLoader) {
classLoader = new PluginFirstClassLoader2(urls.toArray(new URL[0]), parent);
classLoader = new PluginFirstClassLoader2(name, urls.toArray(new URL[0]), parent);
} else {
classLoader = new URLClassLoader2(urls.toArray(new URL[0]), parent);
classLoader = new URLClassLoader2(name, urls.toArray(new URL[0]), parent);
}
return classLoader;
}
Expand Down Expand Up @@ -561,7 +579,7 @@ static final class DependencyClassLoader extends ClassLoader {
}

DependencyClassLoader(ClassLoader parent, File archive, List<Dependency> dependencies, PluginManager pluginManager) {
super(parent);
super("dependency ClassLoader for " + archive.getPath(), parent);
this._for = archive;
this.dependencies = List.copyOf(dependencies);
this.pluginManager = pluginManager;
Expand Down
46 changes: 24 additions & 22 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import static hudson.Util.fixEmptyAndTrim;

import com.google.common.annotations.VisibleForTesting;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -61,7 +59,6 @@
import hudson.util.ExceptionCatchingThreadFactory;
import hudson.util.FileVisitor;
import hudson.util.FormValidation;
import hudson.util.HeadBufferingStream;
import hudson.util.IOUtils;
import hudson.util.NamingThreadFactory;
import hudson.util.io.Archiver;
Expand All @@ -80,6 +77,7 @@
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -123,21 +121,23 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import jenkins.MasterToSlaveFileCallable;
import jenkins.SlaveToMasterFileCallable;
import jenkins.model.Jenkins;
import jenkins.security.MasterToSlaveCallable;
import jenkins.util.ContextResettingExecutorService;
import jenkins.util.SystemProperties;
import jenkins.util.VirtualFile;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.input.CountingInputStream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarInputStream;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.jenkinsci.remoting.RoleChecker;
Expand Down Expand Up @@ -887,15 +887,8 @@ public OutputStream compress(OutputStream out) {
},
GZIP {
@Override
public InputStream extract(InputStream _in) throws IOException {
HeadBufferingStream in = new HeadBufferingStream(_in, SIDE_BUFFER_SIZE);
try {
return new GZIPInputStream(in, 8192, true);
} catch (IOException e) {
// various people reported "java.io.IOException: Not in GZIP format" here, so diagnose this problem better
in.fillSide();
throw new IOException(e.getMessage() + "\nstream=" + Util.toHexString(in.getSideBuffer()), e);
}
public InputStream extract(InputStream in) throws IOException {
return new GZIPInputStream(new BufferedInputStream(in));
}

@Override
Expand Down Expand Up @@ -1166,7 +1159,9 @@ public void copyFrom(FilePath src) throws IOException, InterruptedException {
public void copyFrom(FileItem file) throws IOException, InterruptedException {
if (channel == null) {
try {
file.write(new File(remote));
file.write(Paths.get(remote));
} catch (UncheckedIOException e) {
throw e.getCause();
} catch (IOException e) {
throw e;
} catch (Exception e) {
Expand All @@ -1180,6 +1175,14 @@ public void copyFrom(FileItem file) throws IOException, InterruptedException {
}
}

/**
* @deprecated use {@link #copyFrom(FileItem)}
*/
@Deprecated
public void copyFrom(org.apache.commons.fileupload.FileItem file) throws IOException, InterruptedException {
copyFrom(file.toFileUpload2FileItem());
}

/**
* Code that gets executed on the machine where the {@link FilePath} is local.
* Used to act on {@link FilePath}.
Expand Down Expand Up @@ -2460,7 +2463,7 @@ private OffsetPipeSecureFileCallable(Pipe p, long offset) {
@Override
public Void invoke(File f, VirtualChannel channel) throws IOException {
try (OutputStream os = p.getOut();
OutputStream out = new java.util.zip.GZIPOutputStream(os, 8192);
OutputStream out = new GZIPOutputStream(os, 8192);
RandomAccessFile raf = new RandomAccessFile(f, "r")) {
raf.seek(offset);
byte[] buf = new byte[8192];
Expand Down Expand Up @@ -3068,14 +3071,13 @@ private static void readFromTar(String name, File baseDir, InputStream in) throw

/**
* Reads from a tar stream and stores obtained files to the base dir.
* Supports large files > 10 GB since 1.627 when this was migrated to use commons-compress.
* Supports large files &gt; 10 GB since 1.627.
*/
private static void readFromTar(String name, File baseDir, InputStream in, Charset filenamesEncoding) throws IOException {

// TarInputStream t = new TarInputStream(in);
try (TarArchiveInputStream t = new TarArchiveInputStream(in, filenamesEncoding.name())) {
TarArchiveEntry te;
while ((te = t.getNextTarEntry()) != null) {
try (TarInputStream t = new TarInputStream(in, filenamesEncoding.name())) {
TarEntry te;
while ((te = t.getNextEntry()) != null) {
File f = new File(baseDir, te.getName());
if (!f.toPath().normalize().startsWith(baseDir.toPath())) {
throw new IOException(
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/PluginFirstClassLoader2.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public class PluginFirstClassLoader2 extends URLClassLoader2 {
registerAsParallelCapable();
}

public PluginFirstClassLoader2(@NonNull URL[] urls, @NonNull ClassLoader parent) {
super(Objects.requireNonNull(urls), Objects.requireNonNull(parent));

public PluginFirstClassLoader2(String name, @NonNull URL[] urls, @NonNull ClassLoader parent) {
super(name, Objects.requireNonNull(urls), Objects.requireNonNull(parent));
}

/**
Expand Down
Loading

0 comments on commit 32f9807

Please sign in to comment.