Skip to content

Commit

Permalink
Merge branch 'master' into executor-widget-condensed
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 authored May 25, 2024
2 parents 63a7ae3 + 8c5026a commit cc4c060
Show file tree
Hide file tree
Showing 104 changed files with 836 additions and 433 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=5829.v1ea_976c1636e
export ATH_VERSION=5858.v4b_c4e3b_16099

if [[ $# -eq 0 ]]; then
export JDK=17
Expand Down
50 changes: 43 additions & 7 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>1869.v3605a_771fb_e3</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.35</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
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
15 changes: 13 additions & 2 deletions core/src/main/java/hudson/FilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,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 @@ -132,7 +133,7 @@
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;
Expand Down Expand Up @@ -1166,7 +1167,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 +1183,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
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
32 changes: 21 additions & 11 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@
import jenkins.util.xml.RestrictiveEntityResolver;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload2.core.DiskFileItem;
import org.apache.commons.fileupload2.core.DiskFileItemFactory;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.fileupload2.core.FileUploadException;
import org.apache.commons.fileupload2.javax.JavaxServletDiskFileUpload;
import org.apache.commons.fileupload2.javax.JavaxServletFileUpload;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -1099,7 +1101,7 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException {
}

/*package*/ static @CheckForNull Manifest parsePluginManifest(URL bundledJpi) {
try (URLClassLoader cl = new URLClassLoader(new URL[]{bundledJpi})) {
try (URLClassLoader cl = new URLClassLoader("Temporary classloader for parsing " + bundledJpi.toString(), new URL[]{bundledJpi}, ClassLoader.getSystemClassLoader())) {
InputStream in = null;
try {
URL res = cl.findResource(PluginWrapper.MANIFEST_FILENAME);
Expand Down Expand Up @@ -1832,13 +1834,21 @@ static class FileUploadPluginCopier implements PluginCopier {
}

@Override
public void copy(File target) throws Exception {
fileItem.write(target);
public void copy(File target) throws IOException {
try {
fileItem.write(Util.fileToPath(target));
} catch (UncheckedIOException e) {
throw e.getCause();
}
}

@Override
public void cleanup() {
fileItem.delete();
try {
fileItem.delete();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}

Expand Down Expand Up @@ -1873,8 +1883,8 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
String fileName = "";
PluginCopier copier;
File tmpDir = Files.createTempDirectory("uploadDir").toFile();
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, tmpDir));
List<FileItem> items = upload.parseRequest(req);
JavaxServletFileUpload<DiskFileItem, DiskFileItemFactory> upload = new JavaxServletDiskFileUpload(DiskFileItemFactory.builder().setFile(tmpDir).get());
List<DiskFileItem> items = upload.parseRequest(req);
String string = items.get(1).getString();
if (string != null && !string.isBlank()) {
// this is a URL deployment
Expand Down Expand Up @@ -2337,7 +2347,7 @@ public static final class UberClassLoader extends ClassLoader {
}

public UberClassLoader(List<PluginWrapper> activePlugins) {
super(PluginManager.class.getClassLoader());
super("UberClassLoader", PluginManager.class.getClassLoader());
this.activePlugins = activePlugins;
}

Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/hudson/console/HyperlinkNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ static String encodeTo(String url, String text, BiFunction<String, Integer, Cons
// If text contains newlines, then its stored length will not match its length when being
// displayed, since the display length will only include text up to the first newline,
// which will cause an IndexOutOfBoundsException in MarkupText#rangeCheck when
// ConsoleAnnotationOutputStream converts the note into markup. That stream treats '\n' as
// the sole end-of-line marker on all platforms, so we ignore '\r' because it will not
// break the conversion.
text = text.replace('\n', ' ');
// ConsoleAnnotationOutputStream converts the note into markup.
text = text.replace('\n', ' ').replace('\r', ' ');
try {
return constructor.apply(url, text.length()).encode() + text;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @since 1.349
*/
public abstract class LineTransformationOutputStream extends OutputStream {
private boolean sawCR;
private ByteArrayOutputStream2 buf = new ByteArrayOutputStream2();

/**
Expand All @@ -53,8 +54,15 @@ public abstract class LineTransformationOutputStream extends OutputStream {

@Override
public void write(int b) throws IOException {
if (sawCR && b != '\n') {
eol();
}
buf.write(b);
if (b == LF) eol();
if (b == '\n') {
eol();
} else if (b == '\r') {
sawCR = true;
}
}

private void eol() throws IOException {
Expand All @@ -65,6 +73,7 @@ private void eol() throws IOException {
buf = new ByteArrayOutputStream2();
else
buf.reset();
sawCR = false;
}

@Override
Expand Down Expand Up @@ -110,8 +119,6 @@ protected String trimEOL(String line) {
return line;
}

private static final int LF = 0x0A;

/**
* Convenience subclass for cases where you wish to process lines being sent to an underlying stream.
* {@link #eol} will typically {@link OutputStream#write(byte[], int, int)} to {@link #out}.
Expand Down
Loading

0 comments on commit cc4c060

Please sign in to comment.