alibaba/nacos · error · IllegalArgumentException
processors scale must between 0 and 1
Error message
processors scale must between 0 and 1
What it means
Thrown by EnvUtil.getAvailableProcessors(double scale) when the scale is outside [0, 1]. The method sizes pools as a fraction of available processors and rejects out-of-range fractions.
Source
Thrown at sys/src/main/java/com/alibaba/nacos/sys/env/EnvUtil.java:509
*/
public static int getAvailableProcessors(int multiple) {
if (multiple < 1) {
throw new IllegalArgumentException("processors multiple must upper than 1");
}
Integer processor = getProperty(Constants.AVAILABLE_PROCESSORS_BASIC, Integer.class);
return null != processor && processor > 0 ? processor * multiple
: ThreadUtils.getSuitableThreadCount(multiple);
}
/**
* Get a scale of available processor numbers from environment.
*
* @param scale scale from 0 to 1.
* @return available processor numbers from environment, will not lower than 1.
*/
public static int getAvailableProcessors(double scale) {
if (scale < 0 || scale > 1) {
throw new IllegalArgumentException("processors scale must between 0 and 1");
}
double result =
getProperty(Constants.AVAILABLE_PROCESSORS_BASIC, int.class,
ThreadUtils.getSuitableThreadCount(1))
* scale;
return result > 1 ? (int) result : 1;
}
public static DeploymentType getDeploymentType() {
return deploymentType;
}
public static void setDeploymentType(DeploymentType deploymentType) {
EnvUtil.deploymentType = deploymentType;
}
}
View on GitHub (pinned to 9b989acdf1)
Solutions
- Find the caller of getAvailableProcessors(double) and ensure scale is within [0, 1].
- If the property is a percentage, divide by 100 before passing (e.g. 75 -> 0.75).
- Clamp the value: Math.max(0.0, Math.min(1.0, scale)).
- Correct the source configuration value.
Example fix
// before // config: nacos.thread.pool.ratio=150 (intended as 150%) double scale = 150.0; int size = EnvUtil.getAvailableProcessors(scale); // throws // after double scale = 150.0 / 100.0; // 1.0, or clamp int size = EnvUtil.getAvailableProcessors(Math.min(1.0, scale));
Defensive patterns
Strategy: validation
Validate before calling
double scale = configuredScale; // from config
if (scale < 0 || scale > 1) {
throw new IllegalArgumentException("thread scale must be in [0,1], got " + scale);
}
int size = EnvUtil.getAvailableProcessors(scale); Try / catch
try {
EnvUtil.getAvailableProcessors(scale);
} catch (IllegalArgumentException e) {
// treat as percentage or clamp
EnvUtil.getAvailableProcessors(Math.max(0.0, Math.min(1.0, scale)));
} Prevention
- Document ratio properties as fractions in [0,1], not percentages.
- Clamp derived scales before calling.
- Validate at startup and fail fast with a clear message.
When it happens
Trigger: A caller passes a scale < 0 or > 1, usually from a misconfigured ratio property (e.g. 1.5 meaning '150%' or a negative value).
Common situations: A thread-pool ratio property set to >1 (user thinking percentage) or negative; a derived ratio computed incorrectly; configuration imported from another system with a different scale convention.
Related errors
- processors multiple must upper than 1
- Must be a file directory :
- nacos address
- serverList is empty,please check configuration
- 400
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/c5f4937b4a3dda3d.
Report an issue: GitHub.