Use var for Immutable builders

pull/666/head
Andrew Gaul 2024-07-20 12:42:05 +05:30
rodzic 5a129e54cf
commit 0effb4bf45
11 zmienionych plików z 64 dodań i 95 usunięć

Wyświetl plik

@ -135,8 +135,7 @@ public final class AliasBlobStore extends ForwardingBlobStore {
@Override @Override
public PageSet<? extends StorageMetadata> list() { public PageSet<? extends StorageMetadata> list() {
PageSet<? extends StorageMetadata> upstream = this.delegate().list(); PageSet<? extends StorageMetadata> upstream = this.delegate().list();
ImmutableList.Builder<StorageMetadata> results = var results = new ImmutableList.Builder<StorageMetadata>();
new ImmutableList.Builder<>();
for (StorageMetadata sm : upstream) { for (StorageMetadata sm : upstream) {
if (aliases.containsValue(sm.getName())) { if (aliases.containsValue(sm.getName())) {
MutableStorageMetadata bucketAlias = MutableStorageMetadata bucketAlias =

Wyświetl plik

@ -233,7 +233,7 @@ public final class EncryptedBlobStore extends ForwardingBlobStore {
// filter the list by showing the unencrypted blob size // filter the list by showing the unencrypted blob size
private PageSet<? extends StorageMetadata> filteredList( private PageSet<? extends StorageMetadata> filteredList(
PageSet<? extends StorageMetadata> pageSet) { PageSet<? extends StorageMetadata> pageSet) {
ImmutableSet.Builder<StorageMetadata> builder = ImmutableSet.builder(); var builder = ImmutableSet.<StorageMetadata>builder();
for (StorageMetadata sm : pageSet) { for (StorageMetadata sm : pageSet) {
if (sm instanceof BlobMetadata) { if (sm instanceof BlobMetadata) {
MutableBlobMetadata mbm = MutableBlobMetadata mbm =

Wyświetl plik

@ -106,10 +106,10 @@ public final class Main {
.build(); .build();
ExecutorService executorService = DynamicExecutors.newScalingThreadPool( ExecutorService executorService = DynamicExecutors.newScalingThreadPool(
1, 20, 60 * 1000, factory); 1, 20, 60 * 1000, factory);
ImmutableMap.Builder<String, Map.Entry<String, BlobStore>> locators = var locators = ImmutableMap
ImmutableMap.builder(); .<String, Map.Entry<String, BlobStore>>builder();
ImmutableMap.Builder<PathMatcher, Map.Entry<String, BlobStore>> var globLocators = ImmutableMap
globLocators = ImmutableMap.builder(); .<PathMatcher, Map.Entry<String, BlobStore>>builder();
Set<String> locatorGlobs = new HashSet<>(); Set<String> locatorGlobs = new HashSet<>();
Set<String> parsedIdentities = new HashSet<>(); Set<String> parsedIdentities = new HashSet<>();
for (File propertiesFile : options.propertiesFiles) { for (File propertiesFile : options.propertiesFiles) {
@ -177,10 +177,8 @@ public final class Main {
throw e; throw e;
} }
final Map<String, Map.Entry<String, BlobStore>> locator = var locator = locators.build();
locators.build(); var globLocator = globLocators.build();
final Map<PathMatcher, Map.Entry<String, BlobStore>>
globLocator = globLocators.build();
if (!locator.isEmpty() || !globLocator.isEmpty()) { if (!locator.isEmpty() || !globLocator.isEmpty()) {
s3Proxy.setBlobStoreLocator( s3Proxy.setBlobStoreLocator(
new GlobBlobStoreLocator(locator, globLocator)); new GlobBlobStoreLocator(locator, globLocator));

Wyświetl plik

@ -100,7 +100,7 @@ final class NullBlobStore extends ForwardingBlobStore {
@Override @Override
public PageSet<? extends StorageMetadata> list(String container) { public PageSet<? extends StorageMetadata> list(String container) {
ImmutableSet.Builder<StorageMetadata> builder = ImmutableSet.builder(); var builder = ImmutableSet.<StorageMetadata>builder();
PageSet<? extends StorageMetadata> pageSet = super.list(container); PageSet<? extends StorageMetadata> pageSet = super.list(container);
for (StorageMetadata sm : pageSet) { for (StorageMetadata sm : pageSet) {
MutableStorageMetadata msm = new MutableStorageMetadataImpl(sm); MutableStorageMetadata msm = new MutableStorageMetadataImpl(sm);
@ -203,7 +203,7 @@ final class NullBlobStore extends ForwardingBlobStore {
@Override @Override
public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) { public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) {
ImmutableList.Builder<MultipartPart> builder = ImmutableList.builder(); var builder = ImmutableList.<MultipartPart>builder();
for (MultipartPart part : super.listMultipartUpload(mpu)) { for (MultipartPart part : super.listMultipartUpload(mpu)) {
// get real blob size from stub blob // get real blob size from stub blob
Blob blob = getBlob(mpu.containerName(), Blob blob = getBlob(mpu.containerName(),

Wyświetl plik

@ -1845,8 +1845,7 @@ public class S3ProxyHandler {
if (replaceMetadata) { if (replaceMetadata) {
ContentMetadataBuilder contentMetadata = ContentMetadataBuilder contentMetadata =
ContentMetadataBuilder.create(); ContentMetadataBuilder.create();
ImmutableMap.Builder<String, String> userMetadata = var userMetadata = ImmutableMap.<String, String>builder();
ImmutableMap.builder();
for (String headerName : Collections.list( for (String headerName : Collections.list(
request.getHeaderNames())) { request.getHeaderNames())) {
String headerValue = Strings.nullToEmpty(request.getHeader( String headerValue = Strings.nullToEmpty(request.getHeader(
@ -2268,8 +2267,7 @@ public class S3ProxyHandler {
// List parts to get part sizes and to map multiple Azure parts // List parts to get part sizes and to map multiple Azure parts
// into single parts. // into single parts.
ImmutableMap.Builder<Integer, MultipartPart> builder = var builder = ImmutableMap.<Integer, MultipartPart>builder();
ImmutableMap.builder();
for (MultipartPart part : blobStore.listMultipartUpload(mpu)) { for (MultipartPart part : blobStore.listMultipartUpload(mpu)) {
builder.put(part.partNumber(), part); builder.put(part.partNumber(), part);
} }
@ -3026,8 +3024,7 @@ public class S3ProxyHandler {
private static void addContentMetdataFromHttpRequest( private static void addContentMetdataFromHttpRequest(
BlobBuilder.PayloadBlobBuilder builder, BlobBuilder.PayloadBlobBuilder builder,
HttpServletRequest request) { HttpServletRequest request) {
ImmutableMap.Builder<String, String> userMetadata = var userMetadata = ImmutableMap.<String, String>builder();
ImmutableMap.builder();
for (String headerName : Collections.list(request.getHeaderNames())) { for (String headerName : Collections.list(request.getHeaderNames())) {
if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) {
userMetadata.put( userMetadata.put(

Wyświetl plik

@ -126,8 +126,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
"Number of shards unset for sharded buckets: %s", "Number of shards unset for sharded buckets: %s",
allMissingShards)); allMissingShards));
} }
ImmutableMap.Builder<String, ShardedBucket> bucketsBuilder = var bucketsBuilder = new ImmutableMap.Builder<String, ShardedBucket>();
new ImmutableMap.Builder<>();
for (String bucket : shards.keySet()) { for (String bucket : shards.keySet()) {
String prefix = prefixes.get(bucket); String prefix = prefixes.get(bucket);
if (prefix == null) { if (prefix == null) {
@ -138,8 +137,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
} }
this.buckets = bucketsBuilder.build(); this.buckets = bucketsBuilder.build();
ImmutableMap.Builder<String, String> prefixMapBuilder = var prefixMapBuilder = new ImmutableMap.Builder<String, String>();
new ImmutableMap.Builder<>();
for (String virtualBucket : buckets.keySet()) { for (String virtualBucket : buckets.keySet()) {
String prefix = buckets.get(virtualBucket).prefix; String prefix = buckets.get(virtualBucket).prefix;
prefixMapBuilder.put(prefix, virtualBucket); prefixMapBuilder.put(prefix, virtualBucket);
@ -149,8 +147,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
public static ImmutableMap<String, Integer> parseBucketShards( public static ImmutableMap<String, Integer> parseBucketShards(
Properties properties) { Properties properties) {
ImmutableMap.Builder<String, Integer> shardsMap = var shardsMap = new ImmutableMap.Builder<String, Integer>();
new ImmutableMap.Builder<>();
for (String key : properties.stringPropertyNames()) { for (String key : properties.stringPropertyNames()) {
Matcher matcher = PROPERTIES_SHARDS_RE.matcher(key); Matcher matcher = PROPERTIES_SHARDS_RE.matcher(key);
if (!matcher.matches()) { if (!matcher.matches()) {
@ -168,8 +165,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
public static ImmutableMap<String, String> parsePrefixes( public static ImmutableMap<String, String> parsePrefixes(
Properties properties) { Properties properties) {
ImmutableMap.Builder<String, String> prefixesMap = var prefixesMap = new ImmutableMap.Builder<String, String>();
new ImmutableMap.Builder<>();
for (String key : properties.stringPropertyNames()) { for (String key : properties.stringPropertyNames()) {
Matcher matcher = PROPERTIES_PREFIX_RE.matcher(key); Matcher matcher = PROPERTIES_PREFIX_RE.matcher(key);
if (!matcher.matches()) { if (!matcher.matches()) {
@ -189,8 +185,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
} }
private Map<String, String> createSuperblockMeta(ShardedBucket bucket) { private Map<String, String> createSuperblockMeta(ShardedBucket bucket) {
ImmutableMap.Builder<String, String> meta = var meta = new ImmutableMap.Builder<String, String>();
new ImmutableMap.Builder<>();
meta.put("s3proxy-sharded-superblock-version", SUPERBLOCK_VERSION); meta.put("s3proxy-sharded-superblock-version", SUPERBLOCK_VERSION);
meta.put("s3proxy-sharded-superblock-prefix", bucket.prefix); meta.put("s3proxy-sharded-superblock-prefix", bucket.prefix);
meta.put("s3proxy-sharded-superblock-shards", meta.put("s3proxy-sharded-superblock-shards",
@ -229,8 +224,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
private boolean createShards(ShardedBucket bucket, Location location, private boolean createShards(ShardedBucket bucket, Location location,
CreateContainerOptions options) { CreateContainerOptions options) {
ImmutableList.Builder<Future<Boolean>> futuresBuilder = var futuresBuilder = new ImmutableList.Builder<Future<Boolean>>();
new ImmutableList.Builder<>();
ExecutorService executor = Executors.newFixedThreadPool( ExecutorService executor = Executors.newFixedThreadPool(
Math.min(bucket.shards, MAX_SHARD_THREADS)); Math.min(bucket.shards, MAX_SHARD_THREADS));
BlobStore blobStore = this.delegate(); BlobStore blobStore = this.delegate();
@ -241,7 +235,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
() -> blobStore.createContainerInLocation( () -> blobStore.createContainerInLocation(
location, shardContainer, options))); location, shardContainer, options)));
} }
ImmutableList<Future<Boolean>> futures = futuresBuilder.build(); var futures = futuresBuilder.build();
executor.shutdown(); executor.shutdown();
boolean ret = true; boolean ret = true;
for (Future<Boolean> future : futures) { for (Future<Boolean> future : futures) {
@ -304,8 +298,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
@Override @Override
public PageSet<? extends StorageMetadata> list() { public PageSet<? extends StorageMetadata> list() {
PageSet<? extends StorageMetadata> upstream = this.delegate().list(); PageSet<? extends StorageMetadata> upstream = this.delegate().list();
ImmutableList.Builder<StorageMetadata> results = var results = new ImmutableList.Builder<StorageMetadata>();
new ImmutableList.Builder<>();
Set<String> virtualBuckets = new HashSet<>(); Set<String> virtualBuckets = new HashSet<>();
for (StorageMetadata sm : upstream) { for (StorageMetadata sm : upstream) {
Matcher matcher = SHARD_RE.matcher(sm.getName()); Matcher matcher = SHARD_RE.matcher(sm.getName());
@ -403,8 +396,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
} }
private boolean deleteShards(ShardedBucket bucket) { private boolean deleteShards(ShardedBucket bucket) {
ImmutableList.Builder<Future<Boolean>> futuresBuilder = var futuresBuilder = new ImmutableList.Builder<Future<Boolean>>();
new ImmutableList.Builder<>();
ExecutorService executor = Executors.newFixedThreadPool( ExecutorService executor = Executors.newFixedThreadPool(
Math.min(bucket.shards, MAX_SHARD_THREADS)); Math.min(bucket.shards, MAX_SHARD_THREADS));
for (int n = 0; n < bucket.shards; ++n) { for (int n = 0; n < bucket.shards; ++n) {
@ -413,7 +405,7 @@ final class ShardedBlobStore extends ForwardingBlobStore {
() -> this.delegate().deleteContainerIfEmpty(shard))); () -> this.delegate().deleteContainerIfEmpty(shard)));
} }
executor.shutdown(); executor.shutdown();
ImmutableList<Future<Boolean>> futures = futuresBuilder.build(); var futures = futuresBuilder.build();
boolean ret = true; boolean ret = true;
for (Future<Boolean> future : futures) { for (Future<Boolean> future : futures) {
try { try {

Wyświetl plik

@ -66,8 +66,7 @@ public final class AliasBlobStoreTest {
.modules(ImmutableList.<Module>of(new SLF4JLoggingModule())) .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
.build(BlobStoreContext.class); .build(BlobStoreContext.class);
blobStore = context.getBlobStore(); blobStore = context.getBlobStore();
ImmutableBiMap.Builder<String, String> aliasesBuilder = var aliasesBuilder = new ImmutableBiMap.Builder<String, String>();
new ImmutableBiMap.Builder<>();
aliasesBuilder.put(aliasContainerName, containerName); aliasesBuilder.put(aliasContainerName, containerName);
aliasBlobStore = AliasBlobStore.newAliasBlobStore( aliasBlobStore = AliasBlobStore.newAliasBlobStore(
blobStore, aliasesBuilder.build()); blobStore, aliasesBuilder.build());
@ -152,8 +151,7 @@ public final class AliasBlobStoreTest {
MultipartPart part = aliasBlobStore.uploadMultipartPart( MultipartPart part = aliasBlobStore.uploadMultipartPart(
mpu, 1, Payloads.newPayload(content)); mpu, 1, Payloads.newPayload(content));
assertThat(part.partETag()).isEqualTo(contentHash.toString()); assertThat(part.partETag()).isEqualTo(contentHash.toString());
ImmutableList.Builder<MultipartPart> parts = var parts = new ImmutableList.Builder<MultipartPart>();
new ImmutableList.Builder<>();
parts.add(part); parts.add(part);
String mpuETag = aliasBlobStore.completeMultipartUpload(mpu, String mpuETag = aliasBlobStore.completeMultipartUpload(mpu,
parts.build()); parts.build());

Wyświetl plik

@ -755,7 +755,7 @@ public final class AwsSdkTest {
@Test @Test
public void testListBuckets() throws Exception { public void testListBuckets() throws Exception {
ImmutableList.Builder<String> builder = ImmutableList.builder(); var builder = ImmutableList.<String>builder();
for (Bucket bucket : client.listBuckets()) { for (Bucket bucket : client.listBuckets()) {
builder.add(bucket.getName()); builder.add(bucket.getName());
} }
@ -841,7 +841,7 @@ public final class AwsSdkTest {
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size()); metadata.setContentLength(BYTE_SOURCE.size());
ImmutableList.Builder<String> builder = ImmutableList.builder(); var builder = ImmutableList.<String>builder();
client.putObject(containerName, "blob1", BYTE_SOURCE.openStream(), client.putObject(containerName, "blob1", BYTE_SOURCE.openStream(),
metadata); metadata);
listing = client.listObjects(containerName); listing = client.listObjects(containerName);
@ -872,7 +872,7 @@ public final class AwsSdkTest {
client.putObject(containerName, "prefix/blob2", client.putObject(containerName, "prefix/blob2",
BYTE_SOURCE.openStream(), metadata); BYTE_SOURCE.openStream(), metadata);
ImmutableList.Builder<String> builder = ImmutableList.builder(); var builder = ImmutableList.<String>builder();
listing = client.listObjects(new ListObjectsRequest() listing = client.listObjects(new ListObjectsRequest()
.withBucketName(containerName) .withBucketName(containerName)
.withDelimiter("/")); .withDelimiter("/"));
@ -1030,7 +1030,7 @@ public final class AwsSdkTest {
String contentEncoding = "gzip"; String contentEncoding = "gzip";
String contentLanguage = "fr"; String contentLanguage = "fr";
String contentType = "audio/mp4"; String contentType = "audio/mp4";
Map<String, String> userMetadata = ImmutableMap.of( var userMetadata = ImmutableMap.of(
"key1", "value1", "key1", "value1",
"key2", "value2"); "key2", "value2");
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
@ -1092,7 +1092,7 @@ public final class AwsSdkTest {
String contentEncoding = "gzip"; String contentEncoding = "gzip";
String contentLanguage = "fr"; String contentLanguage = "fr";
String contentType = "audio/mp4"; String contentType = "audio/mp4";
Map<String, String> userMetadata = ImmutableMap.of( var userMetadata = ImmutableMap.of(
"key1", "value1", "key1", "value1",
"key2", "value2"); "key2", "value2");
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
@ -1185,7 +1185,7 @@ public final class AwsSdkTest {
InitiateMultipartUploadResult result = client.initiateMultipartUpload( InitiateMultipartUploadResult result = client.initiateMultipartUpload(
new InitiateMultipartUploadRequest(containerName, blobName)); new InitiateMultipartUploadRequest(containerName, blobName));
ImmutableList.Builder<PartETag> parts = ImmutableList.builder(); var parts = ImmutableList.<PartETag>builder();
for (int i = 0; i < numParts; ++i) { for (int i = 0; i < numParts; ++i) {
ByteSource partByteSource = byteSource.slice( ByteSource partByteSource = byteSource.slice(
@ -1286,7 +1286,7 @@ public final class AwsSdkTest {
String contentEncoding = "gzip"; String contentEncoding = "gzip";
String contentLanguage = "en"; String contentLanguage = "en";
String contentType = "audio/ogg"; String contentType = "audio/ogg";
Map<String, String> userMetadata = ImmutableMap.of( var userMetadata = ImmutableMap.of(
"key1", "value1", "key1", "value1",
"key2", "value2"); "key2", "value2");
ObjectMetadata metadata = new ObjectMetadata(); ObjectMetadata metadata = new ObjectMetadata();
@ -1390,7 +1390,7 @@ public final class AwsSdkTest {
} }
contentMetadata.setContentType(contentType); contentMetadata.setContentType(contentType);
// TODO: expires // TODO: expires
Map<String, String> userMetadata = ImmutableMap.of( var userMetadata = ImmutableMap.of(
"key3", "value3", "key3", "value3",
"key4", "value4"); "key4", "value4");
contentMetadata.setUserMetadata(userMetadata); contentMetadata.setUserMetadata(userMetadata);

Wyświetl plik

@ -56,10 +56,9 @@ public final class GlobBlobStoreLocatorTest {
@Test @Test
public void testLocateIdentity() { public void testLocateIdentity() {
ImmutableMap<String, Map.Entry<String, BlobStore>> credsMap = var credsMap = ImmutableSortedMap.of(
ImmutableSortedMap.of( "id1", Maps.immutableEntry("one", blobStoreOne),
"id1", Maps.immutableEntry("one", blobStoreOne), "id2", Maps.immutableEntry("two", blobStoreTwo));
"id2", Maps.immutableEntry("two", blobStoreTwo));
GlobBlobStoreLocator locator = new GlobBlobStoreLocator( GlobBlobStoreLocator locator = new GlobBlobStoreLocator(
credsMap, ImmutableMap.of()); credsMap, ImmutableMap.of());
assertThat(locator.locateBlobStore("id2", null, null).getKey()) assertThat(locator.locateBlobStore("id2", null, null).getKey())
@ -71,19 +70,14 @@ public final class GlobBlobStoreLocatorTest {
@Test @Test
public void testLocateContainer() { public void testLocateContainer() {
ImmutableMap<String, Map.Entry<String, BlobStore>> credsMap = var credsMap = ImmutableMap.of(
ImmutableMap.of( "id1", Maps.immutableEntry("one", blobStoreOne),
"id1", Maps.immutableEntry("one", blobStoreOne), "id2", Maps.immutableEntry("two", blobStoreTwo));
"id2", Maps.immutableEntry("two", blobStoreTwo)); var globMap = ImmutableMap.of(
ImmutableMap<PathMatcher, Map.Entry<String, BlobStore>> globMap = FileSystems.getDefault().getPathMatcher("glob:container1"),
ImmutableMap.of( Maps.immutableEntry("id1", blobStoreOne),
FileSystems.getDefault().getPathMatcher( FileSystems.getDefault().getPathMatcher("glob:container2"),
"glob:container1"), Maps.immutableEntry("id2", blobStoreTwo));
Maps.immutableEntry("id1", blobStoreOne),
FileSystems.getDefault().getPathMatcher(
"glob:container2"),
Maps.immutableEntry("id2", blobStoreTwo)
);
GlobBlobStoreLocator locator = new GlobBlobStoreLocator(credsMap, GlobBlobStoreLocator locator = new GlobBlobStoreLocator(credsMap,
globMap); globMap);
@ -103,20 +97,18 @@ public final class GlobBlobStoreLocatorTest {
@Test @Test
public void testLocateGlob() { public void testLocateGlob() {
ImmutableMap<String, Map.Entry<String, BlobStore>> credsMap = var credsMap =
ImmutableSortedMap.of( ImmutableSortedMap.<String, Map.Entry<String, BlobStore>>of(
"id0", Maps.immutableEntry("zero", null), "id0", Maps.immutableEntry("zero", null),
"id1", Maps.immutableEntry("one", blobStoreOne), "id1", Maps.immutableEntry("one", blobStoreOne),
"id2", Maps.immutableEntry("two", blobStoreTwo)); "id2", Maps.immutableEntry("two", blobStoreTwo));
ImmutableMap<PathMatcher, Map.Entry<String, BlobStore>> globMap = var globMap =
ImmutableMap.of( ImmutableMap.<PathMatcher, Map.Entry<String, BlobStore>>of(
FileSystems.getDefault().getPathMatcher( FileSystems.getDefault().getPathMatcher(
"glob:{one,two}"), "glob:{one,two}"),
Maps.immutableEntry("id1", blobStoreOne), Maps.immutableEntry("id1", blobStoreOne),
FileSystems.getDefault().getPathMatcher( FileSystems.getDefault().getPathMatcher("glob:cont?X*"),
"glob:cont?X*"), Maps.immutableEntry("id2", blobStoreTwo));
Maps.immutableEntry("id2", blobStoreTwo)
);
GlobBlobStoreLocator locator = new GlobBlobStoreLocator(credsMap, GlobBlobStoreLocator locator = new GlobBlobStoreLocator(credsMap,
globMap); globMap);
@ -130,15 +122,12 @@ public final class GlobBlobStoreLocatorTest {
@Test @Test
public void testGlobLocatorAnonymous() { public void testGlobLocatorAnonymous() {
ImmutableMap<PathMatcher, Map.Entry<String, BlobStore>> globMap = var globMap =
ImmutableMap.of( ImmutableMap.<PathMatcher, Map.Entry<String, BlobStore>>of(
FileSystems.getDefault().getPathMatcher( FileSystems.getDefault().getPathMatcher("glob:one"),
"glob:one"),
Maps.immutableEntry(null, blobStoreOne), Maps.immutableEntry(null, blobStoreOne),
FileSystems.getDefault().getPathMatcher( FileSystems.getDefault().getPathMatcher("glob:two"),
"glob:two"), Maps.immutableEntry(null, blobStoreTwo));
Maps.immutableEntry(null, blobStoreTwo)
);
GlobBlobStoreLocator locator = new GlobBlobStoreLocator( GlobBlobStoreLocator locator = new GlobBlobStoreLocator(
ImmutableMap.of(), globMap); ImmutableMap.of(), globMap);

Wyświetl plik

@ -71,12 +71,11 @@ public final class RegexBlobStoreTest {
@Test @Test
public void testRemoveSomeCharsFromName() throws IOException { public void testRemoveSomeCharsFromName() throws IOException {
ImmutableList.Builder<Map.Entry<Pattern, String>> regexBuilder = var regexes = ImmutableList.<Map.Entry<Pattern, String>>of(
new ImmutableList.Builder<>(); new SimpleEntry<Pattern, String>(
regexBuilder.add(new SimpleEntry<Pattern, String>(Pattern.compile( Pattern.compile("[^a-zA-Z0-9/_.]"), "_"));
"[^a-zA-Z0-9/_.]"), "_"));
BlobStore regexBlobStore = RegexBlobStore.newRegexBlobStore(delegate, BlobStore regexBlobStore = RegexBlobStore.newRegexBlobStore(delegate,
regexBuilder.build()); regexes);
String initialBlobName = "test/remove:badchars-folder/blob.txt"; String initialBlobName = "test/remove:badchars-folder/blob.txt";
String targetBlobName = "test/remove_badchars_folder/blob.txt"; String targetBlobName = "test/remove_badchars_folder/blob.txt";

Wyświetl plik

@ -60,11 +60,8 @@ public final class ShardedBlobStoreTest {
.modules(ImmutableList.<Module>of(new SLF4JLoggingModule())) .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
.build(BlobStoreContext.class); .build(BlobStoreContext.class);
blobStore = context.getBlobStore(); blobStore = context.getBlobStore();
ImmutableMap<String, Integer> shardsMap = var shardsMap = ImmutableMap.of(containerName, shards);
new ImmutableMap.Builder<String, Integer>() prefixesMap = ImmutableMap.of(containerName, prefix);
.put(containerName, shards).build();
prefixesMap = new ImmutableMap.Builder<String, String>()
.put(containerName, prefix).build();
shardedBlobStore = ShardedBlobStore.newShardedBlobStore( shardedBlobStore = ShardedBlobStore.newShardedBlobStore(
blobStore, shardsMap, prefixesMap); blobStore, shardsMap, prefixesMap);
createdContainers = new ArrayList<>(); createdContainers = new ArrayList<>();