eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
861 stars 784 forks source link

Avoid error logging in HttpUtil #2136

Closed kaikreuzer closed 7 years ago

kaikreuzer commented 7 years ago

My log is full of errors like

14:30:47.400 [ERROR] [lipse.smarthome.io.net.http.HttpUtil] - Fatal transport error: java.util.concurrent.ExecutionException: java.net.SocketTimeoutException: Connect Timeout
14:30:47.400 [ERROR] [lipse.smarthome.io.net.http.HttpUtil] - Fatal transport error: java.util.concurrent.ExecutionException: java.net.SocketTimeoutException: Connect Timeout

This is due to the fact that the AVM Fritz binding is using HttpUtil for accessing the device and the device is not reachable (which is expected, because I am in a different network) - this should result in the Thing being OFFLINE, but not in a log cluttered with errors.

I would suggest to change the methods in HttpUtil to only log debug at max, but additionally to throw IOExceptions, so that the caller actually has a chance to notice that his call wasn't successfully executed.

The main reason that this wasn't done in the past is that org.eclipse.smarthome.model.script.actions.HTTP uses these methods and must not throw an exception (because it could not be handled within the scripts/rules). So this HTTP class should actually catch the IOExceptions and log an error instead.

@svilenvul As you were working on HttpUtil in the past, would you be willing to implement this change (and check that the callers can deal with the newly introduced IOException)?

svilenvul commented 7 years ago

yes, I can do it

svilenvul commented 7 years ago

Additional PR will be opened for the openhab2-addons bundle that are affected as well:

I will make a sample exception handling in the PR, but I guess the developers that implemented the bindings will take a look, if it is ok as well.