Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.uber.jenkins.phabricator.utils.Logger;
import hudson.FilePath;

import org.apache.commons.io.IOUtils;
import java.io.IOException;

import static java.lang.Integer.parseInt;
Expand Down Expand Up @@ -75,7 +76,7 @@ public String getRemoteFile() throws InterruptedException, IOException {
maxLength = (int)source.length();
}
byte[] buffer = new byte[maxLength];
source.read().read(buffer, 0, maxLength);
IOUtils.read(source.read(), buffer);

return new String(buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.apache.commons.lang.StringUtils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -76,15 +77,20 @@ public void testNoCommentConfigured() throws Exception {

@Test
public void testSingleFile() throws Exception {
testWithContent("hello, world");
testWithContent("hello, world", "1000");
}

@Test
public void testUTF8File() throws Exception {
testWithContent("こんにちは世界");
testWithContent("こんにちは世界", "1000");
}

private void testWithContent(String content) throws Exception {
@Test
public void testLargeFile() throws Exception {
testWithContent(StringUtils.repeat("a", 10000), "10000");
}

private void testWithContent(String content, String len) throws Exception {
final String fileName = "just-a-test.txt";
project.getBuildersList().add(echoBuilder(fileName, content));
FreeStyleBuild build = getBuild();
Expand All @@ -93,7 +99,7 @@ private void testWithContent(String content) throws Exception {
build.getWorkspace(),
logger,
fileName,
"1000"
len
);

assertEquals(content, fetcher.getRemoteFile());
Expand All @@ -102,7 +108,7 @@ private void testWithContent(String content) throws Exception {
build.getWorkspace(),
logger,
"*.txt",
"1000"
len
);

assertEquals(content, fetcher.getRemoteFile());
Expand Down