Avoid null pointer exceptions when calling getCapabilities by etanol · Pull Request #1094 · appium/java-client
getCapabilities will be null until the response of the new session request, where the real capabilities are returned by the server.
As I mentioned in the description, if the new session command fails (which can be pretty often when you are trying to set up the proper version combination of Appium, Automation and device), this NullPointerException masks the real failure (with no exception nesting).
So, overall, this makes the initial set up incredibly frustrating.
The idea of this change is to avoid NPEs altogether.