Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 592 forks source link

NoHttpResponseException gets logged outside UnirestException #354

Closed TjeerdvanDijk closed 4 years ago

TjeerdvanDijk commented 4 years ago

Describe the bug When a server returns no response, a exception is thrown, you can catch UnirestException but it will still log a error outside of our catch block.

To Reproduce

  1. run a rest server (i used SparkJava)
  2. make it so it can't return anything, (block the application with a interrupt/make it unresoponive).
  3. do a request to the server. I used: Unirest.get(url).connectTimeout(1500).socketTimeout(3000).asString();

Expected behavior The exception is not logged, the UnirestException already contains the exact same message.

Screenshots The NoHttpResponseException error we don't want: link What can be catched using UnirestException: link

Environmental Data: OpenJDK Runtime Environment 18.9 (build 11.0.6+10)

Additional context I'm running my rest server inside of a PaperSpigot minecraft server (with very low specs), it occurs while the server is initializing, so the address is reachable, but the server application unresponsive

ryber commented 4 years ago

It looks like you have logging enabled for the apache library, you would need to disable that logging. This has nothing to do with Unirest wrapping and throwing the exception. I cannot disable this log, only you can

TjeerdvanDijk commented 4 years ago

Hmm, thats strange, i never enabled myself. anyways, the log got removed by doing System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.NoOpLog"); so i should figure out whats enabling it.