Skip to content

Commit da07f3f

Browse files
authored
Update to 2.1.0 (#173)
*Issue #, if available:* *Description of changes:* - Update dependencies - Fix user agent to match pom.xml - Address new SpotBugs warnings ``` Error: Medium: Shared primitive variable "refreshNeeded" in one thread may not yield the value of the most recent write from another thread [com.amazonaws.secretsmanager.caching.cache.SecretCacheObject] At SecretCacheObject.java:[line 207] AT_STALE_THREAD_WRITE_OF_PRIMITIVE Error: Low: Method intentionally throws RuntimeException. [com.amazonaws.secretsmanager.caching.cache.SecretCacheObject] At SecretCacheObject.java:[line 242] THROWS_METHOD_THROWS_RUNTIMEEXCEPTION ``` - Bump version number By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent db8a853 commit da07f3f

File tree

3 files changed

+27
-50
lines changed

3 files changed

+27
-50
lines changed

pom.xml

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.amazonaws.secretsmanager</groupId>
77
<artifactId>aws-secretsmanager-caching-java</artifactId>
8-
<version>2.0.1</version>
8+
<version>2.1.0</version>
99
<packaging>jar</packaging>
1010

1111

@@ -37,17 +37,14 @@
3737
</scm>
3838

3939
<properties>
40-
<maven.compiler.release>8</maven.compiler.release>
41-
<maven.compiler.source>1.8</maven.compiler.source>
42-
<maven.compiler.target>1.8</maven.compiler.target>
43-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
40+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4441
</properties>
4542

4643
<dependencies>
4744
<dependency>
4845
<groupId>software.amazon.awssdk</groupId>
4946
<artifactId>secretsmanager</artifactId>
50-
<version>2.29.6</version>
47+
<version>2.37.1</version>
5148
</dependency>
5249
<dependency>
5350
<groupId>org.testng</groupId>
@@ -58,13 +55,13 @@
5855
<dependency>
5956
<groupId>org.mockito</groupId>
6057
<artifactId>mockito-core</artifactId>
61-
<version>5.17.0</version>
58+
<version>5.20.0</version>
6259
<scope>test</scope>
6360
</dependency>
6461
<dependency>
6562
<groupId>com.github.spotbugs</groupId>
6663
<artifactId>spotbugs-annotations</artifactId>
67-
<version>4.8.6</version>
64+
<version>4.9.8</version>
6865
<scope>compile</scope>
6966
</dependency>
7067
</dependencies>
@@ -73,10 +70,9 @@
7370
<plugin>
7471
<groupId>org.apache.maven.plugins</groupId>
7572
<artifactId>maven-compiler-plugin</artifactId>
76-
<version>3.13.0</version>
73+
<version>3.14.1</version>
7774
<configuration>
78-
<source>1.8</source>
79-
<target>1.8</target>
75+
<release>8</release>
8076
<compilerArgument>-Xlint:all</compilerArgument>
8177
<showWarnings>true</showWarnings>
8278
<showDeprecation>true</showDeprecation>
@@ -98,7 +94,7 @@
9894
<plugin>
9995
<groupId>org.apache.maven.plugins</groupId>
10096
<artifactId>maven-javadoc-plugin</artifactId>
101-
<version>3.11.1</version>
97+
<version>3.12.0</version>
10298
<executions>
10399
<execution>
104100
<id>attach-javadocs</id>
@@ -132,7 +128,7 @@
132128
<plugin>
133129
<groupId>com.github.spotbugs</groupId>
134130
<artifactId>spotbugs-maven-plugin</artifactId>
135-
<version>4.8.6.5</version>
131+
<version>4.9.8.1</version>
136132
<configuration>
137133
<effort>Max</effort>
138134
<threshold>Low</threshold>
@@ -152,7 +148,7 @@
152148
<plugin>
153149
<groupId>org.jacoco</groupId>
154150
<artifactId>jacoco-maven-plugin</artifactId>
155-
<version>0.8.12</version>
151+
<version>0.8.14</version>
156152
<executions>
157153
<execution>
158154
<id>prepare-agent</id>
@@ -169,26 +165,6 @@
169165
</execution>
170166
</executions>
171167
</plugin>
172-
<plugin>
173-
<groupId>org.apache.maven.plugins</groupId>
174-
<artifactId>maven-dependency-plugin</artifactId>
175-
<version>3.8.1</version>
176-
<executions>
177-
<execution>
178-
<goals>
179-
<goal>properties</goal>
180-
</goals>
181-
</execution>
182-
</executions>
183-
</plugin>
184-
<plugin>
185-
<groupId>org.apache.maven.plugins</groupId>
186-
<artifactId>maven-surefire-plugin</artifactId>
187-
<version>3.5.2</version>
188-
<configuration>
189-
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
190-
</configuration>
191-
</plugin>
192168
</plugins>
193169
</build>
194170

@@ -200,7 +176,7 @@
200176
<plugin>
201177
<groupId>org.apache.maven.plugins</groupId>
202178
<artifactId>maven-gpg-plugin</artifactId>
203-
<version>3.2.7</version>
179+
<version>3.2.8</version>
204180
<executions>
205181
<execution>
206182
<id>sign-artifacts</id>
@@ -214,7 +190,7 @@
214190
<plugin>
215191
<groupId>org.sonatype.central</groupId>
216192
<artifactId>central-publishing-maven-plugin</artifactId>
217-
<version>0.7.0</version>
193+
<version>0.9.0</version>
218194
<extensions>true</extensions>
219195
<configuration>
220196
<publishingServerId>central</publishingServerId>

src/main/java/com/amazonaws/secretsmanager/caching/cache/SecretCacheObject.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package com.amazonaws.secretsmanager.caching.cache;
1515

1616
import java.util.concurrent.ThreadLocalRandom;
17+
import java.util.concurrent.atomic.AtomicBoolean;
1718

1819
import com.amazonaws.secretsmanager.caching.SecretCacheConfiguration;
1920
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -50,7 +51,7 @@ public abstract class SecretCacheObject<T> {
5051
protected final SecretCacheConfiguration config;
5152

5253
/** A flag to indicate a refresh is needed. */
53-
private boolean refreshNeeded = true;
54+
private final AtomicBoolean refreshNeeded = new AtomicBoolean(true);
5455

5556
/** The result of the last AWS Secrets Manager request for this item. */
5657
private Object data = null;
@@ -145,7 +146,9 @@ private void setResult(T result) {
145146
* @return True if the secret item should be refreshed.
146147
*/
147148
protected boolean isRefreshNeeded() {
148-
if (this.refreshNeeded) { return true; }
149+
if (this.refreshNeeded.get()) {
150+
return true;
151+
}
149152
if (null != this.exception) {
150153
// If we encountered an exception on the last attempt
151154
// we do not want to keep retrying without a pause between
@@ -168,7 +171,7 @@ protected boolean isRefreshNeeded() {
168171
*/
169172
private void refresh() {
170173
if (!this.isRefreshNeeded()) { return; }
171-
this.refreshNeeded = false;
174+
this.refreshNeeded.set(false);
172175
try {
173176
this.setResult(this.executeRefresh());
174177
this.exception = null;
@@ -204,7 +207,7 @@ private void refresh() {
204207
* If the thread is interrupted while waiting for the refresh.
205208
*/
206209
public boolean refreshNow() throws InterruptedException {
207-
this.refreshNeeded = true;
210+
this.refreshNeeded.set(true);
208211
// When forcing a refresh, always sleep with a random jitter
209212
// to prevent coding errors that could be calling refreshNow
210213
// in a loop.
@@ -235,6 +238,7 @@ public boolean refreshNow() throws InterruptedException {
235238
*
236239
* @return The cached GetSecretValue result.
237240
*/
241+
@SuppressFBWarnings("THROWS_METHOD_THROWS_RUNTIMEEXCEPTION")
238242
public GetSecretValueResponse getSecretValue() {
239243
synchronized (lock) {
240244
refresh();

src/main/java/com/amazonaws/secretsmanager/caching/cache/internal/VersionInfo.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
* client.
1919
*/
2020
public class VersionInfo {
21-
public static final String VERSION_NUM = "2";
22-
// incremented for design changes that break backward compatibility.
23-
public static final String MAJOR_REVISION_NUM = VERSION_NUM;
24-
// incremented for minor changes to the implementation
25-
public static final String MINOR_REVISION_NUM = "0";
26-
// incremented for releases containing an immediate bug fix.
27-
public static final String BUGFIX_REVISION_NUM = "0";
28-
29-
public static final String RELEASE_VERSION = MAJOR_REVISION_NUM + "." + MINOR_REVISION_NUM
30-
+ "." + BUGFIX_REVISION_NUM;
21+
/**
22+
* Library version number
23+
*/
24+
public static final String RELEASE_VERSION = "2.1.0";
3125

26+
/**
27+
* User agent for AWS Secrets Manager API calls.
28+
*/
3229
public static final String USER_AGENT = "AwsSecretCache/" + RELEASE_VERSION;
3330

3431
private VersionInfo() {

0 commit comments

Comments
 (0)