From 1cf694b63e50b39d09b8fb2ed16f8c4bff18dc69 Mon Sep 17 00:00:00 2001 From: Chris Earle Date: Wed, 17 Aug 2016 17:36:46 -0400 Subject: [PATCH] Use StringBuilder in favor of StringBuffer This removes all instances of StringBuffer that are removeable. Uncontended synchronization in Java is pretty cheap, but it's unnecessary. --- .../org/elasticsearch/env/ShardLockObtainFailedException.java | 2 +- .../java/org/elasticsearch/index/analysis/phonetic/Nysiis.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/env/ShardLockObtainFailedException.java b/core/src/main/java/org/elasticsearch/env/ShardLockObtainFailedException.java index 1c113e1abea..d1a8ce3b6d4 100644 --- a/core/src/main/java/org/elasticsearch/env/ShardLockObtainFailedException.java +++ b/core/src/main/java/org/elasticsearch/env/ShardLockObtainFailedException.java @@ -39,7 +39,7 @@ public class ShardLockObtainFailedException extends Exception { @Override public String getMessage() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(shardId.toString()); sb.append(": "); sb.append(super.getMessage()); diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/phonetic/Nysiis.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/phonetic/Nysiis.java index 894d5d8bd3e..62e2174af8d 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/phonetic/Nysiis.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/phonetic/Nysiis.java @@ -263,7 +263,7 @@ public class Nysiis implements StringEncoder { str = PAT_DT_ETC.matcher(str).replaceFirst("D"); // First character of key = first character of name. - StringBuffer key = new StringBuffer(str.length()); + StringBuilder key = new StringBuilder(str.length()); key.append(str.charAt(0)); // Transcode remaining characters, incrementing by one character each time