jfrog / build-info

Artifactory's open integration layer for CI build servers
https://www.buildinfo.org
Apache License 2.0
147 stars 155 forks source link

Fails on Windows with Guava 32.0.0 #737

Open Bananeweizen opened 1 year ago

Bananeweizen commented 1 year ago

Run Jenkins 2.407 with the Artifactory plugin containing this code, on a Windows machine. That leads to exceptions because some methods in Guava 32.0.0 simply don't work anymore on Windows. Older versions of Jenkins core contained Guava 31.x and therefore work fine.

Jenkins bug: https://issues.jenkins.io/browse/JENKINS-71375 Guava change describing the non-working behavior: https://github.com/google/guava/commit/3dfe3633eb84ec96ac88c764862b0f8d0c3546fc

The Jenkins core developers recommend removing Guava from Jenkins plugins. I support that opinion.

basil commented 1 year ago

Suggest the following patch:

diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java
index f74280ba..a1210ac7 100644
--- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java
+++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java
@@ -1,6 +1,6 @@
 package org.jfrog.build.extractor.clientConfiguration.util;

-import com.google.common.io.Files;
+import java.nio.file.Files;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.BooleanUtils;
@@ -245,7 +245,7 @@ public class DependenciesDownloaderHelper {
     protected Map<String, String> downloadFileConcurrently(final String uriWithParams, long fileSize, final String fileDestination, String filePath)
             throws Exception {
         String[] downloadedFilesPaths;
-        File tempDir = Files.createTempDir();
+        File tempDir = Files.createTempDirectory(null).toFile();
         String tempPath = tempDir.getPath() + File.separatorChar + filePath;
         try {
             downloadedFilesPaths = doConcurrentDownload(fileSize, uriWithParams, tempPath);
cpovirk commented 1 year ago

As the Guava developer responsible for this, I apologize for the trouble. I endorse the patch above, and I am working to fix this in Guava for anyone who isn't in a position to make such changes.

cpovirk commented 1 year ago

The Guava fix is released for anyone who needs it: https://github.com/google/guava/releases/tag/v32.0.1

cpovirk commented 1 year ago

Even with the Guava fix in place, we got another report of trouble from a Jenkins user with a slightly unusual setup (specifically, running as a Windows service). There may still be something that we can do about it on the Guava side, but if JFrog can apply the patch above, that would definitely solve that part of the problem.

yahavi commented 1 year ago

Thanks for the information, @cpovirk. Are you interested in making a contribution by submitting a pull request to address this problem?