Skip to content

Commit e311be7

Browse files
lbergelsonchingor13
authored andcommitted
Improve log output when detecting GCE (#214)
Improving the log output when unexpected exceptions occur while determining if the client is running on Google Compute Engine. Moving the stacktrace to be FINE output since stacktraces are alarming. Making the INFO level log message occur only once instead of potentially many times. Further improvements to #199 and #198
1 parent 24164bf commit e311be7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

oauth2_http/java/com/google/auth/oauth2/ComputeEngineCredentials.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@ static boolean runningOnComputeEngine(
222222
} catch (SocketTimeoutException expected) {
223223
// Ignore logging timeouts which is the expected failure mode in non GCE environments.
224224
} catch (IOException e) {
225-
LOGGER.log(
226-
Level.INFO, "Failed to detect whether we are running on Google Compute Engine.", e);
225+
LOGGER.log(Level.FINE, "Encountered an unexpected exception when determining" +
226+
" if we are running on Google Compute Engine.", e);
227227
}
228228
}
229+
LOGGER.log(Level.INFO, "Failed to detect whether we are running on Google Compute Engine.");
229230
return false;
230231
}
231232

0 commit comments

Comments
 (0)