Skip to content

Commit 08be312

Browse files
Eric Dallo and Gabriel Lima Gomesericdallo
authored andcommitted
Improves S3PropertyPlaceholderConfigurer
1 parent 15decab commit 08be312

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/main/java/com/spring/loader/S3PropertyPlaceholderConfigurer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class S3PropertyPlaceholderConfigurer extends PropertyPlaceholderConfigur
1515
private S3ResourceLoader resourceLoader;
1616
private String[] s3Locations = new String[0];
1717
private Resource[] conventionalResources = new Resource[0];
18-
private boolean ignoreS3resourceNotFound = false;
1918

2019
public S3PropertyPlaceholderConfigurer(S3ResourceLoader resourceLoader) {
2120
this.resourceLoader = resourceLoader;
@@ -42,19 +41,12 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
4241
}
4342

4443
private void injectS3Resources() {
45-
4644
int total = conventionalResources.length + s3Locations.length;
4745

4846
if (total > 0) {
4947
List<Resource> allResources = new ArrayList<>();
5048
for (String s3Location : s3Locations) {
51-
try {
52-
allResources.add(resourceLoader.getResource(s3Location));
53-
} catch (S3ResourceException exp) {
54-
if (!ignoreS3resourceNotFound) {
55-
throw exp;
56-
}
57-
}
49+
allResources.add(resourceLoader.getResource(s3Location));
5850
}
5951
for (Resource conventionalResource : conventionalResources) {
6052
allResources.add(conventionalResource);

src/main/java/com/spring/loader/S3ResourceLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import com.amazonaws.services.s3.AmazonS3Client;
1010
import com.amazonaws.services.s3.model.S3Object;
1111

12-
public class S3ResourceLoader implements ResourceLoader {
12+
class S3ResourceLoader implements ResourceLoader {
1313

1414
private static final String S3_PROTOCOL_PREFIX = "s3://";
1515

16-
private AmazonS3 s3;
16+
private final AmazonS3 s3;
1717

1818
public S3ResourceLoader(AWSCredentials credentials) {
1919
this(new AmazonS3Client(credentials));

0 commit comments

Comments
 (0)