alibaba/nacos · error · IllegalArgumentException

processors multiple must upper than 1

Error message

processors multiple must upper than 1

What it means

Thrown by EnvUtil.getAvailableProcessors(int multiple) when the supplied multiple is less than 1. The method sizes thread pools as a multiple of the available processor count and rejects non-positive multipliers.

Source

Thrown at sys/src/main/java/com/alibaba/nacos/sys/env/EnvUtil.java:494

     * </p>
     *
     * @return available processor numbers from environment, will not lower than 1.
     */
    public static int getAvailableProcessors() {
        int result = getProperty(Constants.AVAILABLE_PROCESSORS_BASIC, int.class,
            ThreadUtils.getSuitableThreadCount(1));
        return result > 0 ? result : 1;
    }
    
    /**
     * Get a multiple time of available processor numbers from environment.
     *
     * @param multiple multiple of available processor numbers
     * @return available processor numbers from environment, will not lower than 1.
     */
    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,

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Find the caller of getAvailableProcessors(int) and ensure the multiplier is >= 1.
  2. If the value comes from config, validate/clamp it to a minimum of 1 before calling.
  3. Search the codebase for the property feeding the multiplier and correct its value.
  4. Add a unit test asserting the multiplier stays positive for expected config ranges.

Example fix

// before
int poolSize = EnvUtil.getAvailableProcessors(configuredMultiple); // configuredMultiple = 0

// after
int multiple = Math.max(1, configuredMultiple);
int poolSize = EnvUtil.getAvailableProcessors(multiple);
Defensive patterns

Strategy: validation

Validate before calling

int multiple = configuredMultiple; // from config
if (multiple < 1) {
    throw new IllegalArgumentException("thread multiplier must be >= 1, got " + multiple);
}
int size = EnvUtil.getAvailableProcessors(multiple);

Try / catch

try {
    EnvUtil.getAvailableProcessors(multiple);
} catch (IllegalArgumentException e) {
    // clamp and retry, or fail startup with config context
    EnvUtil.getAvailableProcessors(Math.max(1, multiple));
}

Prevention

When it happens

Trigger: A caller passes a multiple < 1, typically derived from a misparsed configuration property (negative or zero thread multiplier).

Common situations: A thread-pool sizing property is set to 0 or negative in custom config; a plugin computes a multiplier from a ratio that underflows to <= 0; refactoring introduces an off-by-one producing 0.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/3ec70833fced8362. Report an issue: GitHub.