mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
When a client disconnected while receiving the icon byte stream response,
an error and a warning were logged, making users worried:
```
2022-08-15 20:09:31.387 [ERROR] [ab.core.ui.icon.internal.IconServlet] - Failed sending the icon byte stream as a response: null
2022-08-15 20:09:31.390 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /icon/autarky
java.lang.IllegalStateException: ABORTED
at org.eclipse.jetty.server.HttpChannelState.sendError(HttpChannelState.java:915) ~[?:?]
...
```
IMO, there is no need to log at ERROR or WARN level in such cases,
so I decided to reduce to DEBUG logging.
The following script can be used to reproduce the above case:
```python
import socket
import struct
host = 'localhost'
port = 8080
path = '/icon/BatteryLevel?format=svg&anyFormat=true&state=94+%25&iconset=classic'
request = f"GET {path} HTTP/1.1\r\nHost: {host}\r\nConnection: keep-alive\r\n\r\n"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
# Send the request
s.sendall(request.encode())
# FORCE an immediate hard reset (RST)
# This ensures the server sees a connection failure while it's inside doGet
s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0))
s.close()
```
Signed-off-by: Florian Hotze <dev@florianhotze.com>