Skip to content

Commit

Permalink
[JENKINS-50668] Prevent loading file in memory on upload
Browse files Browse the repository at this point in the history
Fixes java.lang.OutOfMemoryError: Java heap space
  • Loading branch information
carlossg committed Apr 9, 2018
1 parent 3a5d4d3 commit cfe56d3
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -349,6 +349,7 @@ private static void uploadFile(Path f, URL url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
connection.setFixedLengthStreamingMode(Files.size(f)); // prevent loading file in memory
try (OutputStream out = connection.getOutputStream()) {
Files.copy(f, out);
}
Expand Down

0 comments on commit cfe56d3

Please sign in to comment.