Skip to content

Commit 8ef626b

Browse files
committed
Fix bug with incorrect usage of Integer where Long is expected.
Metrics returned from the server can overflow Integer e.g. when elapsed time is higher than 2 seconds (it's in nanoseconds).
1 parent b2692a3 commit 8ef626b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/ProcessParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ public class ProcessParser {
2222
};
2323

2424
public static void parseSummary(String text, OperationMetrics metrics) {
25-
Map<String, Integer> map = parse(text == null ? "{}" : text);
25+
Map<String, Long> map = parse(text == null ? "{}" : text);
2626

2727
for (ServerMetrics m : ServerMetrics.values()) {
2828
metrics.updateMetric(m, -1);
2929
}
3030

3131
for (int i = 0; i < SUMMARY_FIELDS.length; i++) {
3232
String field = SUMMARY_FIELDS[i];
33-
Integer value = map.get(field);
33+
Long value = map.get(field);
3434
if (value != null) {
3535
metrics.updateMetric(SUMMARY_METRICS[i], value);
3636
}
3737
}
3838
}
3939

4040

41-
public static Map<String, Integer> parse(String json) {
41+
public static Map<String, Long> parse(String json) {
4242
if (json == null) {
4343
throw new IllegalArgumentException("json is null");
4444
}
@@ -50,7 +50,7 @@ public static Map<String, Integer> parse(String json) {
5050
throw new IllegalArgumentException("JSON must start with '{' and end with '}'");
5151
}
5252

53-
Map<String, Integer> result = new HashMap<>();
53+
Map<String, Long> result = new HashMap<>();
5454

5555
String content = json.substring(1, json.length() - 1).trim();
5656
if (content.isEmpty()) {
@@ -79,7 +79,7 @@ public static Map<String, Integer> parse(String json) {
7979
}
8080

8181
try {
82-
int value = Integer.parseInt(valueStr);
82+
long value = Long.parseLong(valueStr);
8383
result.put(key, value);
8484
} catch (NumberFormatException e) {
8585
// ignore error

0 commit comments

Comments
 (0)