Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS-549] Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615" #472

Closed
jasonm23 opened this issue Sep 4, 2023 · 8 comments · Fixed by #473
Labels
jira-issue Issue tracked on JIRA

Comments

@jasonm23
Copy link
Contributor

jasonm23 commented Sep 4, 2023

Expected Behavior

Parsing of coverage.lcov report.

bash <(curl -Ls https://coverage.codacy.com/get.sh) \
report \
--coverage-reports coverage.lcov \
--language swift \
--project-token $CODACY_PROJECT_TOKEN

RipGrep shows the number which breaks the reporter.

rg "18446744073709551615" coverage.lcov
2954:DA:36,18446744073709551615
2955:DA:37,18446744073709551615
2978:DA:66,18446744073709551615
2979:DA:67,18446744073709551615

Actual Behavior

Error stacktrace:

java.lang.NumberFormatException

Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615"
        at [email protected]/java.lang.Long.parseLong(Long.java:692)
        at [email protected]/java.lang.Long.parseLong(Long.java:817)
        at scala.collection.immutable.StringLike.toLong(StringLike.scala:309)
        at scala.collection.immutable.StringLike.toLong$(StringLike.scala:309)
        at scala.collection.immutable.StringOps.toLong(StringOps.scala:33)
        at com.codacy.parsers.util.MathUtils$ParseIntOps$.toIntOrMaxValue$extension(MathUtils.scala:12)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$5(LCOVParser.scala:45)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$5$adapted(LCOVParser.scala:45)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:273)
        at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
        at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
        at scala.collection.TraversableLike.map(TraversableLike.scala:273)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:266)
        at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:198)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$2(LCOVParser.scala:45)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parseLines$1(LCOVParser.scala:37)
        at scala.collection.TraversableOnce$folder$1$.apply(TraversableOnce.scala:187)
        at scala.collection.TraversableOnce$folder$1$.apply(TraversableOnce.scala:185)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:189)
        at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:184)
        at scala.collection.AbstractIterator.foldLeft(Iterator.scala:1431)
        at com.codacy.parsers.implementation.LCOVParser$.parseLines(LCOVParser.scala:36)
        at com.codacy.parsers.implementation.LCOVParser$.$anonfun$parse$3(LCOVParser.scala:30)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.parsers.implementation.LCOVParser$.parse(LCOVParser.scala:30)
        at com.codacy.parsers.CoverageParser$ParsedCoverage$1$.unapply(CoverageParser.scala:53)
        at com.codacy.parsers.CoverageParser$$anonfun$parse$4.applyOrElse(CoverageParser.scala:62)
        at com.codacy.parsers.CoverageParser$$anonfun$parse$4.applyOrElse(CoverageParser.scala:61)
        at scala.collection.TraversableOnce.collectFirst(TraversableOnce.scala:172)
        at scala.collection.TraversableOnce.collectFirst$(TraversableOnce.scala:159)
        at scala.collection.SeqLike$$anon$2.collectFirst(SeqLike.scala:682)
        at com.codacy.parsers.CoverageParser$.parse(CoverageParser.scala:61)
        at com.codacy.rules.ReportRules.$anonfun$sendFilesReportForCommit$2(ReportRules.scala:40)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.$anonfun$sendFilesReportForCommit$1(ReportRules.scala:39)
        at scala.collection.immutable.List.map(List.scala:286)
        at com.codacy.rules.ReportRules.sendFilesReportForCommit(ReportRules.scala:36)
        at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$2(ReportRules.scala:76)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$1(ReportRules.scala:68)
        at com.codacy.rules.ReportRules.$anonfun$withCommitUUID$4(ReportRules.scala:365)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.rules.ReportRules.withCommitUUID(ReportRules.scala:365)
        at com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:63)
        at com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:59)
        at com.codacy.CodacyCoverageReporter$.$anonfun$sendReport$1(CodacyCoverageReporter.scala:43)
        at scala.util.Either.flatMap(Either.scala:341)
        at com.codacy.CodacyCoverageReporter$.sendReport(CodacyCoverageReporter.scala:34)
        at com.codacy.CodacyCoverageReporter$.run(CodacyCoverageReporter.scala:19)
        at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:15)
        at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:13)
        at caseapp.CommandAppWithPreCommand.$anonfun$main$1(CommandAppWithPreCommand.scala:97)
        at caseapp.CommandAppWithPreCommand.$anonfun$main$1$adapted(CommandAppWithPreCommand.scala:82)
        at scala.Option.foreach(Option.scala:407)
        at caseapp.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:82)
        at com.codacy.CodacyCoverageReporter.main(CodacyCoverageReporter.scala)

Reproducible Test Case

I assume parsing a report containing an Int value larger n will throw the error.

@github-actions github-actions bot added the jira-issue Issue tracked on JIRA label Sep 4, 2023
@github-actions github-actions bot changed the title Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615" [TS-549] Exception in thread "main" java.lang.NumberFormatException: For input string: "18446744073709551615" Sep 4, 2023
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Internal ticket created : TS-549

@jasonm23
Copy link
Contributor Author

jasonm23 commented Sep 4, 2023

Seems to be an issue in

MathUtils.ParseIntOps.toIntOrMaxValue

Use of toLong will only handle 64bit (max ≤19 digits), time for BigInteger?

@jasonm23
Copy link
Contributor Author

jasonm23 commented Sep 4, 2023

#473 should fix this.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Sep 4, 2023

Currently working around this by replacing > 2,147,483,647 with 2,147,483,647 in coverage.lcov

jasonm23 added a commit to cutbox/CutBox that referenced this issue Sep 4, 2023
@stefanvacareanu7
Copy link
Contributor

Hi Jason,

Thanks for reaching our community!

While the fix you proposed is good for the tool itself, we are passing that information to other internal components and it requires other changes as well.

I am passing the internal ticket to the corresponding team. Keep in mind that this is a low priority for now.

Best,
Stefan

@jasonm23
Copy link
Contributor Author

jasonm23 commented Oct 5, 2023

we are passing that information to other internal components and it requires other changes as well.

Such as?

You have components that want an int overflow?

Facepalm moment

@lolgab
Copy link
Contributor

lolgab commented Nov 7, 2023

@jasonm23 Clearly there was some misunderstanding of the problem on our side.
I answered in your PR thread. I used your PR as the starting point to fix the problem and to fix a bug that comes out when you handle such big numbers (you can't sum as easily as before, since you have overflows).
I also added a test case.
I will merge #479 (which contains your commit as well) when the CI is green.

@jasonm23
Copy link
Contributor Author

jasonm23 commented Nov 8, 2023

Great to hear. Looking forward to the fix shipping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-issue Issue tracked on JIRA
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants