Skip to content

Commit d8d9605

Browse files
author
Vincent Potucek
committed
Add error-prone.picnic.tech featuring RedundantStringConversion
1 parent cc9702a commit d8d9605

File tree

52 files changed

+122
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+122
-80
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ plugins {
4141
id 'org.scoverage' version '8.0.3' apply false
4242
id 'com.gradleup.shadow' version '8.3.9' apply false
4343
id 'com.diffplug.spotless' version "7.2.1"
44+
id 'net.ltgt.errorprone' version '4.3.0' apply false
45+
}
46+
47+
allprojects {
48+
apply from: rootProject.file('gradle/error-prone.gradle')
4449
}
4550

4651
ext {
@@ -76,7 +81,7 @@ ext {
7681
// until version can be upgraded: https://github.com/spotbugs/spotbugs/issues/3564
7782
project.gradle.startParameter.excludedTaskNames.add("spotbugsMain")
7883
project.gradle.startParameter.excludedTaskNames.add("spotbugsTest")
79-
}
84+
}
8085

8186
maxTestForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : Runtime.runtime.availableProcessors()
8287
maxScalacThreads = project.hasProperty('maxScalacThreads') ? maxScalacThreads.toInteger() :

clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ private boolean isSticky() {
387387
if (hasCycles(topicMovementPairs)) {
388388
log.error("Stickiness is violated for topic {}"
389389
+ "\nPartition movements for this topic occurred among the following consumer pairs:"
390-
+ "\n{}", topicMovements.getKey(), topicMovements.getValue().toString());
390+
+ "\n{}", topicMovements.getKey(), topicMovements.getValue());
391391
return false;
392392
}
393393
}

clients/src/main/java/org/apache/kafka/clients/producer/RecordMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ public int partition() {
119119

120120
@Override
121121
public String toString() {
122-
return topicPartition.toString() + "@" + offset;
122+
return topicPartition + "@" + offset;
123123
}
124124
}

clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public MetricName metricInstance(MetricNameTemplate template, Map<String, String
661661

662662
if (!runtimeTagKeys.equals(templateTagKeys)) {
663663
throw new IllegalArgumentException("For '" + template.name() + "', runtime-defined metric tags do not match the tags in the template. "
664-
+ "Runtime = " + runtimeTagKeys + " Template = " + templateTagKeys.toString());
664+
+ "Runtime = " + runtimeTagKeys + " Template = " + templateTagKeys);
665665
}
666666

667667
return this.metricName(template.name(), template.group(), template.description(), tags);

clients/src/main/java/org/apache/kafka/common/metrics/internals/IntGaugeSuite.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void increment(K key) {
167167
synchronized (this) {
168168
if (closed) {
169169
log.warn("{}: Attempted to increment {}, but the GaugeSuite was closed.",
170-
suiteName, key.toString());
170+
suiteName, key);
171171
return;
172172
}
173173
StoredIntGauge gauge = gauges.get(key);
@@ -181,7 +181,7 @@ public void increment(K key) {
181181
if (gauges.size() == maxEntries) {
182182
if (removable.isEmpty()) {
183183
log.debug("{}: Attempted to increment {}, but there are already {} entries.",
184-
suiteName, key.toString(), maxEntries);
184+
suiteName, key, maxEntries);
185185
return;
186186
}
187187
Iterator<K> iter = removable.iterator();
@@ -191,13 +191,13 @@ public void increment(K key) {
191191
gauges.remove(keyToRemove);
192192
pending.push(new PendingMetricsChange(metricNameToRemove, null));
193193
log.trace("{}: Removing the metric {}, which has a value of 0.",
194-
suiteName, keyToRemove.toString());
194+
suiteName, keyToRemove);
195195
}
196196
MetricName metricNameToAdd = metricNameCalculator.apply(key);
197197
gauge = new StoredIntGauge(metricNameToAdd);
198198
gauges.put(key, gauge);
199199
pending.push(new PendingMetricsChange(metricNameToAdd, gauge));
200-
log.trace("{}: Adding a new metric {}.", suiteName, key.toString());
200+
log.trace("{}: Adding a new metric {}.", suiteName, key);
201201
}
202202
// Drop the object monitor and perform any pending metrics additions or removals.
203203
performPendingMetricsOperations();
@@ -236,17 +236,17 @@ private void performPendingMetricsOperations() {
236236
public synchronized void decrement(K key) {
237237
if (closed) {
238238
log.warn("{}: Attempted to decrement {}, but the gauge suite was closed.",
239-
suiteName, key.toString());
239+
suiteName, key);
240240
return;
241241
}
242242
StoredIntGauge gauge = gauges.get(key);
243243
if (gauge == null) {
244244
log.debug("{}: Attempted to decrement {}, but no such metric was registered.",
245-
suiteName, key.toString());
245+
suiteName, key);
246246
} else {
247247
int cur = gauge.decrement();
248248
log.trace("{}: Removed a reference to {}. {} reference(s) remaining.",
249-
suiteName, key.toString(), cur);
249+
suiteName, key, cur);
250250
if (cur <= 0) {
251251
removable.add(key);
252252
}

clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static String deepToString(Iterator<?> iter) {
5757
while (iter.hasNext()) {
5858
Object object = iter.next();
5959
bld.append(prefix);
60-
bld.append(object.toString());
60+
bld.append(object);
6161
prefix = ", ";
6262
}
6363
bld.append("]");

clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public String toString() {
181181
StringBuilder b = new StringBuilder();
182182
b.append('{');
183183
for (int i = 0; i < this.fields.length; i++) {
184-
b.append(this.fields[i].toString());
184+
b.append(this.fields[i]);
185185
if (i < this.fields.length - 1)
186186
b.append(',');
187187
}

clients/src/main/java/org/apache/kafka/common/protocol/types/TaggedFields.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public String toString() {
138138
for (Map.Entry<Integer, Field> field : fields.entrySet()) {
139139
bld.append(prefix);
140140
prefix = ", ";
141-
bld.append(field.getKey()).append(" -> ").append(field.getValue().toString());
141+
bld.append(field.getKey()).append(" -> ").append(field.getValue());
142142
}
143143
bld.append(")");
144144
return bld.toString();

clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ private KafkaMetric getMetric(String name, Map<String, String> tags) throws Exce
892892
entry.getKey().name().equals(name) && entry.getKey().tags().equals(tags))
893893
.findFirst();
894894
if (metric.isEmpty())
895-
throw new Exception(String.format("Could not find metric called %s with tags %s", name, tags.toString()));
895+
throw new Exception(String.format("Could not find metric called %s with tags %s", name, tags));
896896

897897
return metric.get().getValue();
898898
}

connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMaker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ public void awaitStop() {
226226

227227
private void checkHerder(SourceAndTarget sourceAndTarget) {
228228
if (!herders.containsKey(sourceAndTarget)) {
229-
throw new IllegalArgumentException("No herder for " + sourceAndTarget.toString());
229+
throw new IllegalArgumentException("No herder for " + sourceAndTarget);
230230
}
231231
}
232232

233233
private void addHerder(SourceAndTarget sourceAndTarget) {
234-
log.info("creating herder for {}", sourceAndTarget.toString());
234+
log.info("creating herder for {}", sourceAndTarget);
235235
Map<String, String> workerProps = config.workerConfig(sourceAndTarget);
236236
DistributedConfig distributedConfig = new DistributedConfig(workerProps);
237237
String encodedSource = encodePath(sourceAndTarget.source());
@@ -289,13 +289,13 @@ private static String encodePath(String rawPath) {
289289

290290
private String generateWorkerId(SourceAndTarget sourceAndTarget) {
291291
if (config.enableInternalRest()) {
292-
return advertisedUrl.getHost() + ":" + advertisedUrl.getPort() + "/" + sourceAndTarget.toString();
292+
return advertisedUrl.getHost() + ":" + advertisedUrl.getPort() + "/" + sourceAndTarget;
293293
}
294294
try {
295295
//UUID to make sure it is unique even if multiple workers running on the same host
296-
return InetAddress.getLocalHost().getCanonicalHostName() + "/" + sourceAndTarget.toString() + "/" + UUID.randomUUID();
296+
return InetAddress.getLocalHost().getCanonicalHostName() + "/" + sourceAndTarget + "/" + UUID.randomUUID();
297297
} catch (UnknownHostException e) {
298-
return sourceAndTarget.toString() + "/" + UUID.randomUUID();
298+
return sourceAndTarget + "/" + UUID.randomUUID();
299299
}
300300
}
301301

0 commit comments

Comments
 (0)