Added a guard which prevents a non-fatal exception from being output to
the console when running the Java tests via gradle.