{"record":{"id":"a93037e7ee352c19","repo":"hibernate/hibernate-orm","slug":"custom-event-type-name-must-be-non-null","errorCode":null,"errorMessage":"Custom event-type name must be non-null.","messagePattern":"Custom event-type name must be non-null\\.","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/EventEngine.java","lineNumber":110,"sourceCode":"\t\t@Override\n\t\t@Nonnull\n\t\tpublic <T> EventType<T> findEventType(@Nonnull String name) {\n\t\t\t//noinspection unchecked\n\t\t\treturn (EventType<T>) eventTypes.get( name );\n\t\t}\n\n\t\t@Override\n\t\t@Nonnull\n\t\tpublic <T> EventType<T> contributeEventType(@Nonnull String name, @Nonnull Class<T> listenerRole) {\n\t\t\tfinal var eventType = registerEventType( name, listenerRole );\n\t\t\tlistenerRegistryBuilder.prepareListeners( eventType );\n\t\t\treturn eventType;\n\t\t}\n\n\t\t@Nonnull\n\t\tprivate <T> EventType<T> registerEventType(@Nonnull String name, @Nonnull Class<T> listenerRole) {\n\t\t\tif ( name == null ) {\n\t\t\t\tthrow new HibernateException( \"Custom event-type name must be non-null.\" );\n\t\t\t}\n\t\t\telse if ( listenerRole == null ) {\n\t\t\t\tthrow new HibernateException( \"Custom event-type listener role must be non-null.\" );\n\t\t\t}\n\t\t\t// make sure it does not match an existing name...\n\t\t\telse if ( eventTypes.containsKey( name ) ) {\n\t\t\t\tfinal var existing = eventTypes.get( name );\n\t\t\t\tthrow new HibernateException(\n\t\t\t\t\t\t\"Custom event-type already registered: \" + name + \" => \" + existing\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfinal EventType<T> eventType = EventType.create( name, listenerRole, eventTypes.size() );\n\t\t\t\teventTypes.put( name, eventType );\n\t\t\t\treturn eventType;\n\t\t\t}\n\t\t}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/EventEngine.java#L92-L128","documentation":"HibernateException from EventEngine's ContributionManager.registerEventType validating the contribution contract: the name passed to EventEngineContributions.contributeEventType(String, Class) is null. Custom event types are keyed by name in the engine's map (used for later lookup and uniqueness), so a null name is rejected immediately during bootstrap contribution.","triggerScenarios":"An EventEngineContributor calling contributeEventType(null, listenerRole) — typically because the name was assembled from configuration/environment values or string helpers that returned null.","commonSituations":"Custom integrations deriving event-type names from annotations or config properties that may be absent; copy-paste contributor code with placeholder names; test contributors constructed with null arguments.","solutions":["Pass a non-null, descriptive, namespaced name (e.g. 'com.acme.audit-event') from the contributor","Default or validate configuration-derived names before contributing (Objects.requireNonNull(name, 'event type name required'))","Add unit tests that bootstrap the contributor with all config states so null names fail in CI, not in production bootstrap"],"exampleFix":"// before\npublic void contribute(EventEngineContributions c) {\n    c.contributeEventType(nameFromConfig, AuditListener.class); // nameFromConfig == null\n}\n\n// after\npublic void contribute(EventEngineContributions c) {\n    String name = Objects.requireNonNullElse(nameFromConfig, \"com.acme.audit\");\n    c.contributeEventType(name, AuditListener.class);\n}","handlingStrategy":"validation","validationCode":"public void contribute(EventEngineContributions c) {\n    String name = Objects.requireNonNull(nameSource(), \"event type name required\");\n    c.contributeEventType(name, MyListener.class);\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Validate config-derived names at load time with clear error messages","Default namespaced names instead of passing configuration values straight through","Unit-test contributors with every configuration permutation"],"tags":["hibernate","custom-event","event-engine","validation","api-misuse"],"backgroundTag":"null-config-value","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}