Limit size of target and client cache to 1

This commit is contained in:
nsingh
2017-01-31 16:11:21 -08:00
parent 05fe1b1d82
commit dfd5cac945
3 changed files with 14 additions and 14 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.ide.vscode.commons.util.Assert;
*/
public class CFClientParams {
private static final Logger logger = Logger.getLogger(CFClientParams.class.getName());
private static final Logger logger = Logger.getLogger(CFClientParams.class.getName());
private final String apiUrl;
private final String username;
@@ -32,7 +32,7 @@ public class CFClientParams {
private final boolean skipSslValidation;
private String orgName; // optional
private String spaceName; //optional
private String spaceName; // optional
public CFClientParams(String apiUrl,
String username,
@@ -43,7 +43,7 @@ public class CFClientParams {
) {
Assert.isNotNull(apiUrl);
Assert.isNotNull(credentials);
if (credentials.getType()==CFCredentialType.PASSWORD) {
if (credentials.getType() == CFCredentialType.PASSWORD) {
Assert.isNotNull(username);
}
this.apiUrl = apiUrl;
@@ -53,7 +53,7 @@ public class CFClientParams {
this.orgName = orgName;
this.spaceName = spaceName;
}
public CFClientParams(String apiUrl, String username, CFCredentials credentials, boolean skipSslValidation) {
this(apiUrl, username, credentials, null /* no org */,
null /* no space */, skipSslValidation);
@@ -71,8 +71,6 @@ public class CFClientParams {
return skipSslValidation;
}
public String getApiUrl() {
return apiUrl;
}
@@ -109,8 +107,9 @@ public class CFClientParams {
final int prime = 31;
int result = 1;
result = prime * result + ((apiUrl == null) ? 0 : apiUrl.hashCode());
result = prime * result + ((orgName == null) ? 0 : orgName.hashCode());
result = prime * result + ((credentials == null) ? 0 : credentials.hashCode());
result = prime * result + ((orgName == null) ? 0 : orgName.hashCode());
result = prime * result + (skipSslValidation ? 1231 : 1237);
result = prime * result + ((spaceName == null) ? 0 : spaceName.hashCode());
result = prime * result + ((username == null) ? 0 : username.hashCode());
return result;
@@ -130,15 +129,17 @@ public class CFClientParams {
return false;
} else if (!apiUrl.equals(other.apiUrl))
return false;
if (credentials == null) {
if (other.credentials != null)
return false;
} else if (!credentials.equals(other.credentials))
return false;
if (orgName == null) {
if (other.orgName != null)
return false;
} else if (!orgName.equals(other.orgName))
return false;
if (credentials == null) {
if (other.credentials != null)
return false;
} else if (!credentials.equals(other.credentials))
if (skipSslValidation != other.skipSslValidation)
return false;
if (spaceName == null) {
if (other.spaceName != null)
@@ -160,5 +161,4 @@ public class CFClientParams {
+ "]";
}
}

View File

@@ -50,7 +50,7 @@ public class CFTargetCache {
}
};
cache = CacheBuilder.newBuilder().expireAfterAccess(TARGET_EXPIRATION, TimeUnit.HOURS).build(loader);
cache = CacheBuilder.newBuilder().maximumSize(1).expireAfterAccess(TARGET_EXPIRATION, TimeUnit.HOURS).build(loader);
}
/**

View File

@@ -60,7 +60,7 @@ public class CloudFoundryClientCache {
}
};
cache = CacheBuilder.newBuilder().initialCapacity(1).expireAfterAccess(EXPIRATION, TimeUnit.HOURS)
cache = CacheBuilder.newBuilder().maximumSize(1).expireAfterAccess(EXPIRATION, TimeUnit.HOURS)
.build(loader);
}