Skip to content

Commit 0a39149

Browse files
committed
fix test
1 parent 61cdca4 commit 0a39149

File tree

1 file changed

+12
-17
lines changed
  • spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons

1 file changed

+12
-17
lines changed

spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/Commons.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.cloud.kubernetes.integration.tests.commons;
1818

1919
import java.io.File;
20-
import java.io.IOException;
2120
import java.io.InputStream;
2221
import java.nio.charset.StandardCharsets;
2322
import java.nio.file.Files;
@@ -41,7 +40,6 @@
4140
import org.testcontainers.k3s.K3sContainer;
4241

4342
import org.springframework.core.io.ClassPathResource;
44-
import org.springframework.util.ReflectionUtils;
4543
import org.springframework.util.StreamUtils;
4644
import org.springframework.util.StringUtils;
4745

@@ -61,21 +59,6 @@ public final class Commons {
6159

6260
private static String POM_VERSION;
6361

64-
static {
65-
try (InputStream in = new ClassPathResource(KUBERNETES_VERSION_FILE).getInputStream()) {
66-
String version = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
67-
if (StringUtils.hasText(version)) {
68-
version = version.trim();
69-
}
70-
POM_VERSION = version;
71-
}
72-
catch (IOException e) {
73-
ReflectionUtils.rethrowRuntimeException(e);
74-
}
75-
// not reachable since exception rethrown at runtime
76-
POM_VERSION = null;
77-
}
78-
7962
private static final Log LOG = LogFactory.getLog(Commons.class);
8063

8164
private Commons() {
@@ -224,6 +207,18 @@ public static void pullImage(String image, String tag, K3sContainer container) t
224207
}
225208

226209
public static String pomVersion() {
210+
if (POM_VERSION == null) {
211+
try (InputStream in = new ClassPathResource(KUBERNETES_VERSION_FILE).getInputStream()) {
212+
String version = StreamUtils.copyToString(in, StandardCharsets.UTF_8);
213+
if (StringUtils.hasText(version)) {
214+
POM_VERSION = version.trim();
215+
}
216+
}
217+
catch(Exception e) {
218+
throw new RuntimeException(e);
219+
}
220+
}
221+
227222
return POM_VERSION;
228223
}
229224

0 commit comments

Comments
 (0)