Skip to content

Commit ebd3626

Browse files
authored
JCL-366: Address miscellaneous sonar warnings (#488)
1 parent 1a02048 commit ebd3626

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

caffeine/src/main/java/com/inrupt/client/caffeine/CaffeineCache.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
*/
3434
public class CaffeineCache<T, U> implements ClientCache<T, U> {
3535

36+
private static final String CACHE_NOT_NULL = "cache may not be null!";
37+
private static final String KEY_NOT_NULL = "cache key may not be null!";
38+
private static final String VALUE_NOT_NULL = "cache value may not be null!";
39+
3640
private final Cache<T, U> cache;
3741

3842
/**
@@ -41,25 +45,25 @@ public class CaffeineCache<T, U> implements ClientCache<T, U> {
4145
* @param cache the caffeine cache
4246
*/
4347
public CaffeineCache(final Cache<T, U> cache) {
44-
this.cache = Objects.requireNonNull(cache, "cache may not be null!");
48+
this.cache = Objects.requireNonNull(cache, CACHE_NOT_NULL);
4549
}
4650

4751
@Override
4852
public U get(final T key) {
49-
Objects.requireNonNull(key, "cache key may not be null!");
53+
Objects.requireNonNull(key, KEY_NOT_NULL);
5054
return cache.getIfPresent(key);
5155
}
5256

5357
@Override
5458
public void put(final T key, final U value) {
55-
Objects.requireNonNull(key, "cache key may not be null!");
56-
Objects.requireNonNull(value, "cache value may not be null!");
59+
Objects.requireNonNull(key, KEY_NOT_NULL);
60+
Objects.requireNonNull(value, VALUE_NOT_NULL);
5761
cache.put(key, value);
5862
}
5963

6064
@Override
6165
public void invalidate(final T key) {
62-
Objects.requireNonNull(key, "cache key may not be null!");
66+
Objects.requireNonNull(key, KEY_NOT_NULL);
6367
cache.invalidate(key);
6468
}
6569

guava/src/main/java/com/inrupt/client/guava/GuavaCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*/
3434
public class GuavaCache<T, U> implements ClientCache<T, U> {
3535

36+
private static final String CACHE_NOT_NULL = "cache may not be null!";
3637
private static final String KEY_NOT_NULL = "cache key may not be null!";
3738
private static final String VALUE_NOT_NULL = "cache value may not be null!";
3839

@@ -44,7 +45,7 @@ public class GuavaCache<T, U> implements ClientCache<T, U> {
4445
* @param cache the guava cache
4546
*/
4647
public GuavaCache(final Cache<T, U> cache) {
47-
this.cache = Objects.requireNonNull(cache, KEY_NOT_NULL);
48+
this.cache = Objects.requireNonNull(cache, CACHE_NOT_NULL);
4849
}
4950

5051
@Override

openid/src/main/java/com/inrupt/client/openid/OpenIdSession.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ public void reset() {
239239
@Override
240240
public CompletionStage<Optional<Credential>> authenticate(final Authenticator auth,
241241
final Request request, final Set<String> algorithms) {
242-
final Optional<Credential> credential = getCredential(ID_TOKEN, null);
243-
if (credential.isPresent() && request != null) {
242+
final Optional<Credential> cred = getCredential(ID_TOKEN, null);
243+
if (cred.isPresent() && request != null) {
244244
LOGGER.debug("Setting cache entry for request: {}", request.uri());
245245
requestCache.put(request.uri(), Boolean.TRUE);
246246
}
247-
return CompletableFuture.completedFuture(credential);
247+
return CompletableFuture.completedFuture(cred);
248248
}
249249

250250
/* deprecated */

webid/src/main/java/com/inrupt/client/webid/WebIdProfile.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public WebIdProfile(final URI identifier, final Dataset dataset) {
6868
* @return the {@code rdf:type} values
6969
* @deprecated use the {@link #getTypes} method
7070
*/
71-
@Deprecated
71+
@Deprecated(since = "1.0.0.Beta3", forRemoval = true)
7272
public Set<URI> getType() {
7373
return getTypes();
7474
}
@@ -88,7 +88,7 @@ public Set<URI> getTypes() {
8888
* @return the {@code solid:oidcIssuer} values
8989
* @deprecated use the {@link #getOidcIssuers} method
9090
*/
91-
@Deprecated
91+
@Deprecated(since = "1.0.0.Beta3", forRemoval = true)
9292
public Set<URI> getOidcIssuer() {
9393
return getOidcIssuers();
9494
}
@@ -108,7 +108,7 @@ public Set<URI> getOidcIssuers() {
108108
* @return the {@code rdfs:seeAlso} values
109109
* @deprecated use the {@link #getRelatedResources} method
110110
*/
111-
@Deprecated
111+
@Deprecated(since = "1.0.0.Beta3", forRemoval = true)
112112
public Set<URI> getSeeAlso() {
113113
return getRelatedResources();
114114
}
@@ -128,7 +128,7 @@ public Set<URI> getRelatedResources() {
128128
* @return the {@code pim:storage} values
129129
* @deprecated use the {@link #getStorages} method
130130
*/
131-
@Deprecated
131+
@Deprecated(since = "1.0.0.Beta3", forRemoval = true)
132132
public Set<URI> getStorage() {
133133
return getStorages();
134134
}

0 commit comments

Comments
 (0)