{"record":{"id":"7f143b60ce9b9520","repo":"SonarSource/sonarqube","slug":"value-of-property-is-not-an-integer","errorCode":null,"errorMessage":"Value of property  is not an integer: ","messagePattern":"Value of property  is not an integer: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-process/src/main/java/org/sonar/process/Props.java","lineNumber":94,"sourceCode":"    return s != null ? Boolean.parseBoolean(s) : defaultValue;\n  }\n\n  public File nonNullValueAsFile(String key) {\n    String s = value(key);\n    if (s == null) {\n      throw new IllegalArgumentException(\"Property \" + key + \" is not set\");\n    }\n    return new File(s);\n  }\n\n  @CheckForNull\n  public Integer valueAsInt(String key) {\n    String s = value(key);\n    if (s != null && !\"\".equals(s)) {\n      try {\n        return Integer.parseInt(s);\n      } catch (NumberFormatException e) {\n        throw new IllegalStateException(\"Value of property \" + key + \" is not an integer: \" + s, e);\n      }\n    }\n    return null;\n  }\n\n  public int valueAsInt(String key, int defaultValue) {\n    Integer i = valueAsInt(key);\n    return i == null ? defaultValue : i;\n  }\n\n  public Properties rawProperties() {\n    return properties;\n  }\n\n  public Props set(String key, @Nullable String value) {\n    if (value != null) {\n      properties.setProperty(key, value);\n    }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-process/src/main/java/org/sonar/process/Props.java#L76-L112","documentation":"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.","triggerScenarios":"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\u00000” with spaces, \"http\", or \"9000.5\".","commonSituations":"Hand-edited sonar.properties with typos (\"sonar.web.port=90O0\"), quotes or trailing whitespace around numbers, or a port placeholder left from a template.","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."],"exampleFix":"// before\nsonar.web.port=\"9000\"\n// after\nsonar.web.port=9000","handlingStrategy":"validation","validationCode":"String raw = props.value(\"sonar.web.port\");\nif (raw != null && !raw.matches(\"\\\\d+\")) {\n  throw new IllegalStateException(\"sonar.web.port must be an integer, got: \" + raw.trim());\n}","typeGuard":null,"tryCatchPattern":"try {\n  Integer port = props.valueAsInt(\"sonar.web.port\");\n} catch (IllegalStateException e) {\n  logger.error(\"Bad integer property: {}\", e.getMessage());\n}","preventionTips":["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."],"tags":["number-format","configuration","parse-error"],"backgroundTag":"invalid-config-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}