Skip to content

Commit ec61b76

Browse files
authored
Remove DockerServiceImpl.StreamUtils (#2648)
This entire class is only used to support a simple Files.copy() operation: convert the sole user and remove the class. Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
1 parent 7eb0359 commit ec61b76

1 file changed

Lines changed: 22 additions & 50 deletions

File tree

docker/src/main/java/org/apache/karaf/docker/internal/DockerServiceImpl.java

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,29 @@
1616
*/
1717
package org.apache.karaf.docker.internal;
1818

19-
import org.apache.karaf.docker.*;
20-
21-
import java.io.*;
19+
import org.apache.karaf.docker.Container;
20+
import org.apache.karaf.docker.ContainerConfig;
21+
import org.apache.karaf.docker.DockerClient;
22+
import org.apache.karaf.docker.DockerService;
23+
import org.apache.karaf.docker.HostConfig;
24+
import org.apache.karaf.docker.HostPortBinding;
25+
import org.apache.karaf.docker.Image;
26+
import org.apache.karaf.docker.ImageHistory;
27+
import org.apache.karaf.docker.ImageSearch;
28+
import org.apache.karaf.docker.Info;
29+
import org.apache.karaf.docker.Top;
30+
import org.apache.karaf.docker.Version;
31+
32+
import java.io.File;
33+
import java.io.IOException;
2234
import java.nio.file.Files;
2335
import java.nio.file.attribute.PosixFilePermission;
24-
import java.util.*;
36+
import java.util.ArrayList;
37+
import java.util.HashMap;
38+
import java.util.HashSet;
39+
import java.util.List;
40+
import java.util.Map;
41+
import java.util.Set;
2542

2643
public class DockerServiceImpl implements DockerService {
2744

@@ -377,53 +394,8 @@ private void copy(File source, File destination) throws IOException {
377394
copy(new File(source, child), new File(destination, child));
378395
}
379396
} else {
380-
try (
381-
InputStream in = new FileInputStream(source);
382-
OutputStream out = new FileOutputStream(destination)
383-
) {
384-
new StreamUtils().copy(in, out);
385-
}
386-
}
387-
}
388-
389-
class StreamUtils {
390-
391-
public StreamUtils() {
392-
}
393-
394-
public void close(Closeable... closeables) {
395-
for (Closeable c : closeables) {
396-
try {
397-
if (c != null) {
398-
c.close();
399-
}
400-
} catch (IOException e) {
401-
// Ignore
402-
}
403-
}
404-
}
405-
406-
public void close(Iterable<Closeable> closeables) {
407-
for (Closeable c : closeables) {
408-
try {
409-
if (c != null) {
410-
c.close();
411-
}
412-
} catch (IOException e) {
413-
// Ignore
414-
}
415-
}
397+
Files.copy(source.toPath(), destination.toPath());
416398
}
417-
418-
public void copy(final InputStream input, final OutputStream output) throws IOException {
419-
byte[] buffer = new byte[1024 * 16];
420-
int n;
421-
while ((n = input.read(buffer)) > 0) {
422-
output.write(buffer, 0, n);
423-
}
424-
output.flush();
425-
}
426-
427399
}
428400

429401
private static void makeFileExecutable(File serviceFile) throws IOException {

0 commit comments

Comments
 (0)