Skip to content
Open
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,3 @@
#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
/*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,17 @@ public RepositorySelection(final URIish uri, final RemoteConfig config) {
* selection
*/
public URIish getURI(boolean pushMode) {
if (isConfigSelected())
if (pushMode) {
if (config.getPushURIs().size() > 0)
return config.getPushURIs().get(0);
else if (config.getURIs().size() > 0)
return config.getURIs().get(0);
else
return null;
} else {
if (config.getURIs().size() > 0)
return config.getURIs().get(0);
else if (config.getPushURIs().size() > 0)
return config.getPushURIs().get(0);
else
return null;
if (isConfigSelected()) {
boolean pushOptions = config.getPushURIs().size() > 0;
boolean uriOptions = config.getURIs().size() > 0;
URIish returnOption = null;
if ((pushOptions && pushMode) || (!pushMode && !uriOptions)) {
returnOption = config.getPushURIs().get(0);
} else if ((!pushOptions && pushMode) || (!pushMode && !pushOptions)) {
returnOption = config.getURIs().get(0);
}
return returnOption;
}
return uri;
}

Expand Down Expand Up @@ -184,4 +179,4 @@ else if (config != null)
return config.hashCode();
return 31;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class InlineTaggingCodeSampleApp {
* credentials from.
* https://console.aws.amazon.com/iam/home?#security_credential
*
* WARNING:
* WARNING:
* To avoid accidental leakage of your credentials, DO NOT keep
* the credentials file in your source directory.
*/
Expand All @@ -93,9 +93,9 @@ public static void main(String[] args) {
}

// Create the AmazonEC2Client object so we can call various APIs.
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("us-west-2")
AmazonEC2 ec2 = AmazonEC2ClientBuilder.standard()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

AWS Region is set using a String. To explicitly set a publicly available region, we recommend that you use the Regions enum.

Learn more

.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("us-west-2")
.build();

// Initializes a Spot Instance Request
Expand Down Expand Up @@ -149,20 +149,11 @@ public static void main(String[] args) {

// Create a tag request for requests.
CreateTagsRequest createTagsRequest_requests = new CreateTagsRequest();

createTagsRequest_requests.setResources(spotInstanceRequestIds);
createTagsRequest_requests.setTags(requestTags);

// Try to tag the Spot request submitted.
try {
ec2.createTags(createTagsRequest_requests);
} catch (AmazonServiceException e) {
// Write out any exceptions that may have occurred.
System.out.println("Error terminating instances");
System.out.println("Caught Exception: " + e.getMessage());
System.out.println("Reponse Status Code: " + e.getStatusCode());
System.out.println("Error Code: " + e.getErrorCode());
System.out.println("Request ID: " + e.getRequestId());
}
handleException(createTagsRequest_requests, ec2);

//============================================================================================//
//=========================== Determining the State of the Spot Request ======================//
Expand Down Expand Up @@ -228,18 +219,8 @@ public static void main(String[] args) {
createTagsRequest_instances.setResources(instanceIds);
createTagsRequest_instances.setTags(instanceTags);

// Try to tag the Spot instance started.
try {
ec2.createTags(createTagsRequest_instances);
} catch (AmazonServiceException e) {
// Write out any exceptions that may have occurred.
System.out.println("Error terminating instances");
System.out.println("Caught Exception: " + e.getMessage());
System.out.println("Reponse Status Code: " + e.getStatusCode());
System.out.println("Error Code: " + e.getErrorCode());
System.out.println("Request ID: " + e.getRequestId());
}

handleException(createTagsRequest_instances, ec2);

//============================================================================================//
//====================================== Canceling the Request ==============================//
//============================================================================================//
Expand Down Expand Up @@ -274,5 +255,18 @@ public static void main(String[] args) {
}

}


private static void handleException(CreateTagsRequest createTagsRequest_requests, AmazonEC2 ec2) {
// Try to tag the Spot request submitted.
try {
ec2.createTags(createTagsRequest_requests);
} catch (AmazonServiceException e) {
// Write out any exceptions that may have occurred.
System.out.println("Error terminating instances");
System.out.println("Caught Exception: " + e.getMessage());
System.out.println("Reponse Status Code: " + e.getStatusCode());
System.out.println("Error Code: " + e.getErrorCode());
System.out.println("Request ID: " + e.getRequestId());
}
}
}