Skip to content

Commit 420e161

Browse files
committed
Fix pmd_analyze issues.
1 parent 55447b5 commit 420e161

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/BatchE2ET.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void cleanUpTest() {
131131
.build());
132132

133133
for (Map<String, AttributeValue> item : items.items()) {
134-
HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>() {
134+
Map<String, AttributeValue> key = new HashMap<String, AttributeValue>() {
135135
{
136136
put("functionName", AttributeValue.builder()
137137
.s(item.get("functionName").s())

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/LargeMessageE2ET.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ void bigSQSMessageOffloadedToS3_shouldLoadFromS3() throws IOException {
109109
final ExtendedClientConfiguration extendedClientConfig = new ExtendedClientConfiguration()
110110
.withPayloadSupportEnabled(s3Client, bucketName);
111111
try (AmazonSQSExtendedClient client = new AmazonSQSExtendedClient(
112-
SqsClient.builder().region(region).httpClient(httpClient).build(), extendedClientConfig)) {
113-
InputStream inputStream = this.getClass().getResourceAsStream("/large_sqs_message.txt");
112+
SqsClient.builder().region(region).httpClient(httpClient).build(), extendedClientConfig);
113+
InputStream inputStream = this.getClass().getResourceAsStream("/large_sqs_message.txt");) {
114114
String bigMessage = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
115115

116116
// WHEN

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/LargeMessageIdempotentE2ET.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,23 @@ static void tearDown() {
111111
void test_ttlNotExpired_doesNotInsertInDDB_ttlExpired_insertInDDB() throws InterruptedException,
112112
IOException {
113113
// GIVEN
114-
InputStream inputStream = this.getClass().getResourceAsStream("/large_sqs_message.txt");
115-
String bigMessage = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
116-
117-
// upload manually to S3
118-
String key = UUID.randomUUID().toString();
119-
s3Client.putObject(PutObjectRequest.builder()
120-
.bucket(bucketName)
121-
.key(key)
122-
.build(), RequestBody.fromString(bigMessage));
114+
String s3Key = UUID.randomUUID().toString();
115+
try (InputStream inputStream = this.getClass().getResourceAsStream("/large_sqs_message.txt")) {
116+
String bigMessage = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
117+
118+
// upload manually to S3
119+
s3Client.putObject(PutObjectRequest.builder()
120+
.bucket(bucketName)
121+
.key(s3Key)
122+
.build(), RequestBody.fromString(bigMessage));
123+
}
123124

124125
// WHEN
125126
SendMessageRequest messageRequest = SendMessageRequest.builder()
126127
.queueUrl(queueUrl)
127128
.messageBody(String.format(
128129
"[\"software.amazon.payloadoffloading.PayloadS3Pointer\",{\"s3BucketName\":\"%s\",\"s3Key\":\"%s\"}]",
129-
bucketName, key))
130+
bucketName, s3Key))
130131
.messageAttributes(Collections.singletonMap("SQSLargePayloadSize", MessageAttributeValue.builder()
131132
.stringValue("300977")
132133
.dataType("Number")

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/TracingE2ET.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void test_tracing() {
9191
assertThat(initSegment.getAnnotations()).isNull();
9292

9393
final SubSegment handleRequestSegment = trace.getSubsegments().stream()
94-
.filter(subSegment -> subSegment.getName().equals("## handleRequest"))
94+
.filter(subSegment -> "## handleRequest".equals(subSegment.getName()))
9595
.findFirst().orElse(null);
9696
assertNotNull(handleRequestSegment);
9797
assertThat(handleRequestSegment.getName()).isEqualTo("## handleRequest");

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/ValidationALBE2ET.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ static void tearDown() {
6161

6262
@Test
6363
void test_validInboundSQSEvent() throws IOException {
64-
InputStream inputStream = this.getClass().getResourceAsStream("/validation/valid_alb_in_out_event.json");
65-
String validEvent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
66-
67-
// WHEN
68-
InvocationResult invocationResult = invokeFunction(functionName, validEvent);
69-
70-
// THEN
71-
// invocation should pass validation and return 200
72-
JsonNode validJsonNode = objectMapper.readTree(invocationResult.getResult());
73-
assertThat(validJsonNode.get("statusCode").asInt()).isEqualTo(200);
74-
assertThat(validJsonNode.get("body").asText()).isEqualTo("{\"price\": 150}");
64+
try (InputStream is = this.getClass().getResourceAsStream("/validation/valid_alb_in_out_event.json")) {
65+
String validEvent = IOUtils.toString(is, StandardCharsets.UTF_8);
66+
// WHEN
67+
InvocationResult invocationResult = invokeFunction(functionName, validEvent);
68+
69+
// THEN
70+
// invocation should pass validation and return 200
71+
JsonNode validJsonNode = objectMapper.readTree(invocationResult.getResult());
72+
assertThat(validJsonNode.get("statusCode").asInt()).isEqualTo(200);
73+
assertThat(validJsonNode.get("body").asText()).isEqualTo("{\"price\": 150}");
74+
}
7575
}
7676

7777
@Test

0 commit comments

Comments
 (0)