kopia lustrzana https://github.com/gaul/s3proxy
Address modern Guava deprecations
rodzic
456f7c7a0a
commit
51aa2e7fcd
|
@ -283,8 +283,8 @@ public final class Main {
|
|||
} else if (provider.equals("google-cloud-storage")) {
|
||||
File credentialFile = new File(credential);
|
||||
if (credentialFile.exists()) {
|
||||
credential = Files.toString(credentialFile,
|
||||
StandardCharsets.UTF_8);
|
||||
credential = Files.asCharSource(credentialFile,
|
||||
StandardCharsets.UTF_8).read();
|
||||
}
|
||||
properties.remove(Constants.PROPERTY_CREDENTIAL);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ import com.google.common.collect.Iterables;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.escape.Escaper;
|
||||
import com.google.common.hash.HashCode;
|
||||
import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.hash.HashingInputStream;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
@ -175,7 +176,9 @@ public class S3ProxyHandler {
|
|||
);
|
||||
private static final String XML_CONTENT_TYPE = "application/xml";
|
||||
/** URLEncoder escapes / which we do not want. */
|
||||
private static Escaper urlEscaper = new PercentEscaper("*-./_", true);
|
||||
private static final Escaper urlEscaper = new PercentEscaper("*-./_", true);
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final HashFunction MD5 = Hashing.md5();
|
||||
|
||||
private final boolean anonymousIdentity;
|
||||
private final AuthenticationType authenticationType;
|
||||
|
@ -1662,7 +1665,7 @@ public class S3ProxyHandler {
|
|||
} catch (IllegalArgumentException iae) {
|
||||
throw new S3Exception(S3ErrorCode.INVALID_DIGEST, iae);
|
||||
}
|
||||
if (contentMD5.bits() != Hashing.md5().bits()) {
|
||||
if (contentMD5.bits() != MD5.bits()) {
|
||||
throw new S3Exception(S3ErrorCode.INVALID_DIGEST);
|
||||
}
|
||||
}
|
||||
|
@ -2276,8 +2279,7 @@ public class S3ProxyHandler {
|
|||
// part multiple Azure parts.
|
||||
long azureMaximumMultipartPartSize =
|
||||
blobStore.getMaximumMultipartPartSize();
|
||||
HashingInputStream his = new HashingInputStream(Hashing.md5(),
|
||||
is);
|
||||
HashingInputStream his = new HashingInputStream(MD5, is);
|
||||
for (int offset = 0, subPartNumber = 0; offset < contentLength;
|
||||
offset += azureMaximumMultipartPartSize,
|
||||
++subPartNumber) {
|
||||
|
@ -2354,7 +2356,7 @@ public class S3ProxyHandler {
|
|||
} catch (IllegalArgumentException iae) {
|
||||
throw new S3Exception(S3ErrorCode.INVALID_DIGEST, iae);
|
||||
}
|
||||
if (contentMD5.bits() != Hashing.md5().bits()) {
|
||||
if (contentMD5.bits() != MD5.bits()) {
|
||||
throw new S3Exception(S3ErrorCode.INVALID_DIGEST);
|
||||
}
|
||||
}
|
||||
|
@ -2405,8 +2407,7 @@ public class S3ProxyHandler {
|
|||
// part multiple Azure parts.
|
||||
long azureMaximumMultipartPartSize =
|
||||
blobStore.getMaximumMultipartPartSize();
|
||||
HashingInputStream his = new HashingInputStream(Hashing.md5(),
|
||||
is);
|
||||
HashingInputStream his = new HashingInputStream(MD5, is);
|
||||
for (int offset = 0, subPartNumber = 0; offset < contentLength;
|
||||
offset += azureMaximumMultipartPartSize,
|
||||
++subPartNumber) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.inject.Module;
|
||||
|
@ -196,7 +195,7 @@ public final class EventualBlobStoreTest {
|
|||
.contentEncoding("compress")
|
||||
.contentLength(BYTE_SOURCE.size())
|
||||
.contentType(MediaType.MP4_AUDIO)
|
||||
.contentMD5(BYTE_SOURCE.hash(Hashing.md5()))
|
||||
.contentMD5(BYTE_SOURCE.hash(TestUtils.MD5))
|
||||
.userMetadata(ImmutableMap.of("key", "value"))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.net.MediaType;
|
||||
|
@ -181,7 +180,7 @@ public final class NullBlobStoreTest {
|
|||
.contentEncoding("compress")
|
||||
.contentLength(BYTE_SOURCE.size())
|
||||
.contentType(MediaType.MP4_AUDIO)
|
||||
.contentMD5(BYTE_SOURCE.hash(Hashing.md5()))
|
||||
.contentMD5(BYTE_SOURCE.hash(TestUtils.MD5))
|
||||
.userMetadata(ImmutableMap.of("key", "value"))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.Random;
|
|||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.Resources;
|
||||
|
@ -41,6 +43,9 @@ import org.jclouds.blobstore.BlobStoreContext;
|
|||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
|
||||
final class TestUtils {
|
||||
@SuppressWarnings("deprecation")
|
||||
static final HashFunction MD5 = Hashing.md5();
|
||||
|
||||
private TestUtils() {
|
||||
throw new AssertionError("intentionally unimplemented");
|
||||
}
|
||||
|
@ -164,8 +169,8 @@ final class TestUtils {
|
|||
if (provider.equals("google-cloud-storage")) {
|
||||
File credentialFile = new File(credential);
|
||||
if (credentialFile.exists()) {
|
||||
credential = Files.toString(credentialFile,
|
||||
StandardCharsets.UTF_8);
|
||||
credential = Files.asCharSource(credentialFile,
|
||||
StandardCharsets.UTF_8).read();
|
||||
}
|
||||
info.getProperties().remove(Constants.PROPERTY_CREDENTIAL);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue