Skip to content

Commit e9fbd85

Browse files
committed
address review comments
Signed-off-by: Bala.FA <bala@minio.io>
1 parent 3273c9f commit e9fbd85

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

api/src/main/java/io/minio/BaseS3Client.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -799,16 +799,14 @@ public CompletableFuture<GenericResponse> createBucket(CreateBucketArgs args) {
799799
region = Http.US_EAST_1;
800800
}
801801

802-
Http.Headers headers =
803-
args.objectLock() ? new Http.Headers("x-amz-bucket-object-lock-enabled", "true") : null;
804-
final String locationConstraint = region;
802+
Http.Headers headers = new Http.Headers();
803+
if (args.objectLock()) headers.put("x-amz-bucket-object-lock-enabled", "true");
804+
if (args.forceCreate()) headers.put("x-minio-force-create", "true");
805805

806-
CreateBucketConfiguration config = null;
807-
if (locationConstraint.equals(Http.US_EAST_1)) {
808-
config =
809-
new CreateBucketConfiguration(
810-
locationConstraint, args.locationConfig(), args.bucketConfig(), args.tags());
811-
}
806+
final String locationConstraint = region;
807+
CreateBucketConfiguration config =
808+
new CreateBucketConfiguration(
809+
locationConstraint, args.locationConfig(), args.bucketConfig(), args.tags());
812810

813811
Http.Body body = null;
814812
try {

api/src/main/java/io/minio/CreateBucketBaseArgs.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public abstract class CreateBucketBaseArgs extends BucketArgs {
2626
protected CreateBucketConfiguration.Location locationConfig;
2727
protected CreateBucketConfiguration.Bucket bucket;
2828
protected Tags tags;
29+
protected boolean forceCreate;
2930

3031
protected CreateBucketBaseArgs() {}
3132

@@ -35,6 +36,7 @@ protected CreateBucketBaseArgs(CreateBucketBaseArgs args) {
3536
this.locationConfig = args.locationConfig;
3637
this.bucket = args.bucket;
3738
this.tags = args.tags;
39+
this.forceCreate = args.forceCreate;
3840
}
3941

4042
public boolean objectLock() {
@@ -53,6 +55,10 @@ public Tags tags() {
5355
return tags;
5456
}
5557

58+
public boolean forceCreate() {
59+
return forceCreate;
60+
}
61+
5662
/** Base argument builder of {@link CreateBucketBaseArgs}. */
5763
@SuppressWarnings("unchecked") // Its safe to type cast to B as B is inherited by this class
5864
public abstract static class Builder<B extends Builder<B, A>, A extends CreateBucketBaseArgs>
@@ -81,6 +87,11 @@ public B tags(Tags tags) {
8187
operations.add(args -> args.tags = tags);
8288
return (B) this;
8389
}
90+
91+
public B forceCreate(boolean forceCreate) {
92+
operations.add(args -> args.forceCreate = forceCreate);
93+
return (B) this;
94+
}
8495
}
8596

8697
@Override
@@ -92,11 +103,12 @@ public boolean equals(Object o) {
92103
return objectLock == that.objectLock
93104
&& Objects.equals(locationConfig, that.locationConfig)
94105
&& Objects.equals(bucket, that.bucket)
95-
&& Objects.equals(tags, that.tags);
106+
&& Objects.equals(tags, that.tags)
107+
&& forceCreate == that.forceCreate;
96108
}
97109

98110
@Override
99111
public int hashCode() {
100-
return Objects.hash(super.hashCode(), objectLock, locationConfig, bucket, tags);
112+
return Objects.hash(super.hashCode(), objectLock, locationConfig, bucket, tags, forceCreate);
101113
}
102114
}

api/src/main/java/io/minio/ObjectConditionalReadArgs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected ObjectConditionalReadArgs(ObjectConditionalReadArgs args) {
6767

6868
protected ObjectConditionalReadArgs(ObjectConditionalReadArgs args, String matchETag) {
6969
this(args);
70-
this.matchETag = args.matchETag;
70+
this.matchETag = matchETag;
7171
}
7272

7373
public Long offset() {

0 commit comments

Comments
 (0)