{"record":{"id":"64797030b3e32dde","repo":"MyCATApache/Mycat-Server","slug":"fractional-values-are-not-supported-input-was","errorCode":null,"errorMessage":"Fractional values are not supported. Input was: ${value}","messagePattern":"Fractional values are not supported\\. Input was: (.+?)","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/memory/unsafe/utils/JavaUtils.java","lineNumber":212,"sourceCode":"    String lower = str.toLowerCase().trim();\n\n    try {\n      Matcher m = Pattern.compile(\"([0-9]+)([a-z]+)?\").matcher(lower);\n      Matcher fractionMatcher = Pattern.compile(\"([0-9]+\\\\.[0-9]+)([a-z]+)?\").matcher(lower);\n\n      if (m.matches()) {\n        long val = Long.parseLong(m.group(1));\n        String suffix = m.group(2);\n\n        // Check for invalid suffixes\n        if (suffix != null && !byteSuffixes.containsKey(suffix)) {\n          throw new NumberFormatException(\"Invalid suffix: \\\"\" + suffix + \"\\\"\");\n        }\n\n        // If suffix is valid use that, otherwise none was provided and use the default passed\n        return unit.convertFrom(val, suffix != null ? byteSuffixes.get(suffix) : unit);\n      } else if (fractionMatcher.matches()) {\n        throw new NumberFormatException(\"Fractional values are not supported. Input was: \"\n          + fractionMatcher.group(1));\n      } else {\n        throw new NumberFormatException(\"Failed to parse byte string: \" + str);\n      }\n\n    } catch (NumberFormatException e) {\n      String byteError = \"Size must be specified as bytes (b), \" +\n        \"kibibytes (k), mebibytes (m), gibibytes (g), tebibytes (t), or pebibytes(p). \" +\n        \"E.g. 50b, 100k, or 250m.\";\n\n      throw new NumberFormatException(byteError + \"\\n\" + e.getMessage());\n    }\n  }\n\n  /**\n   * Convert a passed byte string (e.g. 50b, 100k, or 250m) to bytes for\n   * internal use.\n   *","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/memory/unsafe/utils/JavaUtils.java#L194-L230","documentation":"byteStringAs rejects fractional byte sizes. When the input doesn't match the integer pattern but does match the fraction pattern (e.g. \"1.5g\"), it throws NumberFormatException naming the fractional input, because sizes must be whole numbers in this parser.","triggerScenarios":"Passing decimal values such as \"1.5g\", \"0.5m\", \"2.75t\" to byteStringAs/byteStringAsBytes/byteStringAsKb/Mb/Gb.","commonSituations":"Config values like \"1.5GB\" written by users expecting float support; computed strings from other languages that render doubles (\"512.0m\").","solutions":["Rewrite the value as an integer in a smaller unit: 1.5g → 1536m.","Round the value yourself before passing it in.","If fractions are common in your config, pre-normalize them with a helper before calling byteStringAs."],"exampleFix":"// before\nlong bytes = JavaUtils.byteStringAsBytes(\"1.5g\");\n// after\nlong bytes = JavaUtils.byteStringAsBytes(\"1536m\");","handlingStrategy":"validation","validationCode":"if (raw.matches(\".*[0-9]\\\\.[0-9].*\")) {\n  // fractional size — convert to a smaller unit or reject before parsing\n}","typeGuard":null,"tryCatchPattern":"try {\n  long bytes = JavaUtils.byteStringAsBytes(raw);\n} catch (NumberFormatException e) {\n  bytes = defaultBytes;\n}","preventionTips":["Express fractional sizes as integers in a smaller unit: 1.5g → 1536m.","Avoid formatting byte sizes through floating-point to-string (produces \"512.0m\").","Reject or normalize decimal-point inputs at the config boundary."],"tags":["java","parsing","configuration","memory"],"backgroundTag":"invalid-config-value","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}