Skip to content

Commit

Permalink
fix(google): return null guards to GoogleApplicationProvider (#3921)
Browse files Browse the repository at this point in the history
* fix(google): return null guards to GoogleApplicationProvider

* fix(google): add @nullable annotation to GoogleApplicationProvider
  • Loading branch information
maggieneterval committed Aug 8, 2019
1 parent abb0783 commit 0069e93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import lombok.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -75,6 +76,7 @@ static class ApplicationCacheData {
Set<String> instanceIdentifiers;
}

@Nullable
ApplicationCacheData getApplicationCacheData(String name) {
CacheData cacheData =
cacheView.get(
Expand All @@ -85,6 +87,9 @@ ApplicationCacheData getApplicationCacheData(String name) {
}

private ApplicationCacheData getApplicationCacheData(CacheData cacheData) {
if (cacheData == null) {
return null;
}
return new ApplicationCacheData(
cacheData.getAttributes(),
getRelationships(cacheData, CLUSTERS),
Expand All @@ -102,6 +107,9 @@ private GoogleApplication.View applicationFromCacheData(CacheData cacheData) {

private GoogleApplication.View applicationFromCacheData(
ApplicationCacheData applicationCacheData) {
if (applicationCacheData == null) {
return null;
}
GoogleApplication application =
objectMapper.convertValue(
applicationCacheData.getApplicationAttributes(), GoogleApplication.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class GoogleClusterProvider implements ClusterProvider<GoogleCluster.View> {
Map<String, Set<GoogleCluster.View>> getClusters(String applicationName, boolean includeInstanceDetails) {
GoogleApplicationProvider.ApplicationCacheData applicationCacheData = applicationProvider.getApplicationCacheData(applicationName)

if (applicationCacheData == null) {
return new HashMap<>()
}

Set<String> clusterIdentifiers = applicationCacheData.getClusterIdentifiers();
Collection<CacheData> clusterCacheData = cacheView.getAll(
CLUSTERS.ns,
Expand Down

0 comments on commit 0069e93

Please sign in to comment.