Skip to content

Commit

Permalink
[FIXED JENKINS-22641] FileUtils.readFileToByteArray behavior has chan…
Browse files Browse the repository at this point in the history
…ged in the latest version of commons-io.
  • Loading branch information
christ66 committed Jul 17, 2014
1 parent 682ba57 commit 410f06a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions core/src/main/java/hudson/util/ProcessTree.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand All @@ -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);
}
}
}

/**
Expand Down

0 comments on commit 410f06a

Please sign in to comment.