mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
Remove usages of IOUtils#toByteArray (#8098)
This commit is contained in:
1 parent
c084ee05c2
commit
41edd5faf4
7 files changed
+11
-24
No files matched your search
@@ -1135,7 +1135,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
final JarEntry entry = entryName != null && jarFile != null ? jarFile.getJarEntry(entryName) : null;
|
||||
if (entry != null) {
|
||||
try (InputStream i = jarFile.getInputStream(entry)) {
|
||||
byte[] manifestBytes = IOUtils.toByteArray(i);
|
||||
byte[] manifestBytes = i.readAllBytes();
|
||||
in = new ByteArrayInputStream(manifestBytes);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.apache.commons.fileupload.FileItemHeaders;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItem;
|
||||
import org.apache.commons.fileupload.util.FileItemHeadersImpl;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.NoExternalUse;
|
||||
import org.kohsuke.stapler.DataBoundConstructor;
|
||||
@@ -288,9 +287,7 @@ public class FileParameterValue extends ParameterValue {
|
||||
@Override
|
||||
public byte[] get() {
|
||||
try {
|
||||
try (InputStream inputStream = Files.newInputStream(file.toPath())) {
|
||||
return IOUtils.toByteArray(inputStream);
|
||||
}
|
||||
return Files.readAllBytes(file.toPath());
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ import jenkins.model.Jenkins;
|
||||
import jenkins.security.MasterToSlaveCallable;
|
||||
import jenkins.slaves.WorkspaceLocator;
|
||||
import jenkins.util.SystemProperties;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.kohsuke.accmod.Restricted;
|
||||
import org.kohsuke.accmod.restrictions.DoNotUse;
|
||||
@@ -470,7 +469,7 @@ public abstract class Slave extends Node implements Serializable {
|
||||
|
||||
public byte[] readFully() throws IOException {
|
||||
try (InputStream in = connect().getInputStream()) {
|
||||
return IOUtils.toByteArray(in);
|
||||
return in.readAllBytes();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.Serializable;
|
||||
@@ -75,7 +74,6 @@ import java.util.logging.Logger;
|
||||
import jenkins.agents.AgentComputerUtil;
|
||||
import jenkins.security.SlaveToMasterCallable;
|
||||
import jenkins.util.SystemProperties;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jenkinsci.remoting.SerializableOnlyOverRemoting;
|
||||
import org.jvnet.winp.WinProcess;
|
||||
import org.jvnet.winp.WinpException;
|
||||
@@ -914,7 +912,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
return arguments;
|
||||
arguments = new ArrayList<>();
|
||||
try {
|
||||
byte[] cmdline = readFileToByteArray(getFile("cmdline"));
|
||||
byte[] cmdline = Files.readAllBytes(Util.fileToPath(getFile("cmdline")));
|
||||
int pos = 0;
|
||||
for (int i = 0; i < cmdline.length; i++) {
|
||||
byte b = cmdline[i];
|
||||
@@ -938,7 +936,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
return envVars;
|
||||
envVars = new EnvVars();
|
||||
try {
|
||||
byte[] environ = readFileToByteArray(getFile("environ"));
|
||||
byte[] environ = Files.readAllBytes(Util.fileToPath(getFile("environ")));
|
||||
int pos = 0;
|
||||
for (int i = 0; i < environ.length; i++) {
|
||||
byte b = environ[i];
|
||||
@@ -954,12 +952,6 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
|
||||
return envVars;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] readFileToByteArray(File file) throws IOException {
|
||||
try (InputStream in = FileUtils.openInputStream(file)) {
|
||||
return org.apache.commons.io.IOUtils.toByteArray(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import javax.crypto.CipherInputStream;
|
||||
import javax.crypto.CipherOutputStream;
|
||||
import javax.crypto.SecretKey;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
/**
|
||||
* Default portable implementation of {@link ConfidentialStore} that uses
|
||||
@@ -104,7 +103,7 @@ public class DefaultConfidentialStore extends ConfidentialStore {
|
||||
sym.init(Cipher.DECRYPT_MODE, masterKey);
|
||||
try (InputStream fis = Files.newInputStream(f.toPath());
|
||||
CipherInputStream cis = new CipherInputStream(fis, sym)) {
|
||||
byte[] bytes = IOUtils.toByteArray(cis);
|
||||
byte[] bytes = cis.readAllBytes();
|
||||
return verifyMagic(bytes);
|
||||
}
|
||||
} catch (GeneralSecurityException e) {
|
||||
|
||||
Reference in new issue
Block a user