Skip to content

Commit ee83cff

Browse files
authored
Merge branch 'master' into actor-testcontainer
2 parents 0c7448e + 0fafc97 commit ee83cff

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
2525
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
2626
<maven-deploy-plugin.version>2.7</maven-deploy-plugin.version>
27+
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
2728
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
2829
<maven.compiler.source>11</maven.compiler.source>
2930
<maven.compiler.target>11</maven.compiler.target>
@@ -156,6 +157,11 @@
156157
</execution>
157158
</executions>
158159
</plugin>
160+
<plugin>
161+
<groupId>org.apache.maven.plugins</groupId>
162+
<artifactId>maven-resources-plugin</artifactId>
163+
<version>${maven-resources-plugin.version}</version>
164+
</plugin>
159165
</plugins>
160166
</pluginManagement>
161167

sdk/pom.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@
2121
<argLine>
2222
--add-opens java.base/java.util=ALL-UNNAMED
2323
</argLine>
24+
2425
</properties>
2526

2627
<dependencies>
2728
<dependency>
2829
<groupId>org.slf4j</groupId>
2930
<artifactId>slf4j-api</artifactId>
3031
</dependency>
31-
<dependency>
32-
<groupId>org.apache.maven.plugins</groupId>
33-
<artifactId>maven-resources-plugin</artifactId>
34-
<version>3.3.1</version>
35-
<type>maven-plugin</type>
36-
</dependency>
3732
<dependency>
3833
<groupId>io.dapr</groupId>
3934
<artifactId>dapr-sdk-autogen</artifactId>
@@ -169,6 +164,10 @@
169164
</resource>
170165
</resources>
171166
<plugins>
167+
<plugin>
168+
<groupId>org.apache.maven.plugins</groupId>
169+
<artifactId>maven-resources-plugin</artifactId>
170+
</plugin>
172171
<plugin>
173172
<groupId>org.apache.maven.plugins</groupId>
174173
<artifactId>maven-source-plugin</artifactId>

sdk/src/main/java/io/dapr/utils/Version.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,43 @@
1616
import java.io.IOException;
1717
import java.io.InputStream;
1818
import java.util.Properties;
19+
import java.util.concurrent.atomic.AtomicReference;
1920

2021
public final class Version {
2122

22-
private static String sdkVersion = null;
23+
private static volatile AtomicReference<String> sdkVersion = new AtomicReference<>();
2324

2425
/**
2526
* Retrieves sdk version from resources.
2627
*
2728
* @return String version of sdk.
2829
*/
2930
public static String getSdkVersion() {
31+
var version = sdkVersion.get();
3032

31-
if (sdkVersion != null) {
32-
return sdkVersion;
33+
if ((version != null) && !version.isBlank()) {
34+
return version;
3335
}
3436

35-
try (InputStream input = Version.class.getResourceAsStream("/sdk_version.properties");) {
37+
try (InputStream input = Version.class.getResourceAsStream("/sdk_version.properties")) {
3638
Properties properties = new Properties();
3739
properties.load(input);
38-
sdkVersion = "dapr-sdk-java/v" + properties.getProperty("sdk_version", "unknown");
40+
var v = properties.getProperty("sdk_version", null);
41+
if (v == null) {
42+
throw new IllegalStateException("Did not find sdk_version property!");
43+
}
44+
45+
if (v.isBlank()) {
46+
throw new IllegalStateException("Property sdk_version cannot be blank.");
47+
}
48+
49+
version = "dapr-sdk-java/v" + v;
50+
sdkVersion.set(version);
3951
} catch (IOException e) {
40-
sdkVersion = "unknown";
52+
throw new IllegalStateException("Could not load sdk_version property!", e);
4153
}
4254

43-
return sdkVersion;
55+
return version;
4456
}
4557

4658
}

0 commit comments

Comments
 (0)