Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpotBug P3 Fixes #2973

Merged
merged 7 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<FindBugsFilter>
<!-- These existing KeyVault Attribute APIs return their super class rather than the actual type. -->
<Match>
<Class name="~com\.microsoft\.azure\.keyvault\.requests\.\w+Request"/>
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/>
</Match>

<!-- These keyvault models are already publicly released APIs with name
matching the simple name of superclass -->
<Match>
Expand Down Expand Up @@ -33,6 +39,13 @@
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<!-- Suppress non-null warning in the case that we change the code and it is possible for
KeyVaultCredentials.getAuthenticationCredentials to return null. -->
<Match>
<Class name="com.microsoft.azure.keyvault.authentication.KeyVaultCredentials"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>

<!-- These KeyVaultClientBase methods are made synchronous by blocking and
waiting for a result. They do not return anything, so it can be ignored. -->
<Match>
Expand All @@ -41,6 +54,13 @@
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
</Match>

<!-- These autorest generated APIs for existing Azure SDK components supports Java 7.
Suppressing error for using anonymous inner classes. -->
<Match>
<Class name="~com\.microsoft\.azure\.(.+)Impl"/>
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"/>
</Match>

<!-- KeyVaultCredential values manipulated do not need to be localised. They
are base64 encoded or URL encoded.-->
<Match>
Expand All @@ -58,7 +78,7 @@
<!-- Known issue in autorest where it will generate a variable with a value of null.
https://github.com/Azure/autorest.java/issues/324 -->
<Match>
<Class name="com.microsoft.azure.keyvault.KeyVaultClientImpl"/>
<Class name="~com\.microsoft\.azure\.(.+)Impl"/>
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ public class CachingKeyResolver implements IKeyResolver {
public CachingKeyResolver(int capacity, final IKeyResolver keyResolver) {
this.keyResolver = keyResolver;
cache = CacheBuilder.newBuilder().maximumSize(capacity)
.build(new CacheLoader<String, ListenableFuture<IKey>>() {

@Override
public ListenableFuture<IKey> load(String kid) {
return keyResolver.resolveKeyAsync(kid);
}
});
.build(new CachingKeyResolverCacheLoader(keyResolver));
}

@Override
Expand All @@ -58,4 +52,18 @@ public void run() {
return cache.getUnchecked(kid);
}
}

private static class CachingKeyResolverCacheLoader extends CacheLoader<String, ListenableFuture<IKey>> {

private final IKeyResolver keyResolver;

CachingKeyResolverCacheLoader(IKeyResolver keyResolver) {
this.keyResolver = keyResolver;
}

@Override
public ListenableFuture<IKey> load(String kid) {
return keyResolver.resolveKeyAsync(kid);
}
}
}