From 3c95d4731cfc1ad575f92e6c1944bf6f881e74d2 Mon Sep 17 00:00:00 2001 From: Dave Brosius Date: Sun, 4 Sep 2016 12:19:16 -0400 Subject: [PATCH] use StringBuilder correctly --- .../org/apache/cassandra/metrics/TableMetrics.java | 2 +- .../org/apache/cassandra/tools/nodetool/Ring.java | 4 ++-- .../org/apache/cassandra/tools/nodetool/Status.java | 4 ++-- .../org/apache/cassandra/stress/StressProfile.java | 4 ++-- .../stress/settings/OptionAnyProbabilities.java | 10 +++++----- .../cassandra/stress/settings/OptionMulti.java | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/java/org/apache/cassandra/metrics/TableMetrics.java b/src/java/org/apache/cassandra/metrics/TableMetrics.java index c57f24051b..0a726d4b06 100644 --- a/src/java/org/apache/cassandra/metrics/TableMetrics.java +++ b/src/java/org/apache/cassandra/metrics/TableMetrics.java @@ -952,7 +952,7 @@ public class TableMetrics String groupName = TableMetrics.class.getPackage().getName(); StringBuilder mbeanName = new StringBuilder(); mbeanName.append(groupName).append(":"); - mbeanName.append("type=" + type); + mbeanName.append("type=").append(type); mbeanName.append(",name=").append(metricName); return new CassandraMetricsRegistry.MetricName(groupName, type, metricName, "all", mbeanName.toString()); } diff --git a/src/java/org/apache/cassandra/tools/nodetool/Ring.java b/src/java/org/apache/cassandra/tools/nodetool/Ring.java index 55220a1187..c6b9af17ca 100644 --- a/src/java/org/apache/cassandra/tools/nodetool/Ring.java +++ b/src/java/org/apache/cassandra/tools/nodetool/Ring.java @@ -72,7 +72,7 @@ public class Ring extends NodeToolCmd String formatPlaceholder = "%%-%ds %%-12s%%-7s%%-8s%%-16s%%-20s%%-44s%%n"; String format = format(formatPlaceholder, maxAddressLength); - StringBuffer errors = new StringBuffer(); + StringBuilder errors = new StringBuilder(); boolean showEffectiveOwnership = true; // Calculate per-token ownership of the ring Map ownerships; @@ -83,7 +83,7 @@ public class Ring extends NodeToolCmd catch (IllegalStateException ex) { ownerships = probe.getOwnership(); - errors.append("Note: " + ex.getMessage() + "%n"); + errors.append("Note: ").append(ex.getMessage()).append("%n"); showEffectiveOwnership = false; } catch (IllegalArgumentException ex) diff --git a/src/java/org/apache/cassandra/tools/nodetool/Status.java b/src/java/org/apache/cassandra/tools/nodetool/Status.java index a43b7039df..f7bb1e52a7 100644 --- a/src/java/org/apache/cassandra/tools/nodetool/Status.java +++ b/src/java/org/apache/cassandra/tools/nodetool/Status.java @@ -65,7 +65,7 @@ public class Status extends NodeToolCmd hostIDMap = probe.getHostIdMap(); epSnitchInfo = probe.getEndpointSnitchInfoProxy(); - StringBuffer errors = new StringBuffer(); + StringBuilder errors = new StringBuilder(); Map ownerships = null; boolean hasEffectiveOwns = false; @@ -77,7 +77,7 @@ public class Status extends NodeToolCmd catch (IllegalStateException e) { ownerships = probe.getOwnership(); - errors.append("Note: " + e.getMessage() + "%n"); + errors.append("Note: ").append(e.getMessage()).append("%n"); } catch (IllegalArgumentException ex) { diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java index 9e2783df14..1343cf12dd 100644 --- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java +++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java @@ -464,7 +464,7 @@ public class StressProfile implements Serializable List allColumns = com.google.common.collect.Lists.newArrayList(cfMetaData.allColumnsInSelectOrder()); StringBuilder sb = new StringBuilder(); - sb.append("INSERT INTO ").append(quoteIdentifier(keyspaceName) + "." + quoteIdentifier(tableName)).append(" ("); + sb.append("INSERT INTO ").append(quoteIdentifier(keyspaceName)).append(".").append(quoteIdentifier(tableName)).append(" ("); StringBuilder value = new StringBuilder(); for (ColumnDefinition c : allColumns) { @@ -664,7 +664,7 @@ public class StressProfile implements Serializable return first; if (val != null && val.trim().length() > 0) return builder.apply(val); - + return builder.apply(defValue); } diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java b/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java index 181f4d6d09..0d045c0008 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionAnyProbabilities.java @@ -1,6 +1,6 @@ package org.apache.cassandra.stress.settings; /* - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -8,16 +8,16 @@ package org.apache.cassandra.stress.settings; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ @@ -63,7 +63,7 @@ public final class OptionAnyProbabilities extends OptionMulti StringBuilder sb = new StringBuilder(); for (Map.Entry entry : options.entrySet()) { - sb.append(entry.getKey() + "=" + entry.getValue() + ","); + sb.append(entry.getKey()).append("=").append(entry.getValue()).append(","); } return sb.toString(); } diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java b/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java index d051554c29..1d7ae7224a 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/OptionMulti.java @@ -1,6 +1,6 @@ package org.apache.cassandra.stress.settings; /* - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -8,16 +8,16 @@ package org.apache.cassandra.stress.settings; * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * */ @@ -112,7 +112,7 @@ abstract class OptionMulti extends Option public String getOptionAsString() { StringBuilder sb = new StringBuilder(); - sb.append(name + ": "); + sb.append(name).append(": "); sb.append(delegate.getOptionAsString()); sb.append(";"); if (collectAsMap != null) @@ -188,7 +188,7 @@ abstract class OptionMulti extends Option StringBuilder sb = new StringBuilder(); for (Map.Entry entry : options.entrySet()) { - sb.append(entry.getKey() + "=" + entry.getValue() + ","); + sb.append(entry.getKey()).append("=").append(entry.getValue()).append(","); } return sb.toString(); }