fix url-encoded java.io.tmpdir property
package co.elastic.apm.agent.util;
import co.elastic.apm.agent.bci.VisibleForAdvice;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
+import java.net.URLDecoder;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@@ -219,7 +221,11 @@ public class IOUtils {
throw new IllegalStateException(resource + " not found");
}
String hash = md5Hash(IOUtils.class.getResourceAsStream("/" + resource));
- File tempFile = new File(System.getProperty("java.io.tmpdir"), tempFileNamePrefix + "-" + hash + tempFileNameExtension);
+
+ // temp folder might be url-encoded
+ String tempFolder = URLDecoder.decode(System.getProperty("java.io.tmpdir"), StandardCharsets.UTF_8.name());
+
+ File tempFile = new File(tempFolder, tempFileNamePrefix + "-" + hash + tempFileNameExtension);
if (!tempFile.exists()) {
try (FileOutputStream out = new FileOutputStream(tempFile)) {
FileChannel channel = out.getChannel();
