dash-licenses icon indicating copy to clipboard operation
dash-licenses copied to clipboard

Add log output in case of RuntimeException

Open calohmn opened this issue 2 years ago • 2 comments

I just ran the dash license tool CLI (using parameters -Dorg.eclipse.dash.timeout=60 and -batch 90) and was surprised to see that the tool just exited at some point, with no error log output:

[...]
[main] INFO Querying ClearlyDefined for license data for 90 items.
[...]
[main] DEBUG Sending: maven/mavencentral/io.quarkus/quarkus-bootstrap-runner/3.2.6.Final
[main] DEBUG Sending: maven/mavencentral/io.quarkus/quarkus-caffeine/3.2.6.Final

Adding log output in the catch (RuntimeException e) block in the Main class revealed the error:

java.lang.RuntimeException: java.net.http.HttpTimeoutException: request timed out
	at org.eclipse.dash.licenses.http.HttpClientService.post(HttpClientService.java:75)
	at org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedSupport.doQueryClearlyDefined(ClearlyDefinedSupport.java:141)
	at org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedSupport.queryClearlyDefined(ClearlyDefinedSupport.java:123)
	at org.eclipse.dash.licenses.clearlydefined.ClearlyDefinedSupport.queryLicenseData(ClearlyDefinedSupport.java:102)
	at org.eclipse.dash.licenses.LicenseChecker.lambda$getLicenseData$3(LicenseChecker.java:52)
	at org.eclipse.dash.licenses.util.Batchifier.batchify(Batchifier.java:77)
	at org.eclipse.dash.licenses.LicenseChecker.getLicenseData(LicenseChecker.java:57)
	at org.eclipse.dash.licenses.cli.Main.lambda$main$5(Main.java:126)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at org.eclipse.dash.licenses.cli.Main.main(Main.java:107)
Caused by: java.net.http.HttpTimeoutException: request timed out
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:571)
	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:123)
	at org.eclipse.dash.licenses.http.HttpClientService.post(HttpClientService.java:63)
	... 10 more

It would be helpful to have error log output in all such INTERNAL_ERROR cases, specifically also in case of HTTP request timeouts (a hint about the org.eclipse.dash.timeout property could be added there as well).

calohmn avatar Oct 03 '23 09:10 calohmn

I've deferred doing very much proper exception handling. Clearly we need to do better.

But this seems like an obvious incremental improvement. We should at least show the stack trace while using DEBUG level logging.

I'll see what I can do.

waynebeaton avatar Dec 07 '23 15:12 waynebeaton

I've pushed a fix that should appear shortly in the 1.1.1-SNAPSHOT.

waynebeaton avatar Dec 07 '23 18:12 waynebeaton