Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana committed Jun 9, 2020
1 parent 6288dcb commit d4ccd41
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
6 changes: 2 additions & 4 deletions api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -2445,10 +2446,7 @@ public void copyObject(CopyObjectArgs args)
Multimap<String, String> headers = args.genHeaders();

// Source object name is optional, if empty default to object name.
String srcObject = args.object();
if (args.srcObject() != null) {
srcObject = args.srcObject();
}
String srcObject = Optional.ofNullable(args.srcObject()).orElse(args.object());

String copySource = S3Escaper.encodePath("/" + args.srcBucket() + "/" + srcObject);
if (args.srcVersionId() != null) {
Expand Down
10 changes: 1 addition & 9 deletions api/src/main/java/io/minio/ObjectWriteArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,25 @@ protected void validateSse(HttpUrl url) {
checkSse(sse, url);
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public abstract static class Builder<B extends Builder<B, A>, A extends ObjectWriteArgs>
extends ObjectArgs.Builder<B, A> {
@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B headers(Map<String, String> headers) {
final Multimap<String, String> headersCopy = toMultimap(headers);
operations.add(args -> args.headers = headersCopy);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B headers(Multimap<String, String> headers) {
final Multimap<String, String> headersCopy = copyMultimap(headers);
operations.add(args -> args.headers = headersCopy);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B userMetadata(Map<String, String> userMetadata) {
return userMetadata((userMetadata == null) ? null : Multimaps.forMap(userMetadata));
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B userMetadata(Multimap<String, String> userMetadata) {
Multimap<String, String> userMetadataCopy = HashMultimap.create();
if (userMetadata != null) {
Expand All @@ -134,33 +131,28 @@ public B userMetadata(Multimap<String, String> userMetadata) {
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B sse(ServerSideEncryption sse) {
operations.add(args -> args.sse = sse);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B tags(Map<String, String> map) {
final Tags tags = (map == null) ? new Tags() : Tags.newObjectTags(map);
operations.add(args -> args.tags = tags);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B tags(Tags tags) {
Tags tagsCopy = (tags == null) ? new Tags() : Tags.newObjectTags(tags.get());
operations.add(args -> args.tags = tagsCopy);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B retention(Retention retention) {
operations.add(args -> args.retention = retention);
return (B) this;
}

@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
public B legalHold(boolean flag) {
operations.add(args -> args.legalHold = flag);
return (B) this;
Expand Down
6 changes: 2 additions & 4 deletions functional/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -2315,10 +2316,7 @@ public static void testCopyObject(
System.out.println("Test: " + methodName + " " + testTags);
}

String srcObject = args.object();
if (args.srcObject() != null) {
srcObject = args.srcObject();
}
String srcObject = Optional.ofNullable(args.srcObject()).orElse(args.object());

long startTime = System.currentTimeMillis();
try {
Expand Down

0 comments on commit d4ccd41

Please sign in to comment.