From 9361455c4b7d18782660807dfdb9a21b033dcb04 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Fri, 13 Dec 2024 14:41:06 -0800 Subject: [PATCH] Reduce usage of Ant --- .../main/java/hudson/model/DirectoryBrowserSupport.java | 8 ++++---- core/src/main/java/jenkins/util/VirtualFile.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java index 72da0c7514c1..242975e2b13b 100644 --- a/core/src/main/java/hudson/model/DirectoryBrowserSupport.java +++ b/core/src/main/java/hudson/model/DirectoryBrowserSupport.java @@ -58,6 +58,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import jenkins.model.Jenkins; import jenkins.security.MasterToSlaveCallable; import jenkins.security.ResourceDomainConfiguration; @@ -65,8 +67,6 @@ import jenkins.util.SystemProperties; import jenkins.util.VirtualFile; import org.apache.commons.io.IOUtils; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipOutputStream; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.HttpResponse; @@ -530,8 +530,8 @@ private static String createBackRef(int times) { private static void zip(StaplerResponse2 rsp, VirtualFile root, VirtualFile dir, String glob) throws IOException, InterruptedException { OutputStream outputStream = rsp.getOutputStream(); - try (ZipOutputStream zos = new ZipOutputStream(outputStream)) { - zos.setEncoding(Charset.defaultCharset().displayName()); // TODO JENKINS-20663 make this overridable via query parameter + // TODO JENKINS-20663 make encoding overridable via query parameter + try (ZipOutputStream zos = new ZipOutputStream(outputStream, Charset.defaultCharset())) { // TODO consider using run(Callable) here if (glob.isEmpty()) { diff --git a/core/src/main/java/jenkins/util/VirtualFile.java b/core/src/main/java/jenkins/util/VirtualFile.java index 6c754a50bbc4..36279a8ec6fa 100644 --- a/core/src/main/java/jenkins/util/VirtualFile.java +++ b/core/src/main/java/jenkins/util/VirtualFile.java @@ -60,6 +60,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import jenkins.MasterToSlaveFileCallable; import jenkins.model.ArtifactManager; import jenkins.security.MasterToSlaveCallable; @@ -68,8 +70,6 @@ import org.apache.tools.ant.types.selectors.SelectorUtils; import org.apache.tools.ant.types.selectors.TokenizedPath; import org.apache.tools.ant.types.selectors.TokenizedPattern; -import org.apache.tools.zip.ZipEntry; -import org.apache.tools.zip.ZipOutputStream; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -375,8 +375,8 @@ public int zip(OutputStream outputStream, String includes, String excludes, bool } Collection files = list(includes, excludes, useDefaultExcludes, openOptions); - try (ZipOutputStream zos = new ZipOutputStream(outputStream)) { - zos.setEncoding(Charset.defaultCharset().displayName()); // TODO JENKINS-20663 make this overridable via query parameter + // TODO JENKINS-20663 make encoding overridable via query parameter + try (ZipOutputStream zos = new ZipOutputStream(outputStream, Charset.defaultCharset())) { for (String relativePath : files) { VirtualFile virtualFile = this.child(relativePath);