AsyncServer blocks in getAllByName
When the application is connected to a router without (working) internet connection, AsyncServer.getAllByName can block for 20s due to unreachable DNS. When this happens it also blocks the selector.wakeupOnce from the AsyncServer.wakeup function. Probably due to the fact that they use the same synchronousWorkers ExecutorService.
I made a workaround where I use a separate executorservice for the DNS resolve and it seems to work. However I cannot completely see the consequences of this change.
Usecase: App connects to a device on the local network directly using it's ip-address. At the same time the app tries to connect to our backend using the hostname. However, the app is connected to a router without internet connection, so the hostname cannot be resolved. This blocks the connection to the device on the local network.
It can also be reproduced by starting an emulator with an unreachable DNS: emulator -avd Nexus_5X_API_24_x86 -dns-server 192.168.1.30 (for example).
I have attached a demo-project to reproduce this issue. If you run this on the emulator with unreachable DNS you can see in the logcat that when you click 'Unresolved' it will block the 'IP Direct' call for 20s. IonLock.zip