Skip to content

Commit 8433c2a

Browse files
committed
EIS-5488: Upgrading Spring boot version to 3.5.0
1 parent faab9ef commit 8433c2a

30 files changed

Lines changed: 152 additions & 111 deletions

File tree

symphony-bdk-bom/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616

1717
dependencies {
1818
// import Spring Boot's BOM
19-
api platform('org.springframework.boot:spring-boot-dependencies:3.3.12')
19+
api platform('org.springframework.boot:spring-boot-dependencies:3.5.3')
2020
// import Jackson's BOM
2121
api platform('com.fasterxml.jackson:jackson-bom:2.18.2')
2222
// import Jersey's BOM
@@ -70,13 +70,14 @@ dependencies {
7070
api 'com.github.jknack:handlebars:4.3.1'
7171
api 'org.reflections:reflections:0.10.2'
7272

73-
api 'org.junit.jupiter:junit-jupiter:5.10.1'
74-
api 'org.junit.jupiter:junit-jupiter-api:5.10.1'
75-
api 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
73+
api "org.junit.jupiter:junit-jupiter:5.10.1"
74+
api "org.junit.jupiter:junit-jupiter-api:5.10.1"
75+
api "org.junit.jupiter:junit-jupiter-engine:5.10.1"
76+
api "org.junit.platform:junit-platform-launcher:1.10.1"
7677
api 'com.tngtech.archunit:archunit-junit5:1.2.1'
7778
api 'org.mock-server:mockserver-netty:5.15.0'
78-
api 'org.mockito:mockito-core:5.8.0'
79-
api 'org.mockito:mockito-junit-jupiter:5.8.0'
79+
api "org.mockito:mockito-core:5.11.0"
80+
api "org.mockito:mockito-junit-jupiter:5.11.0"
8081
api 'org.assertj:assertj-core:3.24.2'
8182

8283
api 'jakarta.ws.rs:jakarta.ws.rs-api:3.1.0'

symphony-bdk-config/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ dependencies {
2424
testImplementation 'org.junit.jupiter:junit-jupiter'
2525
testImplementation 'ch.qos.logback:logback-classic'
2626
testImplementation 'org.assertj:assertj-core'
27+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
2728
}

symphony-bdk-config/src/main/java/com/symphony/bdk/core/config/BdkConfigParser.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ public JsonNode parse(InputStream inputStream) throws BdkConfigException {
4646
}
4747

4848
public JsonNode parseJsonNode(InputStream inputStream) throws BdkConfigException {
49-
String content = new BufferedReader(
50-
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
51-
.lines()
52-
.collect(Collectors.joining("\n"));
49+
String content = "";
50+
try (
51+
InputStreamReader isr = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
52+
BufferedReader reader = new BufferedReader(isr)
53+
) {
54+
content = reader.lines().collect(Collectors.joining("\n"));
55+
} catch (IOException e) {
56+
log.debug("Error while reading file content");
57+
}
5358
try {
5459
return JSON_MAPPER.readTree(content);
5560
} catch (IOException e) {

symphony-bdk-config/src/test/java/com/symphony/bdk/core/config/BdkConfigLoaderTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.junit.jupiter.api.io.TempDir;
1717

1818
import java.io.FileOutputStream;
19+
import java.io.OutputStream;
1920
import java.io.IOException;
2021
import java.io.InputStream;
2122
import java.nio.file.Files;
@@ -178,8 +179,12 @@ void testLoadConfigFromSymphonyDirectory() throws Exception {
178179
final String tmpConfigFileName = UUID.randomUUID().toString() + "-config.yaml";
179180
final Path tmpConfigPath = Paths.get(System.getProperty("user.home"), ".symphony", tmpConfigFileName);
180181
FileUtils.forceMkdirParent(tmpConfigPath.toFile());
181-
final InputStream configInputStream = this.getClass().getResourceAsStream("/config/config.yaml");
182-
IOUtils.copy(configInputStream, new FileOutputStream(tmpConfigPath.toFile()));
182+
try (
183+
InputStream configInputStream = this.getClass().getResourceAsStream("/config/config.yaml");
184+
OutputStream out = new FileOutputStream(tmpConfigPath.toFile())
185+
) {
186+
IOUtils.copy(configInputStream, out);
187+
}
183188

184189
final BdkConfig config = BdkConfigLoader.loadFromSymphonyDir(tmpConfigFileName);
185190
assertThat(config).isNotNull();

symphony-bdk-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ dependencies {
7272
testImplementation 'org.mockito:mockito-core'
7373
testImplementation 'org.mockito:mockito-junit-jupiter'
7474
testImplementation 'org.assertj:assertj-core'
75+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
7576
}
7677

7778
// OpenAPI code generation

symphony-bdk-core/src/main/java/com/symphony/bdk/core/auth/AuthenticatorFactory.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
/**
3737
* Factory class that provides new instances for the main authenticators :
3838
* <ul>
39-
* <li>{@link BotAuthenticator} : to authenticate the main Bot service account</li>
40-
* <li>{@link OboAuthenticator} : to perform on-behalf-of authentication</li>
39+
* <li>{@link BotAuthenticator} : to authenticate the main Bot service
40+
* account</li>
41+
* <li>{@link OboAuthenticator} : to perform on-behalf-of authentication</li>
4142
* </ul>
4243
*/
4344
@Slf4j
@@ -64,8 +65,7 @@ public AuthenticatorFactory(@Nonnull BdkConfig bdkConfig, @Nonnull ApiClientFact
6465
*
6566
* @return a new {@link BotAuthenticator} instance.
6667
*/
67-
public @Nonnull
68-
BotAuthenticator getBotAuthenticator() throws AuthInitializationException {
68+
public @Nonnull BotAuthenticator getBotAuthenticator() throws AuthInitializationException {
6969
if (this.config.getBot().isBothCertificateAndRsaConfigured()) {
7070
throw new AuthInitializationException(
7171
"Both of certificate and rsa authentication are configured. Only one of them should be provided.");
@@ -82,8 +82,7 @@ BotAuthenticator getBotAuthenticator() throws AuthInitializationException {
8282
this.apiClientFactory.getLoginClient(),
8383
this.apiClientFactory.getSessionAuthClient(),
8484
this.apiClientFactory.getKeyAuthClient(),
85-
new AgentVersionService(new SignalsApi(this.apiClientFactory.getAgentClient()))
86-
);
85+
new AgentVersionService(new SignalsApi(this.apiClientFactory.getAgentClient())));
8786
}
8887
if (this.config.getBot().isRsaAuthenticationConfigured()) {
8988
if (!this.config.getBot().isRsaConfigurationValid()) {
@@ -97,8 +96,7 @@ BotAuthenticator getBotAuthenticator() throws AuthInitializationException {
9796
this.loadPrivateKeyFromAuthenticationConfig(this.config.getBot()),
9897
this.apiClientFactory.getLoginClient(),
9998
this.apiClientFactory.getRelayClient(),
100-
new AgentVersionService(new SignalsApi(this.apiClientFactory.getAgentClient()))
101-
);
99+
new AgentVersionService(new SignalsApi(this.apiClientFactory.getAgentClient())));
102100
}
103101
throw new AuthInitializationException("Neither RSA private key nor certificate is configured.");
104102
}
@@ -108,8 +106,7 @@ BotAuthenticator getBotAuthenticator() throws AuthInitializationException {
108106
*
109107
* @return a new {@link OboAuthenticator} instance.
110108
*/
111-
public @Nonnull
112-
OboAuthenticator getOboAuthenticator() throws AuthInitializationException {
109+
public @Nonnull OboAuthenticator getOboAuthenticator() throws AuthInitializationException {
113110
if (this.config.getApp().isBothCertificateAndRsaConfigured()) {
114111
throw new AuthInitializationException(
115112
"Both of certificate and rsa authentication are configured. Only one of them should be provided.");
@@ -122,8 +119,7 @@ OboAuthenticator getOboAuthenticator() throws AuthInitializationException {
122119
return new OboAuthenticatorCertImpl(
123120
this.config.getRetry(),
124121
this.config.getApp().getAppId(),
125-
this.apiClientFactory.getExtAppSessionAuthClient()
126-
);
122+
this.apiClientFactory.getExtAppSessionAuthClient());
127123
}
128124
if (this.config.getApp().isRsaAuthenticationConfigured()) {
129125
if (!this.config.getApp().isRsaConfigurationValid()) {
@@ -134,8 +130,7 @@ OboAuthenticator getOboAuthenticator() throws AuthInitializationException {
134130
this.config.getRetry(),
135131
this.config.getApp().getAppId(),
136132
this.loadPrivateKeyFromAuthenticationConfig(this.config.getApp()),
137-
this.apiClientFactory.getLoginClient()
138-
);
133+
this.apiClientFactory.getLoginClient());
139134
}
140135
throw new AuthInitializationException("Neither RSA private key nor certificate is configured.");
141136
}
@@ -145,8 +140,7 @@ OboAuthenticator getOboAuthenticator() throws AuthInitializationException {
145140
*
146141
* @return a new {@link ExtensionAppAuthenticator} instance.
147142
*/
148-
public @Nonnull
149-
ExtensionAppAuthenticator getExtensionAppAuthenticator() throws AuthInitializationException {
143+
public @Nonnull ExtensionAppAuthenticator getExtensionAppAuthenticator() throws AuthInitializationException {
150144
if (this.config.getApp().isBothCertificateAndRsaConfigured()) {
151145
throw new AuthInitializationException(
152146
"Both of certificate and rsa authentication are configured. Only one of them should be provided.");
@@ -173,8 +167,7 @@ ExtensionAppAuthenticator getExtensionAppAuthenticator() throws AuthInitializati
173167
this.loadPrivateKeyFromAuthenticationConfig(this.config.getApp()),
174168
this.apiClientFactory.getLoginClient(),
175169
this.apiClientFactory.getPodClient(),
176-
extensionAppTokensRepository
177-
);
170+
extensionAppTokensRepository);
178171
}
179172
throw new AuthInitializationException("Neither RSA private key nor certificate is configured.");
180173
}
@@ -225,10 +218,13 @@ private static String loadPrivateKey(String privateKeyPath) throws IOException,
225218
throw new AuthInitializationException(
226219
"Unable to find RSA private key as classpath resource from: " + privateKeyPath);
227220
}
221+
try (InputStream resourceStream = is) {
222+
return IOUtils.toString(resourceStream, StandardCharsets.UTF_8);
223+
}
228224
} else {
229-
is = new FileInputStream(privateKeyPath);
225+
try (InputStream fileStream = new FileInputStream(privateKeyPath)) {
226+
return IOUtils.toString(fileStream, StandardCharsets.UTF_8);
227+
}
230228
}
231-
232-
return IOUtils.toString(is, StandardCharsets.UTF_8);
233229
}
234230
}

symphony-bdk-core/src/test/java/com/symphony/bdk/core/auth/AuthenticatorFactoryTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.junit.jupiter.api.io.TempDir;
2929

3030
import java.io.FileOutputStream;
31+
import java.io.OutputStream;
32+
import java.nio.charset.StandardCharsets;
3133
import java.nio.file.Path;
3234
import java.util.UUID;
3335
import java.util.function.Supplier;
@@ -387,6 +389,8 @@ private BdkConfig createRsaConfigDeprecatedPath(Supplier<String> privateKeyPathS
387389

388390
@SneakyThrows
389391
private static void writeContentToPath(String content, Path path) {
390-
IOUtils.write(content, new FileOutputStream(path.toFile()), "utf-8");
392+
try (OutputStream out = new FileOutputStream(path.toFile())) {
393+
IOUtils.write(content, out, StandardCharsets.UTF_8);
394+
}
391395
}
392396
}

0 commit comments

Comments
 (0)