Skip to content

Commit

Permalink
Drop guava (fixes #74)
Browse files Browse the repository at this point in the history
- Remove workaround for JERSEY-2878
  • Loading branch information
dmandalidis committed Nov 17, 2019
1 parent 69af7cd commit cd93223
Show file tree
Hide file tree
Showing 32 changed files with 415 additions and 421 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* `RegistryConfigs.Builder#addConfig` does not ignore null `RegistryAuth` values anymore
* `HostConfig.Builder#appendBinds*` methods removed
* `HostConfig.Builder#binds(final Bind... binds)` method does not ignore null binds anymore
* `Immutable*` types removed from public getters and builders

## 2.0.2

Expand Down
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<violationSeverity>warning</violationSeverity>
<excludes>**\/AutoValue_*.java</excludes>
<excludes>**\/Immutable*.java</excludes>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -415,7 +415,6 @@
<configuration>
<excludes>
<exclude>org/mandas/**/Immutable*</exclude>
<exclude>org/mandas/**/AutoValue*</exclude>
</excludes>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@

package org.mandas.docker.client;

import com.google.common.collect.Maps;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

import org.mandas.docker.client.exceptions.DockerException;
import org.mandas.docker.client.messages.ProgressMessage;

import java.io.PrintStream;
import java.util.Map;

/**
* Parses ProgressMessage objects and writes the output to a PrintStream. The output includes ANSI
* escape characters to move the cursor around to nicely print progress bars.
Expand All @@ -46,7 +45,7 @@ public AnsiProgressHandler() {

public AnsiProgressHandler(PrintStream out) {
this.out = out;
idsToLines = Maps.newHashMap();
idsToLines = new HashMap<>();
}

@Override
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/org/mandas/docker/client/CompressedDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@

package org.mandas.docker.client;

import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.Collections.reverse;
import static java.util.Collections.unmodifiableList;
import static org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.BIGNUMBER_POSIX;
import static org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.LONGFILE_POSIX;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -44,7 +42,9 @@
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -104,8 +104,7 @@ public static CompressedDirectory create(final Path directory) throws IOExceptio
final Path file = Files.createTempFile("docker-client-", ".tar.gz");

final Path dockerIgnorePath = directory.resolve(".dockerignore");
final ImmutableList<DockerIgnorePathMatcher> ignoreMatchers =
parseDockerIgnore(dockerIgnorePath);
final List<DockerIgnorePathMatcher> ignoreMatchers = parseDockerIgnore(dockerIgnorePath);

try (final OutputStream fileOut = Files.newOutputStream(file);
final GzipCompressorOutputStream gzipOut = new GzipCompressorOutputStream(fileOut);
Expand Down Expand Up @@ -137,14 +136,14 @@ public void close() throws IOException {
Files.delete(file);
}

static ImmutableList<DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnorePath)
static List<DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnorePath)
throws IOException {
final ImmutableList.Builder<DockerIgnorePathMatcher> matchersBuilder = ImmutableList.builder();
final List<DockerIgnorePathMatcher> matchersBuilder = new ArrayList<>();

if (Files.isReadable(dockerIgnorePath) && Files.isRegularFile(dockerIgnorePath)) {
for (final String line : Files.readAllLines(dockerIgnorePath, StandardCharsets.UTF_8)) {
final String pattern = createPattern(line);
if (isNullOrEmpty(pattern)) {
if (pattern == null || "".equals(pattern.trim())) {
log.debug("Will skip '{}' - because it's empty after trimming or it's a comment", line);
continue;
}
Expand All @@ -158,7 +157,7 @@ static ImmutableList<DockerIgnorePathMatcher> parseDockerIgnore(Path dockerIgnor
}
}

return matchersBuilder.build();
return unmodifiableList(matchersBuilder);
}

private static String createPattern(String line) {
Expand All @@ -172,7 +171,6 @@ private static String createPattern(String line) {
return pattern.replace("/", "\\\\");
}

@VisibleForTesting
static PathMatcher goPathMatcher(FileSystem fs, String pattern) {
// Supposed to work the same way as Go's path.filepath.match.Match:
// http://golang.org/src/path/filepath/match.go#L34
Expand Down Expand Up @@ -253,15 +251,16 @@ private static String getNotSeparatorPattern(String separator) {
private static class Visitor extends SimpleFileVisitor<Path> {

private final Path root;
private final ImmutableList<DockerIgnorePathMatcher> ignoreMatchers;
private final List<DockerIgnorePathMatcher> ignoreMatchers;
private final TarArchiveOutputStream tarStream;

private Visitor(final Path root, ImmutableList<DockerIgnorePathMatcher> ignoreMatchers,
private Visitor(final Path root, List<DockerIgnorePathMatcher> ignoreMatchers,
final TarArchiveOutputStream tarStream) {
this.root = root;
// .dockerignore matchers need to be read from the bottom of the file,
// so the given list should be reversed before using it.
this.ignoreMatchers = ignoreMatchers.reverse();
this.ignoreMatchers = new ArrayList<>(ignoreMatchers);
reverse(this.ignoreMatchers);
this.tarStream = tarStream;
}

Expand Down Expand Up @@ -312,7 +311,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
* @param path the path to match
* @return <code>true</code> if the given path should be excluded, <code>false</code> otherwise
*/
private static boolean exclude(ImmutableList<DockerIgnorePathMatcher> matchers, Path path) {
private static boolean exclude(List<DockerIgnorePathMatcher> matchers, Path path) {
for (final DockerIgnorePathMatcher matcher : matchers) {
if (matcher.matches(path)) {
return matcher.isExclude();
Expand Down
Loading

0 comments on commit cd93223

Please sign in to comment.