Skip to content

Commit ca767ee

Browse files
committed
fix: commons-io compatibility
1 parent dd96afb commit ca767ee

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/browserstack/local/LocalBinary.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private static void newCopyToFile(URL url, File f) throws IOException {
205205
String contentEncoding = conn.getContentEncoding();
206206

207207
if (contentEncoding == null || !contentEncoding.toLowerCase().contains("gzip")) {
208-
FileUtils.copyToFile(conn.getInputStream(), f);
208+
customCopyInputStreamToFile(conn.getInputStream(), f, url);
209209
return;
210210
}
211211

@@ -214,9 +214,17 @@ private static void newCopyToFile(URL url, File f) throws IOException {
214214
System.out.println("using gzip in " + conn.getRequestProperty("User-Agent"));
215215
}
216216

217-
FileUtils.copyToFile(stream, f);
217+
customCopyInputStreamToFile(stream, f, url);
218218
} catch (ZipException e) {
219219
FileUtils.copyURLToFile(url, f);
220220
}
221221
}
222+
223+
private static void customCopyInputStreamToFile(InputStream stream, File file, URL url) throws IOException {
224+
try {
225+
FileUtils.copyInputStreamToFile(stream, file);
226+
} catch (Throwable e) {
227+
FileUtils.copyURLToFile(url, file);
228+
}
229+
}
222230
}

0 commit comments

Comments
 (0)