{"record":{"id":"7f03f4a1a9bfb9d6","repo":"redis/jedis","slug":"must-not-instantiate-this-class-7f03f4","errorCode":null,"errorMessage":"Must not instantiate this class","messagePattern":"Must not instantiate this class","errorType":"exception","errorClass":"InstantiationError","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/search/SearchBuilderFactory.java","lineNumber":85,"sourceCode":"\n        String header = STRING.build(rawElements.get(0));\n        if (!TERM.equals(header)) {\n          throw new IllegalStateException(\"Unrecognized header: \" + header);\n        }\n        String term = STRING.build(rawElements.get(1));\n\n        List<List<Object>> list = (List<List<Object>>) rawElements.get(2);\n        Map<String, Double> entries = new LinkedHashMap<>(list.size());\n        list.forEach(entry -> entries.put(STRING.build(entry.get(1)), BuilderFactory.DOUBLE.build(entry.get(0))));\n\n        returnTerms.put(term, entries);\n      }\n      return returnTerms;\n    }\n  };\n\n  private SearchBuilderFactory() {\n    throw new InstantiationError(\"Must not instantiate this class\");\n  }\n}\n","sourceCodeStart":67,"sourceCodeEnd":88,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/search/SearchBuilderFactory.java#L67-L88","documentation":"SearchBuilderFactory is a static-constants-only factory class; its private constructor throws InstantiationError to forbid instantiation. It only fires if code explicitly tries to construct the class.","triggerScenarios":"Writing new SearchBuilderFactory(); reflective instantiation by frameworks or Class.newInstance; accidental bean-scanning instantiation.","commonSituations":"Incorrect copy of factory-class usage; reflection-based tests or DI containers scanning and instantiating all classes in the package.","solutions":["Use the static builders directly, e.g. SearchBuilderFactory.SEARCH or SearchBuilderFactory.PROFILE","Exclude utility/factory classes from reflective instantiation","Delete any instantiation code"],"exampleFix":"// before\nSearchBuilderFactory f = new SearchBuilderFactory();\nBuilder b = f.SEARCH;\n// after\nBuilder b = SearchBuilderFactory.SEARCH;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use static builder fields directly; never construct factory classes","Exclude factory/util classes from DI and reflection scanning"],"tags":["redisearch","utility-class","instantiation"],"backgroundTag":"unsupported-operation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}