apache/maven · error · RuntimeException

Cannot compare {left} and {right} with operator {operator}

Error message

Cannot compare {left} and {right} with operator {operator}

What it means

Error "Cannot compare {left} and {right} with operator {operator}" thrown in apache/maven.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java:550

                case ">=" -> leftVal >= rightVal;
                case "<=" -> leftVal <= rightVal;
                case "==" -> Math.abs(leftVal - rightVal) < 1e-9;
                case "!=" -> Math.abs(leftVal - rightVal) >= 1e-9;
                default -> throw new IllegalStateException("Unknown operator: " + operator);
            };
        } else if (left instanceof String leftString && right instanceof String rightString) {
            int comparison = leftString.compareTo(rightString);
            return switch (operator) {
                case ">" -> comparison > 0;
                case "<" -> comparison < 0;
                case ">=" -> comparison >= 0;
                case "<=" -> comparison <= 0;
                case "==" -> comparison == 0;
                case "!=" -> comparison != 0;
                default -> throw new IllegalStateException("Unknown operator: " + operator);
            };
        }
        throw new RuntimeException("Cannot compare " + left + " and " + right + " with operator " + operator);
    }

    /**
     * Converts an object to a string representation.
     * If the object is a {@code Double}, it formats it without any decimal places.
     * Otherwise, it uses the {@code String.valueOf} method.
     *
     * @param value the object to convert to a string
     * @return the string representation of the object
     */
    public static String toString(Object value) {
        if (value instanceof Double || value instanceof Float) {
            double doubleValue = ((Number) value).doubleValue();
            if (doubleValue == Math.floor(doubleValue) && !Double.isInfinite(doubleValue)) {
                return String.format("%.0f", doubleValue);
            }
        }
        return String.valueOf(value);

View on GitHub (pinned to e4093d4e12)

When it happens

Trigger: Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java:550 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/5bbdc56d6560acd7. Report an issue: GitHub.