Skip to content

Commit bf74790

Browse files
authored
Merge pull request #2897 from guwirth/cobertura-NumberFormatException
fix #2895
2 parents 455bc4f + 72c9ac8 commit bf74790

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/cobertura/CoberturaParser.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ private static void collectFileData(SMInputCursor clazz, CoverageMeasures builde
9595

9696
while (line.getNext() != null) {
9797
var lineId = Integer.parseInt(line.getAttrValue("number"));
98-
var noHits = Long.parseLong(line.getAttrValue("hits"));
99-
if (noHits > Integer.MAX_VALUE) {
100-
LOG.warn("Truncating the actual number of hits ({}) to the maximum number supported by SonarQube ({})",
101-
noHits, Integer.MAX_VALUE);
98+
int noHits;
99+
try {
100+
noHits = Integer.parseInt(line.getAttrValue("hits"));
101+
} catch (NumberFormatException e) {
102+
LOG.warn(
103+
"CoverageParser: Truncating the actual number of hits to the maximum number supported by SonarQube, {}", e
104+
);
102105
noHits = Integer.MAX_VALUE;
103106
}
104107
builder.setHits(lineId, (int) noHits);

0 commit comments

Comments
 (0)