{"record":{"id":"3e06087e4035f14d","repo":"apache/cassandra","slug":"settype-takes-exactly-1-type-parameter","errorCode":null,"errorMessage":"SetType takes exactly 1 type parameter","messagePattern":"SetType takes exactly 1 type parameter","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/SetType.java","lineNumber":61,"sourceCode":"import org.apache.cassandra.utils.JsonUtils;\nimport org.apache.cassandra.utils.bytecomparable.ByteComparable;\nimport org.apache.cassandra.utils.bytecomparable.ByteSource;\n\npublic class SetType<T> extends CollectionType<Set<T>>\n{\n    // interning instances\n    private static final ConcurrentHashMap<AbstractType<?>, SetType> instances = new ConcurrentHashMap<>();\n    private static final ConcurrentHashMap<AbstractType<?>, SetType> frozenInstances = new ConcurrentHashMap<>();\n\n    private final AbstractType<T> elements;\n    private final SetSerializer<T> serializer;\n    private final boolean isMultiCell;\n\n    public static SetType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException\n    {\n        List<AbstractType<?>> l = parser.getTypeParameters();\n        if (l.size() != 1)\n            throw new ConfigurationException(\"SetType takes exactly 1 type parameter\");\n\n        return getInstance(l.get(0).freeze(), true);\n    }\n\n    public static <T> SetType<T> getInstance(AbstractType<T> elements, boolean isMultiCell)\n    {\n        ConcurrentHashMap<AbstractType<?>, SetType> internMap = isMultiCell ? instances : frozenInstances;\n        SetType<T> t = internMap.get(elements);\n        return null == t\n             ? internMap.computeIfAbsent(elements, k -> new SetType<>(k, isMultiCell))\n             : t;\n    }\n\n    public SetType(AbstractType<T> elements, boolean isMultiCell)\n    {\n        super(ComparisonType.CUSTOM, Kind.SET);\n        this.elements = elements;\n        this.serializer = SetSerializer.getInstance(elements.getSerializer(), elements.comparatorSet);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/SetType.java#L43-L79","documentation":"SetType.getInstance(TypeParser) constructs a SetType from parsed type parameters, e.g. set<element_type>. It throws ConfigurationException when the parser does not provide exactly one type parameter, because a set needs exactly one element type.","triggerScenarios":"Parsing a type string like 'org.apache.cassandra.db.marshal.SetType' with zero parameters or with two or more parameters (e.g. set<int, text>) into SetType.getInstance(parser).","commonSituations":"Malformed schema definitions with extra type arguments; confusing set with map syntax (map takes 2 parameters, set takes 1); programmatic type parsing of user-supplied strings.","solutions":["Supply exactly one element type: e.g. set<org.apache.cassandra.db.marshal.Int32Type>.","If two element types were intended, use map<k,v> instead of set.","Catch ConfigurationException around TypeParser.parse()/getInstance and validate the type string before use."],"exampleFix":"// before\nTypeParser.parse(\"SetType(Int32Type, UTF8Type)\");\n// after\nTypeParser.parse(\"SetType(Int32Type)\");","handlingStrategy":"validation","validationCode":"List<AbstractType<?>> params = parser.getTypeParameters();\nif (params.size() != 1)\n    throw new ConfigurationException(\"set type requires exactly 1 parameter, got \" + params.size());","typeGuard":null,"tryCatchPattern":"try {\n    SetType<?> st = SetType.getInstance(parser);\n} catch (ConfigurationException e) {\n    // report malformed set type definition\n} catch (SyntaxException e) {\n    // report unparseable type string\n}","preventionTips":["Write set types with one parameter: set<T>; two parameters means map<k,v>","Validate user-supplied type strings before parsing","Use server-generated comparator strings as reference"],"tags":["cassandra","type-parser","set","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}