{"record":{"id":"9c222024d66e2c99","repo":"apache/maven","slug":"illegal-event-type-eventtype","errorCode":null,"errorMessage":"Illegal event type: \" + eventType","messagePattern":"Illegal event type: \" \\+ eventType","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java","lineNumber":167,"sourceCode":"    }\n\n    /**\n     * @param eventType The eventType to set.\n     */\n    public void setEventType(final int eventType) {\n        switch (eventType) {\n            case TRANSFER_INITIATED:\n                break;\n            case TRANSFER_STARTED:\n                break;\n            case TRANSFER_COMPLETED:\n                break;\n            case TRANSFER_PROGRESS:\n                break;\n            case TRANSFER_ERROR:\n                break;\n            default:\n                throw new IllegalArgumentException(\"Illegal event type: \" + eventType);\n        }\n\n        this.eventType = eventType;\n    }\n\n    /**\n     * @return Returns the local file.\n     */\n    public File getLocalFile() {\n        return localFile;\n    }\n\n    /**\n     * @param localFile The local file to set.\n     */\n    public void setLocalFile(File localFile) {\n        this.localFile = localFile;\n    }","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java#L149-L185","documentation":"Thrown by ArtifactTransferEvent.setEventType() when the value is not one of TRANSFER_INITIATED, TRANSFER_STARTED, TRANSFER_COMPLETED, TRANSFER_PROGRESS or TRANSFER_ERROR. The setter switch has a default arm rejecting everything else with IllegalArgumentException echoing the bad int. It protects listeners that dispatch on event type from receiving undefined states.","triggerScenarios":"Calling setEventType() with an arbitrary int: a listener re-using an event object and passing a requestType (0/1) by mistake, a computed state machine value, or an unset 0 from a default-initialized event.","commonSituations":"Hand-written wagon listeners/adapters constructing or recycling ArtifactTransferEvent instances; copy-paste between setRequestType and setEventType; code compiled against wagon constants that changed meaning across versions.","solutions":["Use only the TransferEvent.TRANSFER_* constants for setEventType","Double-check argument order at event construction (eventType vs requestType are adjacent ints)","Create a fresh event per transfer state instead of mutating a shared instance","Migrate new code to org.eclipse.aether.TransferEvent with its enum-based EventTypes"],"exampleFix":"// before\nevent.setEventType(99);            // invented value\nevent.setEventType(REQUEST_GET);   // wrong constant family\n// after\nimport static org.apache.maven.wagon.events.TransferEvent.TRANSFER_STARTED;\nevent.setEventType(TRANSFER_STARTED);","handlingStrategy":"validation","validationCode":"import static org.apache.maven.wagon.events.TransferEvent.*;\nstatic boolean isValidEventType(int t) {\n    return t == TRANSFER_INITIATED || t == TRANSFER_STARTED || t == TRANSFER_COMPLETED\n        || t == TRANSFER_PROGRESS || t == TRANSFER_ERROR;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only the five TRANSFER_* constants","Build events through constructors that set both fields atomically","Migrate listeners to org.eclipse.aether.TransferEvent (enum-based)"],"tags":["maven","transfer-event","validation","legacy","wagon"],"backgroundTag":"invalid-event-type","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}