apache/maven · error · IllegalArgumentException
Illegal event type: " + eventType
Error message
Illegal event type: " + eventType
What it means
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.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/repository/ArtifactTransferEvent.java:167
}
/**
* @param eventType The eventType to set.
*/
public void setEventType(final int eventType) {
switch (eventType) {
case TRANSFER_INITIATED:
break;
case TRANSFER_STARTED:
break;
case TRANSFER_COMPLETED:
break;
case TRANSFER_PROGRESS:
break;
case TRANSFER_ERROR:
break;
default:
throw new IllegalArgumentException("Illegal event type: " + eventType);
}
this.eventType = eventType;
}
/**
* @return Returns the local file.
*/
public File getLocalFile() {
return localFile;
}
/**
* @param localFile The local file to set.
*/
public void setLocalFile(File localFile) {
this.localFile = localFile;
}View on GitHub (pinned to e4093d4e12)
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
Example fix
// before event.setEventType(99); // invented value event.setEventType(REQUEST_GET); // wrong constant family // after import static org.apache.maven.wagon.events.TransferEvent.TRANSFER_STARTED; event.setEventType(TRANSFER_STARTED);
Defensive patterns
Strategy: validation
Validate before calling
import static org.apache.maven.wagon.events.TransferEvent.*;
static boolean isValidEventType(int t) {
return t == TRANSFER_INITIATED || t == TRANSFER_STARTED || t == TRANSFER_COMPLETED
|| t == TRANSFER_PROGRESS || t == TRANSFER_ERROR;
} Prevention
- Use only the five TRANSFER_* constants
- Build events through constructors that set both fields atomically
- Migrate listeners to org.eclipse.aether.TransferEvent (enum-based)
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Illegal request type: " + requestType
- artifactId can neither be null, empty nor blank
- version can neither be null, empty nor blank
- Unable to promptForPassword
- Unable to showMessage
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/9c222024d66e2c99.
Report an issue: GitHub.