mirror of https://github.com/apache/jclouds.git
Remove unneeded calls to ByteSources.asByteSource
This commit is contained in:
parent
0398276be3
commit
ac1f05ffac
|
@ -24,7 +24,6 @@ import static org.jclouds.blobstore.options.GetOptions.Builder.ifModifiedSince;
|
|||
import static org.jclouds.blobstore.options.GetOptions.Builder.ifUnmodifiedSince;
|
||||
import static org.jclouds.blobstore.options.GetOptions.Builder.range;
|
||||
import static org.jclouds.concurrent.FutureIterables.awaitCompletion;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
@ -105,7 +104,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
|||
}
|
||||
|
||||
protected static byte[] md5Supplier(InputSupplier<? extends InputStream> supplier) throws IOException {
|
||||
return asByteSource(supplier.getInput()).hash(md5()).asBytes();
|
||||
return ByteStreams.hash(supplier, md5()).asBytes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.io;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.hash.Hashing.md5;
|
||||
import static com.google.common.io.ByteStreams.toByteArray;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -31,6 +30,7 @@ import org.jclouds.io.payloads.StringPayload;
|
|||
import org.jclouds.io.payloads.UrlEncodedFormPayload;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -102,7 +102,7 @@ public class Payloads {
|
|||
oldContentMetadata.setContentMD5(payload.getContentMetadata().getContentMD5());
|
||||
payload.setContentMetadata(oldContentMetadata);
|
||||
}
|
||||
payload.getContentMetadata().setContentMD5(asByteSource(payload.getInput()).hash(md5()).asBytes());
|
||||
payload.getContentMetadata().setContentMD5(ByteStreams.hash(payload, md5()).asBytes());
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import static com.google.common.io.BaseEncoding.base64;
|
|||
import static com.google.common.io.Closeables.closeQuietly;
|
||||
import static java.lang.String.format;
|
||||
import static org.jclouds.http.options.GetOptions.Builder.tail;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
import static org.jclouds.io.Payloads.newFilePayload;
|
||||
import static org.jclouds.io.Payloads.newStringPayload;
|
||||
import static org.jclouds.util.Throwables2.getFirstThrowableOfType;
|
||||
|
@ -45,7 +46,6 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.CharSink;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
|
@ -131,12 +131,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
|||
}
|
||||
|
||||
private void assertValidMd5(final InputStream input) throws IOException {
|
||||
assertEquals(base64().encode(new ByteSource() {
|
||||
@Override
|
||||
public InputStream openStream() {
|
||||
return input;
|
||||
}
|
||||
}.hash(md5()).asBytes()), md5);
|
||||
assertEquals(base64().encode(asByteSource(input).hash(md5()).asBytes()), md5);
|
||||
}
|
||||
|
||||
private InputStream getConsitution() throws MalformedURLException, IOException {
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.google.common.collect.ImmutableMap.Builder;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.InputSupplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
@ -94,7 +95,7 @@ public abstract class BaseJettyTest {
|
|||
this.testPort = testPort;
|
||||
|
||||
final InputSupplier<InputStream> oneHundredOneConstitutions = getTestDataSupplier();
|
||||
md5 = base64().encode(asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes());
|
||||
md5 = base64().encode(ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes());
|
||||
|
||||
Handler server1Handler = new AbstractHandler() {
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.easymock.EasyMock.createMock;
|
|||
import static org.eclipse.jetty.http.HttpHeaders.TRANSFER_ENCODING;
|
||||
import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS;
|
||||
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -50,6 +49,7 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SortedSetMultimap;
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.reflect.Invokable;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.SimpleTimeLimiter;
|
||||
|
@ -125,7 +125,7 @@ public abstract class BaseRestApiTest {
|
|||
Long length = Long.valueOf(payload.getBytes().length);
|
||||
try {
|
||||
assertContentHeadersEqual(request, contentType, contentDispositon, contentEncoding, contentLanguage,
|
||||
length, contentMD5 ? asByteSource(request.getPayload().getInput()).hash(md5()).asBytes() : null, expires);
|
||||
length, contentMD5 ? ByteStreams.hash(request.getPayload(), md5()).asBytes() : null, expires);
|
||||
} catch (IOException e) {
|
||||
propagate(e);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jclouds.http.apachehc;
|
|||
import static com.google.common.hash.Hashing.md5;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
import static org.jclouds.http.HttpUtils.filterOutContentHeaders;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -45,6 +44,7 @@ import org.jclouds.io.Payloads;
|
|||
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class ApacheHCHttpCommandExecutorService extends BaseHttpCommandExecutorS
|
|||
protected HttpUriRequest convert(HttpRequest request) throws IOException {
|
||||
HttpUriRequest returnVal = apacheHCUtils.convertToApacheRequest(request);
|
||||
if (request.getPayload() != null && request.getPayload().getContentMetadata().getContentMD5() != null) {
|
||||
String md5 = base64().encode(asByteSource(request.getPayload().getInput()).hash(md5()).asBytes());
|
||||
String md5 = base64().encode(ByteStreams.hash(request.getPayload(), md5()).asBytes());
|
||||
returnVal.addHeader("Content-MD5", md5);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import static com.google.common.io.ByteStreams.join;
|
|||
import static com.google.common.io.ByteStreams.newInputStreamSupplier;
|
||||
import static com.google.common.io.ByteStreams.toByteArray;
|
||||
import static org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.storageClass;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
import static org.jclouds.io.Payloads.newByteArrayPayload;
|
||||
import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -62,6 +61,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest {
|
|||
public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception {
|
||||
super.setUpResourcesOnThisThread(testContext);
|
||||
oneHundredOneConstitutions = getTestDataSupplier();
|
||||
oneHundredOneConstitutionsMD5 = asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes();
|
||||
oneHundredOneConstitutionsMD5 = ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.testng.annotations.Test;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import static com.google.common.hash.Hashing.md5;
|
||||
import static org.jclouds.io.ByteSources.asByteSource;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -82,7 +81,7 @@ public class AzureBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
|
|||
*/
|
||||
public void testMultipartChunkedFileStream() throws IOException, InterruptedException {
|
||||
oneHundredOneConstitutions = getTestDataSupplier();
|
||||
oneHundredOneConstitutionsMD5 = asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes();
|
||||
oneHundredOneConstitutionsMD5 = ByteStreams.hash(oneHundredOneConstitutions, md5()).asBytes();
|
||||
File file = new File("target/const.txt");
|
||||
Files.copy(oneHundredOneConstitutions, file);
|
||||
String containerName = getContainerName();
|
||||
|
|
Loading…
Reference in New Issue