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
|
||||
protected String createOrImportKeyPair(String region, String group, TemplateOptions options) {
|
||||
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
|
||||
synchronized (credentialsMap) {
|
||||
// if there is already a keypair for the group specified, use it
|
||||
if (credentialsMap.containsKey(regionAndGroup))
|
||||
return credentialsMap.get(regionAndGroup).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);
|
||||
KeyPair origValue = credentialsMap.putIfAbsent(regionAndGroup, keyPair);
|
||||
if (origValue != null) {
|
||||
return origValue.getKeyName();
|
||||
}
|
||||
|
||||
credentialsMap.put(new RegionAndName(region, keyPair.getKeyName()), keyPair);
|
||||
return keyPair.getKeyName();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jclouds.ec2.compute.strategy;
|
||||
|
||||
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.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
|
@ -356,8 +357,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
expect(options.getKeyPair()).andReturn(userSuppliedKeyPair);
|
||||
expect(options.shouldAutomaticallyCreateKeyPair()).andReturn(shouldAutomaticallyCreateKeyPair);
|
||||
expect(keyPair.getKeyName()).andReturn(systemGeneratedKeyPairName).atLeastOnce();
|
||||
expect(strategy.credentialsMap.containsKey(new RegionAndName(region, group))).andReturn(true);
|
||||
expect(strategy.credentialsMap.get(new RegionAndName(region, group))).andReturn(keyPair);
|
||||
expect(strategy.credentialsMap.putIfAbsent(anyObject(RegionAndName.class), anyObject(KeyPair.class))).andReturn(keyPair);
|
||||
expect(options.getRunScript()).andReturn(null);
|
||||
|
||||
// replay mocks
|
||||
|
@ -557,6 +557,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
LoadingCache<RegionAndName, String> securityGroupMap = createMock(LoadingCache.class);
|
||||
GroupNamingConvention.Factory namingConventionFactory = createMock(GroupNamingConvention.Factory.class);
|
||||
GroupNamingConvention namingConvention = createMock(GroupNamingConvention.class);
|
||||
expect(makeKeyPair.apply(anyObject(RegionAndName.class))).andReturn(null).anyTimes();
|
||||
expect(namingConventionFactory.create()).andReturn(namingConvention).anyTimes();
|
||||
expect(namingConvention.sharedNameForGroup("group")).andReturn("jclouds#group").anyTimes();
|
||||
replay(namingConventionFactory);
|
||||
|
|
|
@ -52,10 +52,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
|
|||
@Override
|
||||
public void copyTo(TemplateOptions to) {
|
||||
super.copyTo(to);
|
||||
if (to instanceof GoGridTemplateOptions) {
|
||||
@SuppressWarnings("unused")
|
||||
GoGridTemplateOptions eTo = GoGridTemplateOptions.class.cast(to);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GoGridTemplateOptions NONE = new GoGridTemplateOptions();
|
||||
|
|
Loading…
Reference in New Issue