Skip to content

Commit 71a910d

Browse files
committed
Deprecate legacy properties, README fixes.
1 parent d21a801 commit 71a910d

File tree

15 files changed

+434
-150
lines changed

15 files changed

+434
-150
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Running S3Mock in unit tests is still supported by using [TestContainers](https:
123123
* Features and fixes
124124
* TBD
125125
* Refactorings
126+
* Removal of legacy-style Spring properties in favor of current environment variables.
126127
* AWS has deprecated SDK for Java v1, and will remove support EOY 2025.
127128
* S3Mock will remove bundled support for Java SDK v1 in late 2025.
128129
* JUnit 4.x deprecation
@@ -164,11 +165,15 @@ Version 4.x is JDK17 LTS bytecode compatible, with Docker and JUnit / direct Jav
164165
* Refactorings
165166
* Add JSpecify annotations to S3Mock code
166167
* Migrate unit tests in "testsupport" modules to Kotlin
168+
* Deprecation of legacy-style Spring properties in favor of current environment variables.
169+
* Various fixes and clarifications in README.md
167170
* Version updates (deliverable dependencies)
168171
* Bump alpine from 3.21.3 to 3.22.0 in /docker
169172
* Bump aws.version from 1.12.783 to 1.12.785
170-
* Bump testcontainers.version from 1.21.0 to 1.21.1
173+
* Bump spring-boot.version from 3.5.0 to 3.5.3
174+
* Bump testcontainers.version from 1.21.0 to 1.21.2
171175
* Version updates (build dependencies)
176+
* Bump org.xmlunit:xmlunit-assertj3 from 2.10.2 to 2.10.3
172177
* Bump org.codehaus.mojo:exec-maven-plugin from 3.5.0 to 3.5.1
173178
* Bump org.apache.maven.plugins:maven-clean-plugin from 3.4.1 to 3.5.0
174179
* Bump com.puppycrawl.tools:checkstyle from 10.24.0 to 10.25.0

README.md

Lines changed: 273 additions & 100 deletions
Large diffs are not rendered by default.

server/src/main/java/com/adobe/testing/s3mock/BucketController.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@
7676
@RequestMapping("${com.adobe.testing.s3mock.contextPath:}")
7777
public class BucketController {
7878
private final BucketService bucketService;
79-
private final Region region;
8079

81-
public BucketController(BucketService bucketService, Region region) {
80+
public BucketController(BucketService bucketService) {
8281
this.bucketService = bucketService;
83-
this.region = region;
8482
}
8583

8684
//================================================================================================
@@ -376,8 +374,9 @@ public ResponseEntity<LocationConstraint> getBucketLocation(@PathVariable String
376374

377375
/**
378376
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html">API Reference</a>.
379-
* @deprecated Long since replaced by listObjectsV2
377+
*
380378
* @see #listObjectsV2
379+
* @deprecated Long since replaced by listObjectsV2
381380
*/
382381
@GetMapping(
383382
value = {
@@ -486,12 +485,12 @@ public ResponseEntity<ListVersionsResult> listObjectVersions(
486485
return ResponseEntity.ok(listVersionsResult);
487486
}
488487

488+
@Nullable
489489
private String regionFrom(@Nullable CreateBucketConfiguration createBucketRequest) {
490-
if (createBucketRequest != null
491-
&& createBucketRequest.locationConstraint() != null
492-
&& createBucketRequest.locationConstraint().region() != null) {
493-
return createBucketRequest.locationConstraint().region().toString();
490+
if (createBucketRequest != null) {
491+
return createBucketRequest.regionFrom();
492+
} else {
493+
return null;
494494
}
495-
return this.region.toString();
496495
}
497496
}

server/src/main/java/com/adobe/testing/s3mock/S3MockConfiguration.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
2121

2222
import com.adobe.testing.s3mock.dto.ErrorResponse;
23-
import com.adobe.testing.s3mock.dto.Region;
2423
import com.adobe.testing.s3mock.service.BucketService;
2524
import com.adobe.testing.s3mock.service.MultipartService;
2625
import com.adobe.testing.s3mock.service.ObjectService;
@@ -159,8 +158,8 @@ ObjectController fileStoreController(ObjectService objectService, BucketService
159158
}
160159

161160
@Bean
162-
BucketController bucketController(BucketService bucketService, S3MockProperties properties) {
163-
return new BucketController(bucketService, properties.region());
161+
BucketController bucketController(BucketService bucketService) {
162+
return new BucketController(bucketService);
164163
}
165164

166165
@Bean

server/src/main/java/com/adobe/testing/s3mock/S3MockProperties.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ public record S3MockProperties(
3232
// For example if set to `s3-mock` all endpoints will be available at
3333
// `http://host:port/s3-mock` instead of `http://host:port/`
3434
@DefaultValue("")
35-
String contextPath,
36-
37-
// Region is S3Mock is supposed to mock.
38-
// Must be an official AWS region string like "us-east-1"
39-
Region region
35+
String contextPath
4036
) {
4137

4238
}

server/src/main/java/com/adobe/testing/s3mock/dto/CreateBucketConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ public CreateBucketConfiguration(BucketInfo bucket,
4848
LocationConstraint locationConstraint) {
4949
this(bucket, location, locationConstraint, null);
5050
}
51+
52+
public String regionFrom() {
53+
if (this.locationConstraint() != null
54+
&& this.locationConstraint().region() != null) {
55+
return this.locationConstraint().region().toString();
56+
}
57+
return null;
58+
}
5159
}

server/src/main/java/com/adobe/testing/s3mock/service/BucketService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public Bucket createBucket(
147147
String bucketName,
148148
boolean objectLockEnabled,
149149
ObjectOwnership objectOwnership,
150-
String bucketRegion,
150+
@Nullable String bucketRegion,
151151
@Nullable BucketInfo bucketInfo,
152152
@Nullable LocationInfo locationInfo) {
153153
return Bucket.from(

server/src/main/java/com/adobe/testing/s3mock/store/BucketMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public BucketMetadata withObjectLockConfiguration(
104104
}
105105

106106
public BucketMetadata withBucketLifecycleConfiguration(
107-
BucketLifecycleConfiguration bucketLifecycleConfiguration) {
107+
@Nullable BucketLifecycleConfiguration bucketLifecycleConfiguration
108+
) {
108109
return new BucketMetadata(name(),
109110
creationDate(),
110111
versioningConfiguration(),

server/src/main/java/com/adobe/testing/s3mock/store/BucketStore.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ public class BucketStore {
5656
private final Map<String, Object> lockStore = new ConcurrentHashMap<>();
5757
private final File rootFolder;
5858
private final DateTimeFormatter s3ObjectDateFormat;
59+
private final String region;
5960
private final ObjectMapper objectMapper;
6061

61-
public BucketStore(File rootFolder,
62+
public BucketStore(
63+
File rootFolder,
6264
DateTimeFormatter s3ObjectDateFormat,
65+
String region,
6366
ObjectMapper objectMapper) {
6467
this.rootFolder = rootFolder;
6568
this.s3ObjectDateFormat = s3ObjectDateFormat;
69+
this.region = region;
6670
this.objectMapper = objectMapper;
6771
}
6872

@@ -136,7 +140,7 @@ public BucketMetadata createBucket(
136140
String bucketName,
137141
boolean objectLockEnabled,
138142
ObjectOwnership objectOwnership,
139-
String bucketRegion,
143+
@Nullable String bucketRegion,
140144
@Nullable BucketInfo bucketInfo,
141145
@Nullable LocationInfo locationInfo) {
142146
if (doesBucketExist(bucketName)) {
@@ -145,6 +149,7 @@ public BucketMetadata createBucket(
145149
lockStore.putIfAbsent(bucketName, new Object());
146150
synchronized (lockStore.get(bucketName)) {
147151
var bucketFolder = createBucketFolder(bucketName);
152+
var region = bucketRegion == null ? this.region : bucketRegion;
148153

149154
var newBucketMetadata = new BucketMetadata(
150155
bucketName,
@@ -155,7 +160,7 @@ public BucketMetadata createBucket(
155160
null,
156161
objectOwnership,
157162
bucketFolder.toPath(),
158-
bucketRegion,
163+
region,
159164
bucketInfo,
160165
locationInfo
161166
);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2017-2025 Adobe.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.adobe.testing.s3mock.store;
18+
19+
import java.util.List;
20+
import java.util.Set;
21+
import org.jspecify.annotations.Nullable;
22+
import org.springframework.boot.context.properties.ConfigurationProperties;
23+
import org.springframework.boot.context.properties.bind.DefaultValue;
24+
25+
@Deprecated(forRemoval = true, since = "4.5.0")
26+
@ConfigurationProperties("com.adobe.testing.s3mock.domain")
27+
public record LegacyStoreProperties(
28+
// True if files should be retained when S3Mock exits gracefully.
29+
// False to let S3Mock delete all files when S3Mock exits gracefully.
30+
boolean retainFilesOnExit,
31+
// The root directory to use. If omitted a default temp-dir will be used.
32+
@Nullable String root,
33+
@DefaultValue
34+
Set<String> validKmsKeys,
35+
// A comma separated list of buckets that are to be created at startup.
36+
@DefaultValue
37+
List<String> initialBuckets
38+
) {
39+
40+
}

0 commit comments

Comments
 (0)