mirror of https://github.com/apache/jclouds.git
Further FindBugs fixes
This commit is contained in:
parent
34cfdbe266
commit
8f8b6dd7ce
|
@ -147,17 +147,15 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions {
|
||||||
// base EC2 driver currently does not support key import
|
// base EC2 driver currently does not support key import
|
||||||
protected String createOrImportKeyPair(String region, String group, TemplateOptions options) {
|
protected String createOrImportKeyPair(String region, String group, TemplateOptions options) {
|
||||||
RegionAndName regionAndGroup = new RegionAndName(region, group);
|
RegionAndName regionAndGroup = new RegionAndName(region, group);
|
||||||
KeyPair keyPair;
|
KeyPair keyPair = makeKeyPair.apply(new RegionAndName(region, group));
|
||||||
// make sure that we don't request multiple keys simultaneously
|
// make sure that we don't request multiple keys simultaneously
|
||||||
synchronized (credentialsMap) {
|
// if there is already a keypair for the group specified, use it
|
||||||
// if there is already a keypair for the group specified, use it
|
// otherwise create a new keypair and key it under the group and also the regular keyname
|
||||||
if (credentialsMap.containsKey(regionAndGroup))
|
KeyPair origValue = credentialsMap.putIfAbsent(regionAndGroup, keyPair);
|
||||||
return credentialsMap.get(regionAndGroup).getKeyName();
|
if (origValue != null) {
|
||||||
|
return origValue.getKeyName();
|
||||||
// otherwise create a new keypair and key it under the group and also the regular keyname
|
|
||||||
keyPair = makeKeyPair.apply(new RegionAndName(region, group));
|
|
||||||
credentialsMap.put(regionAndGroup, keyPair);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
credentialsMap.put(new RegionAndName(region, keyPair.getKeyName()), keyPair);
|
credentialsMap.put(new RegionAndName(region, keyPair.getKeyName()), keyPair);
|
||||||
return keyPair.getKeyName();
|
return keyPair.getKeyName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.jclouds.ec2.compute.strategy;
|
package org.jclouds.ec2.compute.strategy;
|
||||||
|
|
||||||
import static com.google.common.io.BaseEncoding.base64;
|
import static com.google.common.io.BaseEncoding.base64;
|
||||||
|
import static org.easymock.EasyMock.anyObject;
|
||||||
import static org.easymock.EasyMock.createMock;
|
import static org.easymock.EasyMock.createMock;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.EasyMock.replay;
|
import static org.easymock.EasyMock.replay;
|
||||||
|
@ -356,8 +357,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
||||||
expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
|
expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
|
||||||
expect(options.shouldAutomaticallyCreateKeyPair()).andReturn(shouldAutomaticallyCreateKeyPair);
|
expect(options.shouldAutomaticallyCreateKeyPair()).andReturn(shouldAutomaticallyCreateKeyPair);
|
||||||
expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
|
expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
|
||||||
expect(strategy.credentialsMap.containsKey(new RegionAndName(region, group))).andReturn(true);
|
expect(strategy.credentialsMap.putIfAbsent(anyObject(RegionAndName.class), anyObject(KeyPair.class))).andReturn(keyPair);
|
||||||
expect(strategy.credentialsMap.get(new RegionAndName(region, group))).andReturn(keyPair);
|
|
||||||
expect(options.getRunScript()).andReturn(null);
|
expect(options.getRunScript()).andReturn(null);
|
||||||
|
|
||||||
// replay mocks
|
// replay mocks
|
||||||
|
@ -557,6 +557,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
||||||
LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
|
LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
|
||||||
GroupNamingConvention.Factory namingConventionFactory = createMock(GroupNamingConvention.Factory.class);
|
GroupNamingConvention.Factory namingConventionFactory = createMock(GroupNamingConvention.Factory.class);
|
||||||
GroupNamingConvention namingConvention = createMock(GroupNamingConvention.class);
|
GroupNamingConvention namingConvention = createMock(GroupNamingConvention.class);
|
||||||
|
expect(makeKeyPair.apply(anyObject(RegionAndName.class))).andReturn(null).anyTimes();
|
||||||
expect(namingConventionFactory.create()).andReturn(namingConvention).anyTimes();
|
expect(namingConventionFactory.create()).andReturn(namingConvention).anyTimes();
|
||||||
expect(namingConvention.sharedNameForGroup("group")).andReturn("jclouds#group").anyTimes();
|
expect(namingConvention.sharedNameForGroup("group")).andReturn("jclouds#group").anyTimes();
|
||||||
replay(namingConventionFactory);
|
replay(namingConventionFactory);
|
||||||
|
|
|
@ -52,10 +52,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
|
||||||
@Override
|
@Override
|
||||||
public void copyTo(TemplateOptions to) {
|
public void copyTo(TemplateOptions to) {
|
||||||
super.copyTo(to);
|
super.copyTo(to);
|
||||||
if (to instanceof GoGridTemplateOptions) {
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
GoGridTemplateOptions eTo = GoGridTemplateOptions.class.cast(to);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final GoGridTemplateOptions NONE = new GoGridTemplateOptions();
|
public static final GoGridTemplateOptions NONE = new GoGridTemplateOptions();
|
||||||
|
|
Loading…
Reference in New Issue