From 71af3159d3f585847c3bf0687a59b44d41ef5ac3 Mon Sep 17 00:00:00 2001 From: Willem Visser Date: Mon, 8 Nov 2021 11:01:50 -0800 Subject: [PATCH 1/4] Update AwsSdkSample.java Removed the nonsense at the top of the file --- .../archetype-resources/src/main/java/AwsSdkSample.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java b/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java index ff0a1db21..eec75b66b 100644 --- a/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java +++ b/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java @@ -1,6 +1,8 @@ +/* #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) +*/ /* * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. * From 93e3f59907971063cc25b9476e94e04368c2ae6b Mon Sep 17 00:00:00 2001 From: Willem Visser Date: Mon, 8 Nov 2021 11:17:07 -0800 Subject: [PATCH 2/4] Update AwsSdkSample.java No real change this fixes the same bug as before --- .../archetype-resources/src/main/java/AwsSdkSample.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java b/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java index eec75b66b..b53affd6c 100644 --- a/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java +++ b/aws-sdk-java-archetype-master/src/main/resources/archetype-resources/src/main/java/AwsSdkSample.java @@ -1,8 +1,3 @@ -/* -#set( $symbol_pound = '#' ) -#set( $symbol_dollar = '$' ) -#set( $symbol_escape = '\' ) -*/ /* * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. * From 5cfc527bfa050fc4c899612263449843d189108e Mon Sep 17 00:00:00 2001 From: Willem Visser Date: Mon, 8 Nov 2021 12:07:40 -0800 Subject: [PATCH 3/4] Update InlineTaggingCodeSampleApp.java Refactored code clone out as a new method --- .../InlineTaggingCodeSampleApp.java | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonEC2SpotInstances-Advanced/InlineTaggingCodeSampleApp.java b/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonEC2SpotInstances-Advanced/InlineTaggingCodeSampleApp.java index 0c48af7e4..57a748aa3 100644 --- a/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonEC2SpotInstances-Advanced/InlineTaggingCodeSampleApp.java +++ b/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.sdk.ui/samples/AmazonEC2SpotInstances-Advanced/InlineTaggingCodeSampleApp.java @@ -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. */ @@ -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() + .withCredentials(new AWSStaticCredentialsProvider(credentials)) + .withRegion("us-west-2") .build(); // Initializes a Spot Instance Request @@ -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 ======================// @@ -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 ==============================// //============================================================================================// @@ -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()); + } + } } From 186b335a20bd8e0c4c5fd0e7a1beef28da954005 Mon Sep 17 00:00:00 2001 From: Willem Visser Date: Mon, 8 Nov 2021 13:32:08 -0800 Subject: [PATCH 4/4] Update RepositorySelection.java Removed clone --- .../core/egit/RepositorySelection.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/egit/RepositorySelection.java b/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/egit/RepositorySelection.java index 0c5a94c97..b5fbb1a2d 100644 --- a/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/egit/RepositorySelection.java +++ b/aws-toolkit-eclipse-master/bundles/com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/egit/RepositorySelection.java @@ -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; } @@ -184,4 +179,4 @@ else if (config != null) return config.hashCode(); return 31; } -} \ No newline at end of file +}