Skip to content

Commit cb3dc78

Browse files
Minor improvements to shallow trace
1 parent 7802139 commit cb3dc78

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/com/linkedin/parseq/trace/ShallowTrace.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,15 @@ public class ShallowTrace
6565
_endNanos = endNanos;
6666
_systemHidden = systemHidden;
6767

68-
Map<String, String> attributeMap = new HashMap<String, String>(attributes);
69-
_attributes = Collections.unmodifiableMap(attributeMap);
68+
if (!attributes.isEmpty())
69+
{
70+
Map<String, String> attributeMap = new HashMap<String, String>(attributes);
71+
_attributes = Collections.unmodifiableMap(attributeMap);
72+
}
73+
else
74+
{
75+
_attributes = Collections.emptyMap();
76+
}
7077

7178
switch (resultType)
7279
{

src/com/linkedin/parseq/trace/ShallowTraceBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.linkedin.parseq.internal.ArgumentUtil;
2020

2121
import java.util.Collections;
22-
import java.util.HashMap;
2322
import java.util.Map;
2423
import java.util.concurrent.ConcurrentHashMap;
2524

@@ -41,7 +40,7 @@ public class ShallowTraceBuilder
4140
private volatile Long _pendingNanos;
4241
private volatile Long _endNanos;
4342
private volatile boolean _systemHidden;
44-
private final Map<String,String> _attributes;
43+
private final Map<String,String> _attributes = new ConcurrentHashMap<String, String>();
4544

4645
public ShallowTraceBuilder(final ShallowTrace shallowTrace)
4746
{
@@ -69,7 +68,6 @@ public ShallowTraceBuilder(String name, ResultType resultType)
6968
public ShallowTraceBuilder(ResultType resultType)
7069
{
7170
setResultType(resultType);
72-
_attributes = new ConcurrentHashMap<String, String>();
7371
}
7472

7573
public boolean getHidden()

0 commit comments

Comments
 (0)