diff --git a/runnel/src/main/java/org/terracotta/runnel/metadata/Metadata.java b/runnel/src/main/java/org/terracotta/runnel/metadata/Metadata.java index 81a2c653e2..1f166ef524 100644 --- a/runnel/src/main/java/org/terracotta/runnel/metadata/Metadata.java +++ b/runnel/src/main/java/org/terracotta/runnel/metadata/Metadata.java @@ -27,19 +27,12 @@ */ public class Metadata { - private final List metadata; - private Map fieldsByName; + private final Map fieldsByName; public Metadata(List metadata) { - this.metadata = metadata; - } - - private void initFields(List metadata) { - if (fieldsByName == null) { - fieldsByName = new HashMap(metadata.size(), 1.0F); - for (Field field : metadata) { - fieldsByName.put(field.name(), field); - } + fieldsByName = new HashMap(); + for (Field field : metadata) { + fieldsByName.put(field.name(), field); } } @@ -52,7 +45,6 @@ public FieldDecoder fieldDecoder(ReadBuffer readBuffer) { } public Map buildFieldsByIndexMap() { - initFields(metadata); Map map = new HashMap(); for (Field field : fieldsByName.values()) { map.put(field.index(), field); @@ -61,7 +53,6 @@ public Map buildFieldsByIndexMap() { } Field getFieldByName(String name) { - initFields(metadata); return fieldsByName.get(name); } diff --git a/runnel/src/test/java/org/terracotta/runnel/StructBuilderTest.java b/runnel/src/test/java/org/terracotta/runnel/StructBuilderTest.java index b971288c17..96c0120426 100644 --- a/runnel/src/test/java/org/terracotta/runnel/StructBuilderTest.java +++ b/runnel/src/test/java/org/terracotta/runnel/StructBuilderTest.java @@ -131,20 +131,4 @@ public void checkValidConfigWorks() throws Exception { StructBuilder.newStructBuilder().enm("a", 2, ENM).enm("b", 3, ENM); } - /** - * Check that when calling StructBuilder.build(), then modifying the builder again then - * building a second struct, we do end up with two identical structs. - * - * Ugly, but that's the quick way to solve the struct loop struct1 -> struct2 -> struct1 problem. - */ - @Test - public void checkLazyStructAliasesWork() throws Exception { - StructBuilder structBuilder = StructBuilder.newStructBuilder(); - - Struct lazilyInitializedStruct = structBuilder.build(); - Struct struct = structBuilder.int32("a", 2).int32("b", 3).build(); - - lazilyInitializedStruct.encoder().int32("a", 1).int32("b", -1).encode(); - struct.encoder().int32("a", 1).int32("b", -1).encode(); - } }