SonarSource/sonarqube · error · IllegalStateException
Value of property is not an integer:
Error message
Value of property is not an integer:
What it means
Props.valueAsInt parses a property as an Integer and throws IllegalStateException (wrapping NumberFormatException) when the value is non-empty but not a valid integer. The error message includes both the property key and the offending raw value.
Solutions
- Open conf/sonar.properties and set the offending property to a plain integer (e.g. sonar.web.port=9000).
- Strip quotes, spaces, and non-ASCII characters from the value; check for letter O vs zero.
- If the value can legitimately be non-integer, parse defensively with value(key) and Integer.parseInt in your own try/catch.
Example fix
// before sonar.web.port="9000" // after sonar.web.port=9000
Defensive patterns
Strategy: validation
Validate before calling
String raw = props.value("sonar.web.port");
if (raw != null && !raw.matches("\\d+")) {
throw new IllegalStateException("sonar.web.port must be an integer, got: " + raw.trim());
} Try / catch
try {
Integer port = props.valueAsInt("sonar.web.port");
} catch (IllegalStateException e) {
logger.error("Bad integer property: {}", e.getMessage());
} Prevention
- Never quote or annotate numeric values in sonar.properties.
- Copy-paste values through a plain-text editor to strip smart quotes and hidden characters.
- Lint sonar.properties numerics in CI before shipping the config.
When it happens
Trigger: Calling props.valueAsInt("sonar.web.port") or valueAsInt(key, default) (used by embeddedDatabasePort, completeDefaults for search/http ports) when the property contains a non-numeric string like "90 0” with spaces, "http", or "9000.5".
Common situations: Hand-edited sonar.properties with typos ("sonar.web.port=90O0"), quotes or trailing whitespace around numbers, or a port placeholder left from a template.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Address in property is not a valid address
- allowAllGroups can only be enabled when Auto-provisioning…
- allowAllGroups cannot be enabled when the GitLab URL is…
- allowedGroups cannot be empty when Auto-provisioning is…
- At least one Elasticsearch host is required
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/7f143b60ce9b9520.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-process/src/main/java/org/sonar/process/Props.java:94
return s != null ? Boolean.parseBoolean(s) : defaultValue;
}
public File nonNullValueAsFile(String key) {
String s = value(key);
if (s == null) {
throw new IllegalArgumentException("Property " + key + " is not set");
}
return new File(s);
}
@CheckForNull
public Integer valueAsInt(String key) {
String s = value(key);
if (s != null && !"".equals(s)) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
throw new IllegalStateException("Value of property " + key + " is not an integer: " + s, e);
}
}
return null;
}
public int valueAsInt(String key, int defaultValue) {
Integer i = valueAsInt(key);
return i == null ? defaultValue : i;
}
public Properties rawProperties() {
return properties;
}
public Props set(String key, @Nullable String value) {
if (value != null) {
properties.setProperty(key, value);
}View on GitHub (pinned to 184c821202)