Skip to content

Commit e5921d1

Browse files
committed
Fix more pmd_analyze issues.
1 parent 2ad954e commit e5921d1

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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
@@ -85,7 +85,7 @@ void test_tracing() {
8585
// We need to filter segments based on name because they are not returned in-order from the X-Ray API
8686
// The Init segment is created by default for Lambda functions in X-Ray
8787
final SubSegment initSegment = trace.getSubsegments().stream()
88-
.filter(subSegment -> subSegment.getName().equals("Init"))
88+
.filter(subSegment -> "Init".equals(subSegment.getName()))
8989
.findFirst().orElse(null);
9090
assertThat(initSegment.getName()).isEqualTo("Init");
9191
assertThat(initSegment.getAnnotations()).isNull();

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
* `PutObjectRequest`)
9999
* and the CloudFormation stack is created (with the SDK `createStack`)
100100
*/
101-
public class Infrastructure {
101+
public final class Infrastructure {
102102
public static final String FUNCTION_NAME_OUTPUT = "functionName";
103103
private static final Logger LOG = LoggerFactory.getLogger(Infrastructure.class);
104104

@@ -121,7 +121,6 @@ public class Infrastructure {
121121
private final String kinesisStream;
122122
private final String largeMessagesBucket;
123123
private String ddbStreamsTableName;
124-
private String functionName;
125124
private Object cfnTemplate;
126125
private String cfnAssetDirectory;
127126

@@ -224,7 +223,7 @@ private Stack createStackWithLambda() {
224223
? dockerConfig.createGraalVMBundlingOptions(pathToFunction, runtime)
225224
: dockerConfig.createJVMBundlingOptions(pathToFunction, runtime);
226225

227-
functionName = stackName + "-function";
226+
String functionName = stackName + "-function";
228227
CfnOutput.Builder.create(e2eStack, FUNCTION_NAME_OUTPUT)
229228
.value(functionName)
230229
.build();

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/testutils/tracing/TraceFetcher.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,11 @@ private Trace getTrace(List<String> traceIds) {
112112
trace.segments().forEach(segment -> {
113113
try {
114114
SegmentDocument document = MAPPER.readValue(segment.document(), SegmentDocument.class);
115-
if (document.getOrigin().equals("AWS::Lambda::Function")) {
116-
if (document.hasSubsegments()) {
117-
getNestedSubSegments(document.getSubsegments(), traceRes,
118-
Collections.emptyList());
119-
}
115+
if ("AWS::Lambda::Function".equals(document.getOrigin()) && document.hasSubsegments()) {
116+
getNestedSubSegments(document.getSubsegments(), traceRes,
117+
Collections.emptyList());
120118
}
119+
121120
} catch (JsonProcessingException e) {
122121
LOG.error("Failed to parse segment document: " + e.getMessage());
123122
throw new RuntimeException(e);

0 commit comments

Comments
 (0)