apache/hadoop · error · UnsupportedOperationException
Could not determine OS
Error message
Could not determine OS
What it means
SysInfo.newInstance() is a platform factory: it returns SysInfoLinux when Shell.LINUX is true and SysInfoWindows when Shell.WINDOWS is true, both determined from the os.name system property. On any other operating system (macOS, Solaris, AIX, BSD) both flags are false and it throws UnsupportedOperationException. There is no generic fallback implementation, because the class reads OS-specific proc files or Windows performance counters.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/SysInfo.java:43
* Plugin to calculate resource information on the system.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public abstract class SysInfo {
/**
* Return default OS instance.
* @throws UnsupportedOperationException If cannot determine OS.
* @return Default instance for the detected OS.
*/
public static SysInfo newInstance() {
if (Shell.LINUX) {
return new SysInfoLinux();
}
if (Shell.WINDOWS) {
return new SysInfoWindows();
}
throw new UnsupportedOperationException("Could not determine OS");
}
/**
* Obtain the total size of the virtual memory present in the system.
*
* @return virtual memory size in bytes.
*/
public abstract long getVirtualMemorySize();
/**
* Obtain the total size of the physical memory present in the system.
*
* @return physical memory size bytes.
*/
public abstract long getPhysicalMemorySize();
/**
* Obtain the total size of the available virtual memory presentView on GitHub (pinned to 2add963021)
Solutions
- Run the component on Linux (or Windows) — that is what production Hadoop supports.
- Guard the call: check Shell.LINUX || Shell.WINDOWS before invoking newInstance() and degrade gracefully (disable the resource monitor or use a stub) on other platforms.
- In tests, mock SysInfo or inject a platform-independent subclass instead of calling the factory.
- Verify os.name at startup and fail fast with a clear message if the platform is unsupported.
Example fix
// before
SysInfo sysInfo = SysInfo.newInstance();
// throws UnsupportedOperationException on macOS
// after
SysInfo sysInfo;
if (Shell.LINUX || Shell.WINDOWS) {
sysInfo = SysInfo.newInstance();
} else {
LOG.warn("Resource monitoring unsupported on " + Shell.OS_NAME);
sysInfo = new SysInfo() { /* zero-value stub */ ... };
} Defensive patterns
Strategy: validation
Validate before calling
import org.apache.hadoop.util.Shell;
static boolean isSupportedPlatform() {
return Shell.LINUX || Shell.WINDOWS;
}
if (!isSupportedPlatform()) {
LOG.warn("SysInfo unavailable on " + Shell.OS_NAME + "; using no-op");
// choose a stub / disable the feature
} Try / catch
try {
sysInfo = SysInfo.newInstance();
} catch (UnsupportedOperationException e) {
// non-Linux/non-Windows dev or CI environment
sysInfo = createNoopSysInfo();
} Prevention
- Gate platform-dependent factories behind Shell.LINUX/Shell.WINDOWS checks.
- Run integration tests for resource monitoring on Linux containers even if dev is on macOS.
- Check os.name early and fail fast with a clear platform message.
When it happens
Trigger: Calling SysInfo.newInstance() on macOS, FreeBSD, Solaris, or any OS whose os.name is neither Linux nor Windows; unit tests or local dev runs of NodeManager-style resource monitoring that instantiate the default SysInfo on a Mac.
Common situations: Developers running Hadoop YARN node helper code or resource-calculator tests on macOS laptops where production runs on Linux; CI runners on non-Linux/non-Windows images; exotic container images reporting an unexpected os.name.
Related errors
- Bad format: {}
- src.toString() + ": No such file or directory"
- Range starts beyond the file length ({l}): {last}
- getXAttrs on path `{}' is not within a mount point
- listXAttrs on path `{}' is not within a mount point
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/bb325aed58ca6442.
Report an issue: GitHub.