Skip to content

Commit 9e0a501

Browse files
committed
checkstyle
Signed-off-by: Antoine Toulme <[email protected]>
1 parent 46ba7eb commit 9e0a501

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/DefaultTracesProvider.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
*/
66
package org.hyperledger.fabric.traces.impl;
77

8-
import io.opentelemetry.api.trace.Span;
9-
import io.opentelemetry.api.trace.Tracer;
10-
import org.hyperledger.fabric.shim.ChaincodeStub;
118
import org.hyperledger.fabric.traces.TracesProvider;
129

1310
public final class DefaultTracesProvider implements TracesProvider {

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryProperties.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@
1010

1111
import javax.annotation.Nullable;
1212
import java.time.Duration;
13-
import java.util.*;
13+
import java.util.AbstractMap;
14+
import java.util.Arrays;
15+
import java.util.Collections;
16+
import java.util.HashMap;
17+
import java.util.LinkedHashMap;
18+
import java.util.List;
19+
import java.util.Locale;
20+
import java.util.Map;
21+
import java.util.Properties;
1422
import java.util.concurrent.TimeUnit;
1523
import java.util.stream.Collectors;
1624

17-
public final class OpenTelemetryProperties implements ConfigProperties {
25+
final class OpenTelemetryProperties implements ConfigProperties {
1826
private final Map<String, String> config;
1927

20-
public OpenTelemetryProperties(Properties props) {
28+
OpenTelemetryProperties(final Properties props) {
2129
Map<String, String> config = new HashMap<>();
2230
System.getenv().forEach(
2331
(name, value) -> config.put(name.toLowerCase(Locale.ROOT).replace('_', '.'), value));
@@ -32,13 +40,13 @@ public OpenTelemetryProperties(Properties props) {
3240

3341
@Override
3442
@Nullable
35-
public String getString(String name) {
43+
public String getString(final String name) {
3644
return config.get(name);
3745
}
3846

3947
@Override
4048
@Nullable
41-
public Boolean getBoolean(String name) {
49+
public Boolean getBoolean(final String name) {
4250
String value = config.get(name);
4351
if (value == null || value.isEmpty()) {
4452
return null;
@@ -49,7 +57,7 @@ public Boolean getBoolean(String name) {
4957
@Override
5058
@Nullable
5159
@SuppressWarnings("UnusedException")
52-
public Integer getInt(String name) {
60+
public Integer getInt(final String name) {
5361
String value = config.get(name);
5462
if (value == null || value.isEmpty()) {
5563
return null;
@@ -64,7 +72,7 @@ public Integer getInt(String name) {
6472
@Override
6573
@Nullable
6674
@SuppressWarnings("UnusedException")
67-
public Long getLong(String name) {
75+
public Long getLong(final String name) {
6876
String value = config.get(name);
6977
if (value == null || value.isEmpty()) {
7078
return null;
@@ -79,7 +87,7 @@ public Long getLong(String name) {
7987
@Override
8088
@Nullable
8189
@SuppressWarnings("UnusedException")
82-
public Double getDouble(String name) {
90+
public Double getDouble(final String name) {
8391
String value = config.get(name);
8492
if (value == null || value.isEmpty()) {
8593
return null;
@@ -94,14 +102,12 @@ public Double getDouble(String name) {
94102
@Override
95103
@Nullable
96104
@SuppressWarnings("UnusedException")
97-
public Duration getDuration(String name) {
105+
public Duration getDuration(final String name) {
98106
String value = config.get(name);
99107
if (value == null || value.isEmpty()) {
100108
return null;
101109
}
102110
String unitString = getUnitString(value);
103-
// TODO: Environment variables have unknown encoding. `trim()` may cut codepoints oddly
104-
// but likely we'll fail for malformed unit string either way.
105111
String numberString = value.substring(0, value.length() - unitString.length());
106112
try {
107113
long rawNumber = Long.parseLong(numberString.trim());
@@ -122,7 +128,7 @@ public Duration getDuration(String name) {
122128
}
123129

124130
@Override
125-
public List<String> getList(String name) {
131+
public List<String> getList(final String name) {
126132
String value = config.get(name);
127133
if (value == null) {
128134
return Collections.emptyList();
@@ -131,7 +137,7 @@ public List<String> getList(String name) {
131137
}
132138

133139
@Override
134-
public Map<String, String> getMap(String name) {
140+
public Map<String, String> getMap(final String name) {
135141
return getList(name).stream()
136142
.map(keyValuePair -> filterBlanksAndNulls(keyValuePair.split("=", 2)))
137143
.map(
@@ -151,12 +157,12 @@ public Map<String, String> getMap(String name) {
151157
}
152158

153159
private static ConfigurationException newInvalidPropertyException(
154-
String name, String value, String type) {
160+
final String name, final String value, final String type) {
155161
throw new ConfigurationException(
156162
"Invalid value for property " + name + "=" + value + ". Must be a " + type + ".");
157163
}
158164

159-
private static List<String> filterBlanksAndNulls(String[] values) {
165+
private static List<String> filterBlanksAndNulls(final String[] values) {
160166
return Arrays.stream(values)
161167
.map(String::trim)
162168
.filter(s -> !s.isEmpty())
@@ -165,8 +171,10 @@ private static List<String> filterBlanksAndNulls(String[] values) {
165171

166172
/**
167173
* Returns the TimeUnit associated with a unit string. Defaults to milliseconds.
174+
* @param unitString the time unit as a string
175+
* @return the parsed TimeUnit
168176
*/
169-
private static TimeUnit getDurationUnit(String unitString) {
177+
private static TimeUnit getDurationUnit(final String unitString) {
170178
switch (unitString) {
171179
case "": // Fallthrough expected
172180
case "ms":
@@ -188,8 +196,10 @@ private static TimeUnit getDurationUnit(String unitString) {
188196
* Fragments the 'units' portion of a config value from the 'value' portion.
189197
*
190198
* <p>E.g. "1ms" would return the string "ms".
199+
* @param rawValue the raw value of a unit and value
200+
* @return the unit string
191201
*/
192-
private static String getUnitString(String rawValue) {
202+
private static String getUnitString(final String rawValue) {
193203
int lastDigitIndex = rawValue.length() - 1;
194204
while (lastDigitIndex >= 0) {
195205
char c = rawValue.charAt(lastDigitIndex);

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.hyperledger.fabric.shim.ChaincodeStub;
1818
import org.hyperledger.fabric.traces.TracesProvider;
1919

20-
import java.util.*;
20+
import java.util.Properties;
2121

2222
public final class OpenTelemetryTracesProvider implements TracesProvider {
2323

fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProviderTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.hyperledger.fabric.traces.impl;
77

88
import com.google.common.io.Closer;
9-
import com.google.protobuf.ByteString;
109
import io.grpc.ManagedChannelBuilder;
1110
import io.grpc.Server;
1211
import io.grpc.ServerCall;
@@ -23,7 +22,6 @@
2322
import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc;
2423
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
2524
import io.opentelemetry.proto.trace.v1.ResourceSpans;
26-
import org.hyperledger.fabric.Logging;
2725
import org.hyperledger.fabric.contract.ChaincodeStubNaiveImpl;
2826
import org.hyperledger.fabric.metrics.Metrics;
2927
import org.hyperledger.fabric.protos.peer.Chaincode;

0 commit comments

Comments
 (0)