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

NumberFormatException when running coverageReport or coverageAggregated #476

Open
tomsfernandez opened this issue Jun 8, 2022 · 10 comments
Labels

Comments

@tomsfernandez
Copy link

tomsfernandez commented Jun 8, 2022

Hi! I'm getting the following error when using either coverageReport or coverageAggregated. The error doesn't happen 100% of the time I don't know why. Can you help me out please?

[error] java.lang.NumberFormatException: For input string: "2849015114"
[error] 	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
[error] 	at java.base/java.lang.Integer.parseInt(Integer.java:652)
[error] 	at java.base/java.lang.Integer.parseInt(Integer.java:770)
[error] 	at scala.collection.immutable.StringLike.toInt(StringLike.scala:304)
[error] 	at scala.collection.immutable.StringLike.toInt$(StringLike.scala:304)
[error] 	at scala.collection.immutable.StringOps.toInt(StringOps.scala:33)
[error] 	at scoverage.IOUtils$.$anonfun$invoked$2(IOUtils.scala:80)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:943)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error] 	at scoverage.IOUtils$.$anonfun$invoked$1(IOUtils.scala:78)
[error] 	at scoverage.IOUtils$.$anonfun$invoked$1$adapted(IOUtils.scala:76)
[error] 	at scala.collection.Iterator.foreach(Iterator.scala:943)
[error] 	at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error] 	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error] 	at scoverage.IOUtils$.invoked(IOUtils.scala:76)
[error] 	at scoverage.report.CoverageAggregator$.$anonfun$aggregatedCoverage$1(CoverageAggregator.scala:31)
[error] 	at scoverage.report.CoverageAggregator$.$anonfun$aggregatedCoverage$1$adapted(CoverageAggregator.scala:26)
[error] 	at scala.collection.immutable.List.foreach(List.scala:431)
[error] 	at scoverage.report.CoverageAggregator$.aggregatedCoverage(CoverageAggregator.scala:26)
[error] 	at scoverage.report.CoverageAggregator$.aggregate(CoverageAggregator.scala:17)
[error] 	at scoverage.ScoverageSbtPlugin$.$anonfun$coverageAggregate0$3(ScoverageSbtPlugin.scala:136)
[error] 	at scoverage.ScoverageSbtPlugin$.$anonfun$coverageAggregate0$3$adapted(ScoverageSbtPlugin.scala:131)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:829)
@ckipp01
Copy link
Member

ckipp01 commented Jun 26, 2022

Thanks for reporting @tomsfernandez. The issue is that scoverage tries to call .toInt on this and 2849015114 is too large for an Int. I'm surprised the number went this high. Is this a large code base you're working with? I'll go ahead and transfer this over to the main scoverage repo as the issue will actually need to be fixed there.

@ckipp01 ckipp01 transferred this issue from scoverage/sbt-scoverage Jun 26, 2022
@ckipp01 ckipp01 added the bug label Jun 26, 2022
@tomsfernandez
Copy link
Author

Hi @ckipp01 sorry for taking so long to answer I never saw the notification. I really dont know if our codebase is considered big. The repository in question is www.github.com/aml-org/amf.

@tomsfernandez
Copy link
Author

I checked our latest CI runs and it appears this happens only sometimes (flaky) 😢 so I guess it will be difficult to replicate or at least to fix the "root" issue.

@jdbxwyx
Copy link

jdbxwyx commented Feb 13, 2023

I encountered the same issue when trying to build a coverage pipeline for my team.
I managed to run UT, generated UT report, build a binary for regression coverage, collect regression coverage result and generate RT report. But we trying to merge UT and RT result, we encountered this problem.

[2023-02-13T08:50:39.656Z] [info] Waiting for measurement data to sync... [2023-02-13T08:50:41.019Z] [info] Reading scoverage instrumentation [/ads-forecast/common/src/forecast/spark_planner/target/scala-2.12/scoverage-data/scoverage.coverage.xml] [2023-02-13T08:50:41.580Z] [info] Reading scoverage measurements... [2023-02-13T08:50:41.580Z] [error] java.lang.NumberFormatException: For input string: "1326 " [2023-02-13T08:50:41.580Z] [error] at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [2023-02-13T08:50:41.580Z] [error] at java.lang.Integer.parseInt(Integer.java:580) [2023-02-13T08:50:41.580Z] [error] at java.lang.Integer.parseInt(Integer.java:615) [2023-02-13T08:50:41.580Z] [error] at scala.collection.immutable.StringLike.toInt(StringLike.scala:304) [2023-02-13T08:50:41.580Z] [error] at scala.collection.immutable.StringLike.toInt$(StringLike.scala:304) [2023-02-13T08:50:41.580Z] [error] at scala.collection.immutable.StringOps.toInt(StringOps.scala:33) [2023-02-13T08:50:41.580Z] [error] at scoverage.IOUtils$.$anonfun$invoked$2(IOUtils.scala:77) [2023-02-13T08:50:41.580Z] [error] at scala.collection.Iterator.foreach(Iterator.scala:941) [2023-02-13T08:50:41.580Z] [error] at scala.collection.Iterator.foreach$(Iterator.scala:941) [2023-02-13T08:50:41.580Z] [error] at scala.collection.AbstractIterator.foreach(Iterator.scala:1429) [2023-02-13T08:50:41.580Z] [error] at scoverage.IOUtils$.$anonfun$invoked$1(IOUtils.scala:75) [2023-02-13T08:50:41.580Z] [error] at scoverage.IOUtils$.$anonfun$invoked$1$adapted(IOUtils.scala:73) [2023-02-13T08:50:41.580Z] [error] at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36) [2023-02-13T08:50:41.580Z] [error] at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33) [2023-02-13T08:50:41.580Z] [error] at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38) [2023-02-13T08:50:41.580Z] [error] at scoverage.IOUtils$.invoked(IOUtils.scala:73) [2023-02-13T08:50:41.580Z] [error] at scoverage.ScoverageSbtPlugin$.loadCoverage(ScoverageSbtPlugin.scala:236) [2023-02-13T08:50:41.580Z] [error] at scoverage.ScoverageSbtPlugin$.$anonfun$coverageReport0$1(ScoverageSbtPlugin.scala:112) [2023-02-13T08:50:41.580Z] [error] at scoverage.ScoverageSbtPlugin$.$anonfun$coverageReport0$1$adapted(ScoverageSbtPlugin.scala:105) [2023-02-13T08:50:41.580Z] [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [2023-02-13T08:50:41.580Z] [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [2023-02-13T08:50:41.580Z] [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [2023-02-13T08:50:41.580Z] [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [2023-02-13T08:50:41.580Z] [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [2023-02-13T08:50:41.580Z] [error] at sbt.Execute.work(Execute.scala:290) [2023-02-13T08:50:41.580Z] [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [2023-02-13T08:50:41.580Z] [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178) [2023-02-13T08:50:41.580Z] [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37) [2023-02-13T08:50:41.580Z] [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [2023-02-13T08:50:41.580Z] [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [2023-02-13T08:50:41.580Z] [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [2023-02-13T08:50:41.580Z] [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [2023-02-13T08:50:41.580Z] [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [2023-02-13T08:50:41.580Z] [error] at java.lang.Thread.run(Thread.java:748) [2023-02-13T08:50:41.580Z] [error] (coverageReport) java.lang.NumberFormatException: For input string: "1326 " [2023-02-13T08:50:41.580Z] [error] Total time: 2 s, completed Feb 13, 2023 8:50:41 AM [2023-02-13T08:50:41.580Z] ls: cannot access target/scala-2.12/scoverage-report/*: No such file or directory

@ckipp01
Copy link
Member

ckipp01 commented Feb 13, 2023

Hey @jdbxwyx, thanks for the report. Do you have a reproduction that you could point to or provide?

@jdbxwyx
Copy link

jdbxwyx commented Feb 13, 2023

Hey @jdbxwyx, thanks for the report. Do you have a reproduction that you could point to or provide?

I have to check if the policy of our company allows it.

@jdbxwyx
Copy link

jdbxwyx commented Feb 14, 2023

I cannot show you the measurements and XML files due to company policy. Will it help if I should you the sbt commands we used?
FYI: #19

@jdbxwyx
Copy link

jdbxwyx commented Feb 14, 2023

1. Some preparations:

sed -i '$a\addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6")' project/plugins.sbt
sed -i '$a\addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6")' project/assembly.sbt
sed -i '$a\coverageEnabled := true' build.sbt
sed -i '$a\coverageExcludedPackages := "xxxxxxx"' build.sbt
sed -i '$a\scoverage-plugins: https://repo1.maven.org/maven2/'  /root/.sbt/repositories
sed -i '$a\sbt-buildinfo-plugins: https://scala.jfrog.io/artifactory/sbt-plugin-releases/ , [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]' /root/.sbt/repositories

2. Build for regression test:

export SBT_OPTS="-Xms1024M -Xmx4G -Xss2M -XX:MaxMetaspaceSize=2G -Dfile.encoding=utf-8"
echo "##### Start to build repo #######"
cd "xxx/spark_repo"
sbt publishLocal
echo "##### Start to build consumer #########"
cd "xxx/spark_ack_ratio_consumer"
sbt publishLocal
echo "##### Start to build application ########"
cd "xxx/${component}/"
sbt 'set test in assembly := {}' 'set coverageDataDir := file("xxx/regression/coverage/")' clean coverage assembly -mem 2048
#upload code and jar to arti
#xxx

3. UT

export SBT_OPTS="-Xms1024M -Xmx4G -Xss2M -XX:MaxMetaspaceSize=2G -Dfile.encoding=utf-8"
echo "##### Start to build repo #######"
cd "xxx/spark_repo"
sbt publishLocal
echo "##### Start to build consumer #########"
cd "xxx/spark_ack_ratio_consumer"
sbt publishLocal
echo "########start to build UT #######################"
cd "xxx/${component}"
sbt clean
sbt coverage test coverageAggregate -mem 2048 > fail.txt 2>&1
#upload UT code to arti
#upload UT coverage data

4. For RT report

echo "##### Start to build repo #######"
cd "xxx/spark_repo"
sbt publishLocal
echo "##### Start to build consumer #########"
cd "xxx/spark_ack_ratio_consumer"
sbt publishLocal
#Get RT coverage data(measurements generated in regression and uploaded to arti) and code
wget_coverage_data
wget_coverage_code
cp xxx/scoverage-data/scoverage.coverage.xml xxx/scoverage-data/

sbt coverageReport -mem 2048
#upload UT coverage data

5. Merge UT and RT

export SBT_OPTS="-Xms1024M -Xmx4G -Xss2M -XX:MaxMetaspaceSize=2G -Dfile.encoding=utf-8"
echo "##### Start to build repo #######"
cd "xxx/spark_repo"
sbt publishLocal
echo "##### Start to build consumer #########"
cd "xxx/spark_ack_ratio_consumer"
sbt publishLocal
#Get RT coverage data(measurements generated in regression and uploaded to arti) and code
echo "########sync coverage from regression ############"
wget_coverage_data

sbt coverageReport -mem 2048

@jdbxwyx
Copy link

jdbxwyx commented Feb 14, 2023

By the way, I got something like this if I ls in our job. I don't know why the name pattern and different, will it cause the bug?

[2023-02-13T08:50:27.219Z] scoverage.coverage.xml
[2023-02-13T08:50:27.219Z] scoverage.measurements.1265
[2023-02-13T08:50:27.219Z] scoverage.measurements.1266
[2023-02-13T08:50:27.219Z] scoverage.measurements.1267
[2023-02-13T08:50:27.219Z] scoverage.measurements.1268
[2023-02-13T08:50:27.219Z] scoverage.measurements.1270
[2023-02-13T08:50:27.219Z] scoverage.measurements.1271
[2023-02-13T08:50:27.219Z] scoverage.measurements.45783b50-ed20-4825-bccf-a54f63435424.285
[2023-02-13T08:50:27.219Z] scoverage.measurements.45783b50-ed20-4825-bccf-a54f63435424.286
[2023-02-13T08:50:27.219Z] scoverage.measurements.45783b50-ed20-4825-bccf-a54f63435424.287
[2023-02-13T08:50:27.219Z] scoverage.measurements.45783b50-ed20-4825-bccf-a54f63435424.288
[2023-02-13T08:50:27.219Z] scoverage.measurements.783
[2023-02-13T08:50:27.219Z] scoverage.measurements.841
[2023-02-13T08:50:27.219Z] scoverage.measurements.889
[2023-02-13T08:50:27.219Z] scoverage.measurements.895
[2023-02-13T08:50:27.219Z] scoverage.measurements.896
[2023-02-13T08:50:27.219Z] scoverage.measurements.898
[2023-02-13T08:50:27.219Z] scoverage.measurements.899

@gheine
Copy link

gheine commented May 7, 2024

We're seeing a similar error occasionally/randomly on coverageAggregate, where it seems to try to cast a partial path String to Int:

+ sbt coverageAggregate
[info] welcome to sbt 1.9.9 (Eclipse Adoptium Java 17.0.11)
[info] loading settings for project flowcommerce_label_pr-2139-build from plugins.sbt ...
[info] loading project definition from /home/jenkins/workspace/flowcommerce_label_PR-2139/project
[info] loading settings for project flowcommerce_label_pr-2139 from build.sbt ...
[info] set current project to label (in build file:/home/jenkins/workspace/flowcommerce_label_PR-2139/)
[info] Aggregating coverage from subprojects...
[info] Found 5 subproject scoverage data directories [target/scala-2.13/scoverage-data,target/scala-2.13/scoverage-data,/home/jenkins/workspace/flowcommerce_label_PR-2139/target/scala-2.13/scoverage-data,target/scala-2.13/scoverage-data,target/scala-2.13/scoverage-data]
[error] java.lang.NumberFormatException: For input string: "arget/scala-2.13/routes/main/label/Routes.scala"
[error] 	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
[error] 	at java.base/java.lang.Integer.parseInt(Integer.java:654)
[error] 	at java.base/java.lang.Integer.parseInt(Integer.java:786)
[error] 	at scala.collection.immutable.StringLike.toInt(StringLike.scala:310)
[error] 	at scala.collection.immutable.StringLike.toInt$(StringLike.scala:310)
[error] 	at scala.collection.immutable.StringOps.toInt(StringOps.scala:33)
[error] 	at scoverage.serialize.Serializer$.toStatement$1(Serializer.scala:130)
[error] 	at scoverage.serialize.Serializer$.deserialize(Serializer.scala:179)
[error] 	at scoverage.serialize.Serializer$.deserialize(Serializer.scala:117)
[error] 	at scoverage.reporter.CoverageAggregator$.$anonfun$aggregatedCoverage$1(CoverageAggregator.scala:35)
[error] 	at scoverage.reporter.CoverageAggregator$.$anonfun$aggregatedCoverage$1$adapted(CoverageAggregator.scala:31)
[error] 	at scala.collection.immutable.List.foreach(List.scala:431)
[error] 	at scoverage.reporter.CoverageAggregator$.aggregatedCoverage(CoverageAggregator.scala:31)
[error] 	at scoverage.reporter.CoverageAggregator$.aggregate(CoverageAggregator.scala:22)
[error] 	at scoverage.ScoverageSbtPlugin$.$anonfun$coverageAggregate0$3(ScoverageSbtPlugin.scala:257)
[error] 	at scoverage.ScoverageSbtPlugin$.$anonfun$coverageAggregate0$3$adapted(ScoverageSbtPlugin.scala:247)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] 	at sbt.Execute.work(Execute.scala:292)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] 	at java.base/java.lang.Thread.run(Thread.java:840)
[error] (coverageAggregate) java.lang.NumberFormatException: For input string: "arget/scala-2.13/routes/main/label/Routes.scala"
[error] Total time: 1 s, completed May 7, 2024, 4:14:04 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants