fix issue-2251

This commit is contained in:
chris-sharl 2019-12-19 18:39:04 +08:00
parent 0143dcfd24
commit 5272ae24b3

View File

@ -16,15 +16,21 @@
*/
package brut.util;
import brut.common.BrutException;
import org.apache.commons.io.IOUtils;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.io.IOUtils;
import brut.common.BrutException;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
@ -79,7 +85,14 @@ abstract public class Jar {
if (in == null) {
throw new FileNotFoundException(resourcePath);
}
File fileOut = File.createTempFile(tmpPrefix, null);
long n = ThreadLocalRandom.current().nextLong();
if (n == Long.MIN_VALUE) {
n = 0; // corner case
} else {
n = Math.abs(n);
}
String suffix = Long.toString(n) + ".tmp";
File fileOut = File.createTempFile(tmpPrefix, suffix);
fileOut.deleteOnExit();
OutputStream out = new FileOutputStream(fileOut);
IOUtils.copy(in, out);