{"record":{"id":"5698ed23adca250a","repo":"apache/dubbo","slug":"the-array-size-of-values-should-be-larger-than-0","errorCode":null,"errorMessage":"the array size of values should be larger than 0","messagePattern":"the array size of values should be larger than 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/url/component/param/FixedParamValue.java","lineNumber":34,"sourceCode":" */\npackage org.apache.dubbo.common.url.component.param;\n\nimport java.util.Arrays;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Locale;\nimport java.util.Map;\n\n/**\n * In lower case\n */\npublic class FixedParamValue implements ParamValue {\n    private final String[] values;\n    private final Map<String, Integer> val2Index;\n\n    public FixedParamValue(String... values) {\n        if (values.length == 0) {\n            throw new IllegalArgumentException(\"the array size of values should be larger than 0\");\n        }\n        this.values = values;\n        Map<String, Integer> valueMap = new HashMap<>(values.length);\n        for (int i = 0; i < values.length; i++) {\n            if (values[i] != null) {\n                valueMap.put(values[i].toLowerCase(Locale.ROOT), i);\n            }\n        }\n        val2Index = Collections.unmodifiableMap(valueMap);\n    }\n\n    /**\n     * DEFAULT value will be returned if n = 0\n     * @param n\n     */\n    @Override\n    public String getN(int n) {\n        return values[n];","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/param/FixedParamValue.java#L16-L52","documentation":"Thrown by the FixedParamValue constructor when called with a zero-length varargs array. FixedParamValue represents a param key whose allowed value set is fixed and enumerated up front (e.g. boolean-style keys). At least one permitted value must be supplied so getN/getIndex have a valid index 0 to work with.","triggerScenarios":"new FixedParamValue() or new FixedParamValue(new String[0]) — constructing the fixed value set with no entries. This is an internal SPI class instantiated by DynamicParamSource extensions when declaring known param keys.","commonSituations":"A custom DynamicParamSource extension declares a fixed param key but passes an empty values array (e.g. reads values from a config that resolved empty, or a code bug). End users do not normally instantiate this class directly.","solutions":["Pass at least one permitted value string to the FixedParamValue constructor.","If the value set is genuinely open/unbounded, use DynamicValues instead of FixedParamValue.","Check the DynamicParamSource extension code that builds the ParamValue list and ensure no empty arrays slip in."],"exampleFix":"// before\nnew FixedParamValue(); // throws: no values\nnew FixedParamValue(new String[0]);\n\n// after\nnew FixedParamValue(\"true\", \"false\");\n// or for an open value set:\nnew DynamicValues(null);","handlingStrategy":"validation","validationCode":"String[] vals = /* ... */;\nif (vals == null || vals.length == 0) {\n    throw new IllegalArgumentException(\"FixedParamValue requires >= 1 value; use DynamicValues for open sets\");\n}\nnew FixedParamValue(vals);","typeGuard":"static boolean nonEmptyValues(String[] vals) {\n    return vals != null && vals.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always pass at least one permitted value when constructing FixedParamValue.","Use DynamicValues when the value set cannot be enumerated up front.","Unit-test SPI extensions that build ParamValue lists to ensure no empty arrays."],"tags":["internal-api","param-table","spi","constructor"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}