alts: remove confusing constant name in InternalCheckGcpEnvironment.java (#7954)

This commit is contained in:
Jiangtao Li 2021-03-10 10:00:44 -08:00 committed by GitHub
parent c8d3cf23e6
commit bb737a2e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 9 deletions

View File

@ -30,25 +30,22 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class for checking if the system is running on Google Cloud Platform (GCP).
* This is intended for usage internal to the gRPC team. If you *really* think you need
* to use this, contact the gRPC team first.
* Class for checking if the system is running on Google Cloud Platform (GCP). This is intended for
* usage internal to the gRPC team. If you *really* think you need to use this, contact the gRPC
* team first.
*/
@Internal
public final class InternalCheckGcpEnvironment {
private static final Logger logger =
Logger.getLogger(InternalCheckGcpEnvironment.class.getName());
private static final String DMI_PRODUCT_NAME = "/sys/class/dmi/id/product_name";
private static final String WINDOWS_COMMAND = "powershell.exe";
private static Boolean cachedResult = null;
// Construct me not!
private InternalCheckGcpEnvironment() {}
/**
* Returns {@code true} if currently running on Google Cloud Platform (GCP).
*/
/** Returns {@code true} if currently running on Google Cloud Platform (GCP). */
public static synchronized boolean isOnGcp() {
if (cachedResult == null) {
cachedResult = isRunningOnGcp();
@ -79,7 +76,8 @@ public final class InternalCheckGcpEnvironment {
try {
if (osName.startsWith("linux")) {
// Checks GCE residency on Linux platform.
return checkProductNameOnLinux(Files.newBufferedReader(Paths.get(DMI_PRODUCT_NAME), UTF_8));
return checkProductNameOnLinux(
Files.newBufferedReader(Paths.get("/sys/class/dmi/id/product_name"), UTF_8));
} else if (osName.startsWith("windows")) {
// Checks GCE residency on Windows platform.
Process p =