Skip to content
Permalink
Browse files
[FIXED JENKINS-22641] FileUtils.readFileToByteArray behavior has chan…
…ged in the latest version of commons-io.
  • Loading branch information
christ66 committed Jul 17, 2014
1 parent 682ba57 commit 410f06adfa798d29118c77ed01c5c02fc207cb02
Showing 1 changed file with 13 additions and 12 deletions.
@@ -37,19 +37,10 @@
import hudson.util.ProcessTree.OSProcess;
import hudson.util.ProcessTreeRemoting.IOSProcess;
import hudson.util.ProcessTreeRemoting.IProcessTree;
import org.apache.commons.io.FileUtils;
import org.jvnet.winp.WinProcess;
import org.jvnet.winp.WinpException;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -680,7 +671,7 @@ public synchronized List<String> getArguments() {
return arguments;
arguments = new ArrayList<String>();
try {
byte[] cmdline = FileUtils.readFileToByteArray(getFile("cmdline"));
byte[] cmdline = readFileToByteArray(getFile("cmdline"));
int pos=0;
for (int i = 0; i < cmdline.length; i++) {
byte b = cmdline[i];
@@ -702,7 +693,7 @@ public synchronized EnvVars getEnvironmentVariables() {
return envVars;
envVars = new EnvVars();
try {
byte[] environ = FileUtils.readFileToByteArray(getFile("environ"));
byte[] environ = readFileToByteArray(getFile("environ"));
int pos=0;
for (int i = 0; i < environ.length; i++) {
byte b = environ[i];
@@ -718,6 +709,16 @@ public synchronized EnvVars getEnvironmentVariables() {
return envVars;
}
}

public byte[] readFileToByteArray(File file) throws IOException {
InputStream in = null;
try {
in = org.apache.commons.io.FileUtils.openInputStream(file);
return org.apache.commons.io.IOUtils.toByteArray(in);
} finally {
org.apache.commons.io.IOUtils.closeQuietly(in);
}
}
}

/**

0 comments on commit 410f06a

Please sign in to comment.