Maybe adding this check can fix the issue (at least the null pointer exception) for LWJGL3. Not sure if it will recognise it after re-connect so.
if (!glfwJoystickPresent(entry.getKey())) {
continue;
}
after this line
Searching google, it seems there is not a controller listener for connect/disconnect in LWJGL3/GLFW.