Skip to content

Commit a5d4eed

Browse files
authored
Immutable ResultRepositoryConfiguration and WorkerConfiguration classe (#650)
* Immutable `ResultRepositoryConfiguration` and `WorkerConfiguration` classes * Replace `@Data` with `@Value` annotation
1 parent 5105645 commit a5d4eed

File tree

3 files changed

+22
-49
lines changed

3 files changed

+22
-49
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/vNEXT) 2023
5+
## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/vNEXT) 2024
66

77
### New Features
88

@@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.
2121
- Replace single thread executor with synchronized keyword. (#633)
2222
- Move contribution status checks from `iexec-commons-poco`. (#636)
2323
- Use `BlockchainAdapterService` from `iexec-blockchain-adapter-api-library`. (#641)
24+
- `ResultRepositoryConfiguration` and `WorkerConfiguration` classes are now immutable with `@Value` lombok annotation. (#650)
2425

2526
### Bug Fixes
2627

src/main/java/com/iexec/core/configuration/ResultRepositoryConfiguration.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,27 +19,18 @@
1919
import com.iexec.resultproxy.api.ResultProxyClient;
2020
import com.iexec.resultproxy.api.ResultProxyClientBuilder;
2121
import feign.Logger;
22-
import lombok.AllArgsConstructor;
23-
import lombok.Getter;
24-
import lombok.NoArgsConstructor;
25-
import org.springframework.beans.factory.annotation.Value;
22+
import lombok.Value;
23+
import org.springframework.boot.context.properties.ConfigurationProperties;
24+
import org.springframework.boot.context.properties.ConstructorBinding;
2625
import org.springframework.context.annotation.Bean;
27-
import org.springframework.stereotype.Component;
2826

29-
@Component
30-
@Getter
31-
@AllArgsConstructor
32-
@NoArgsConstructor
27+
@Value
28+
@ConstructorBinding
29+
@ConfigurationProperties(prefix = "result-repository")
3330
public class ResultRepositoryConfiguration {
34-
35-
@Value("${resultRepository.protocol}")
36-
private String protocol;
37-
38-
@Value("${resultRepository.host}")
39-
private String host;
40-
41-
@Value("${resultRepository.port}")
42-
private String port;
31+
String protocol;
32+
String host;
33+
String port;
4334

4435
public String getResultRepositoryURL() {
4536
return protocol + "://" + host + ":" + port;
Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,36 +16,17 @@
1616

1717
package com.iexec.core.configuration;
1818

19-
import lombok.*;
20-
import org.springframework.beans.factory.annotation.Value;
21-
import org.springframework.stereotype.Component;
19+
import lombok.Value;
20+
import org.springframework.boot.context.properties.ConfigurationProperties;
21+
import org.springframework.boot.context.properties.ConstructorBinding;
2222

23-
import java.util.Arrays;
2423
import java.util.List;
2524

26-
@Setter
27-
@Component
25+
@Value
26+
@ConstructorBinding
27+
@ConfigurationProperties(prefix = "workers")
2828
public class WorkerConfiguration {
29-
30-
@Value("${workers.askForReplicatePeriod}")
31-
private long askForReplicatePeriod;
32-
33-
@Value("${workers.requiredWorkerVersion}")
34-
private String requiredWorkerVersion;
35-
36-
@Value("${workers.whitelist}")
37-
private String[] whitelist;
38-
39-
// getters are overridden since the whitelist should return a list, not an array
40-
public long getAskForReplicatePeriod() {
41-
return askForReplicatePeriod;
42-
}
43-
44-
public String getRequiredWorkerVersion() {
45-
return requiredWorkerVersion;
46-
}
47-
48-
public List<String> getWhitelist() {
49-
return Arrays.asList(whitelist);
50-
}
29+
long askForReplicatePeriod;
30+
String requiredWorkerVersion;
31+
List<String> whitelist;
5132
}

0 commit comments

Comments
 (0)