SONARJAVA-303 Fix a NPE and IllegalArgumentException