{"record":{"id":"6222f3ae32204901","repo":"apache/seatunnel","slug":"utility-class","errorCode":null,"errorMessage":"Utility class","messagePattern":"Utility class","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"info","filePath":"seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/future/RequestFutureCache.java","lineNumber":29,"sourceCode":" *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n *\n */\n\npackage org.apache.seatunnel.engine.imap.storage.file.future;\n\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.atomic.AtomicLong;\n\npublic class RequestFutureCache {\n\n    private RequestFutureCache() {\n        throw new IllegalStateException(\"Utility class\");\n    }\n\n    private static AtomicLong REQUEST_ID_GEN = new AtomicLong(0);\n\n    private static ConcurrentHashMap<Long, RequestFuture> REQUEST_MAP = new ConcurrentHashMap<>();\n\n    public static void put(long requestId, RequestFuture requestFuture) {\n        REQUEST_MAP.put(requestId, requestFuture);\n    }\n\n    public static RequestFuture get(Long requestId) {\n        return REQUEST_MAP.get(requestId);\n    }\n\n    public static void remove(Long requestId) {\n        REQUEST_MAP.remove(requestId);\n    }\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-storage/imap-storage-plugins/imap-storage-file/src/main/java/org/apache/seatunnel/engine/imap/storage/file/future/RequestFutureCache.java#L11-L47","documentation":"IllegalStateException thrown from the private constructor of RequestFutureCache, a static utility class holding pending request futures. This is a defensive guard to prevent instantiation of the class, which only exposes static methods. It only fires if a developer tries `new RequestFutureCache()` via reflection, serialization, or inside the same class.","triggerScenarios":"Any attempt to instantiate RequestFutureCache: direct constructor call (impossible from outside due to private access), reflection with setAccessible(true), or accidental deserialization of the class.","commonSituations":"Refactor or test code trying to instantiate utility classes; reflection-based frameworks (e.g. some mocking or serialization tools) probing constructors.","solutions":["Remove any code that instantiates RequestFutureCache and call its static methods instead","If instantiation is intentional, refactor the needed functionality into a non-utility class","In tests, suppress instantiation attempts rather than calling the constructor"],"exampleFix":"// before\nRequestFutureCache cache = new RequestFutureCache();\n// after\nRequestFuture future = RequestFutureCache.get(requestId); // use static access","handlingStrategy":"type-guard","validationCode":"// never instantiate; just use statics\nassert Modifier.isPrivate(RequestFutureCache.class.getDeclaredConstructor().getModifiers());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat utility classes as static-only; never reflectively instantiate them","Use static method calls directly on RequestFutureCache","Enable IDE inspections that flag instantiation of private-constructor utility classes"],"tags":["java","utility-class","anti-instantiation"],"backgroundTag":"internal-invariant-violation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}