From c2f70e36eeff84cc85d06b1d0e8c8acbd29410cc Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 17 May 2021 21:14:14 +0200 Subject: Use explicit import and final members where you can. --- .../searchdefinition/derived/SummaryClassField.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java index 4375b446e98..c0093e031d1 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java @@ -5,7 +5,19 @@ import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.MapDataType; import com.yahoo.document.ReferenceDataType; -import com.yahoo.document.datatypes.*; +import com.yahoo.document.datatypes.BoolFieldValue; +import com.yahoo.document.datatypes.ByteFieldValue; +import com.yahoo.document.datatypes.DoubleFieldValue; +import com.yahoo.document.datatypes.FieldValue; +import com.yahoo.document.datatypes.Float16FieldValue; +import com.yahoo.document.datatypes.FloatFieldValue; +import com.yahoo.document.datatypes.IntegerFieldValue; +import com.yahoo.document.datatypes.LongFieldValue; +import com.yahoo.document.datatypes.PredicateFieldValue; +import com.yahoo.document.datatypes.Raw; +import com.yahoo.document.datatypes.StringFieldValue; +import com.yahoo.document.datatypes.Struct; +import com.yahoo.document.datatypes.TensorFieldValue; import com.yahoo.vespa.documentmodel.SummaryTransform; /** @@ -39,7 +51,7 @@ public class SummaryClassField { JSONSTRING("jsonstring"), TENSOR("tensor"); - private String name; + private final String name; Type(String name) { this.name = name; -- cgit v1.2.3 From 38d447ad818c8e0183325db5751635fece76989b Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 17 May 2021 21:14:39 +0200 Subject: Remove by index is not thread safe, even if the list is a CopyOnWriteArrayList. iOne thing is that it might throw if index is invalid. The other thing is that the index might point to something completely different. But remove by value should be fine. --- .../com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java index f8e6989bbfa..792d3628ba0 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java @@ -108,13 +108,13 @@ public class ContentPolicy extends SlobrokPolicy { while ((targets.total != 0) && (100 * targets.list.size() / targets.total >= requiredUpPercentageToSendToKnownGoodNodes)) { - int randIndex = randomizer.nextInt(targets.list.size()); - String targetSpec = getTargetSpec(targets.list.get(randIndex), context); + Integer distributor = targets.list.get(randomizer.nextInt(targets.list.size())); + String targetSpec = getTargetSpec(distributor, context); if (targetSpec != null) { context.trace(3, "Sending to random node seen up in cluster state"); return targetSpec; } - targets.list.remove(randIndex); + targets.list.remove(distributor); } context.trace(3, "Too few nodes seen up in state. Sending totally random."); return getTargetSpec(null, context); -- cgit v1.2.3