Correct unnecessary builder reassignment codahale-aggregated-metrics-cloudwatch-reporter's with* methods are mutating the builder object itself, so there's no need to reassign the mutated object to itself from the caller. This allows to make the CloudWatchAsyncClientBuilder final, which in turns helps the compiler, improves readability and allows to use the value in lambdas. Change-Id: I0bdf608f1c9649f4a139eb3fdd6b6fc8062041d8
diff --git a/src/main/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporter.java b/src/main/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporter.java index 56b6769..8cafca5 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporter.java +++ b/src/main/java/com/googlesource/gerrit/plugins/metricsreportercloudwatch/GerritCloudwatchReporter.java
@@ -33,7 +33,8 @@ throws IllegalStateException { this.config = config; - CloudWatchAsyncClientBuilder cloudWatchAsyncClientBuilder = CloudWatchAsyncClient.builder(); + final CloudWatchAsyncClientBuilder cloudWatchAsyncClientBuilder = + CloudWatchAsyncClient.builder(); CloudWatchReporter.Builder cloudWatchReporterBuilder = CloudWatchReporter.forRegistry( @@ -46,11 +47,11 @@ .withHighResolution(); if (config.getDryRun()) { - cloudWatchReporterBuilder = cloudWatchReporterBuilder.withDryRun(); + cloudWatchReporterBuilder.withDryRun(); } if (config.getJvmMetrics()) { - cloudWatchReporterBuilder = cloudWatchReporterBuilder.withJvmMetrics(); + cloudWatchReporterBuilder.withJvmMetrics(); } cloudWatchReporter = cloudWatchReporterBuilder.build();