quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.53k stars 2.61k forks source link

In some context, `NoSuchElementException: No line found` error thrown from telemetry #42058

Closed apupier closed 1 month ago

apupier commented 1 month ago

Describe the bug

It can be reproduced when using the devfile from the devfile registry and starting the remote dev

see https://github.com/devfile/api/issues/1611

Expected behavior

no stacktrace

Actual behavior

there is a stacktrace logged:

tools: ----------------------------
tools: --- Help improve Quarkus ---
tools: ----------------------------
tools: * Learn more: https://quarkus.io/usage/
tools: * Do you agree to contribute anonymous build time data to the Quarkus community? (y/n and enter) 
tools: [WARNING] Failed to collect user input for analytics
tools: java.util.NoSuchElementException: No line found
tools:     at java.util.Scanner.nextLine (Scanner.java:1660)
tools:     at io.quarkus.maven.DevMojo.lambda$execute$0 (DevMojo.java:445)
tools:     at io.quarkus.analytics.ConfigService.lambda$userAcceptance$0 (ConfigService.java:79)
tools:     at java.util.concurrent.CompletableFuture$AsyncSupply.run (CompletableFuture.java:1768)
tools:     at java.lang.Thread.run (Thread.java:1583)
tools: [info] [Quarkus build analytics] Didn't receive a valid user's answer: `y` or `n`. The question will be asked again next time.

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

I wasn't able to reproduce with a local build https://github.com/devfile/api/issues/1611#issuecomment-2210420139

geoand commented 1 month ago

cc @brunobat

brunobat commented 1 month ago

This is just a harmless warning it can be avoided altogether by placing the following file: ~/.redhat/io.quarkus.analytics.localconfig with contents:

{"disabled":false}

This way analytics will be on and user input will not be requested, therefore speeding up the application startup.

apupier commented 1 month ago

In the context the error is hit, it is using the ubi (Universal Base Image). I do not think that we should put this kind of file in this image. An alternative would be to provide a specific image for Quarkus devfiles but it sounds a bit overkill just for that.

And if we place it, we must set "disabled": true, the telemetry must be something opt-in.

I think a good solution is to provide a nicer message instead of a stacktrace.

brunobat commented 1 month ago

There was a nicer message: [WARNING] Failed to collect user input for analytics...

quarkus-bot[bot] commented 1 month ago

@maxandersen triage/backport* labels may not be added to an issue. Please add them to the corresponding pull request.

This message is automatically generated by a bot.

maxandersen commented 1 month ago

this should be backported if possbile