{"record":{"id":"2a090efc69f34305","repo":"apache/seatunnel","slug":"handler-not-reset","errorCode":null,"errorMessage":"Handler not reset","messagePattern":"Handler not reset","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/schema/handler/TableSchemaChangeEventHandler.java","lineNumber":31,"sourceCode":" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.apache.seatunnel.api.table.schema.handler;\n\nimport org.apache.seatunnel.api.table.catalog.TableSchema;\nimport org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;\n\npublic interface TableSchemaChangeEventHandler extends SchemaChangeEventHandler<TableSchema> {\n\n    TableSchema get();\n\n    TableSchemaChangeEventHandler reset(TableSchema schema);\n\n    default TableSchema handle(SchemaChangeEvent event) {\n        if (get() == null) {\n            throw new IllegalStateException(\"Handler not reset\");\n        }\n\n        try {\n            return apply(event);\n        } finally {\n            reset(null);\n            if (get() != null) {\n                throw new IllegalStateException(\"Handler not reset\");\n            }\n        }\n    }\n\n    TableSchema apply(SchemaChangeEvent event);\n}\n","sourceCodeStart":13,"sourceCodeEnd":46,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/schema/handler/TableSchemaChangeEventHandler.java#L13-L46","documentation":"TableSchemaChangeEventHandler.apply() requires the handler to have been initialized with a TableSchema via reset(schema). The handle() method checks get() before applying a SchemaChangeEvent and throws IllegalStateException if the handler was never reset with a schema (or was reset to null after a previous event). This is an internal lifecycle guard: each event application clears state, so a stale/uninitialized handler cannot silently mis-apply changes.","triggerScenarios":"Calling handle(event) on a handler that was constructed but never had reset(schema) called, or calling handle(event) twice without re-initializing via reset(schema) in between (since handle() ends with reset(null)).","commonSituations":"CDC/schema-change pipelines where the handler is created once and reused across multiple events without re-binding the current schema; custom event handler implementations that forget to call reset(schema) before dispatching events.","solutions":["Call handler.reset(currentTableSchema) before each handle(event) invocation","Do not reuse the handler for a second event without resetting it with the updated schema returned from the previous handle() call","Check your custom handler: if you overrode reset/get, ensure get() returns the schema set by reset(schema)","Wrap handler lifecycle: obtain schema, reset, then handle, in one sequential block"],"exampleFix":"// before\nTableSchema result = handler.handle(event);\nTableSchema result2 = handler.handle(event2); // throws: handler reset to null\n// after\nTableSchema result = handler.handle(event);\nhandler.reset(result);\nTableSchema result2 = handler.handle(event2);","handlingStrategy":"validation","validationCode":"if (handler.get() == null) {\n    handler.reset(currentTableSchema);\n}\nTableSchema result = handler.handle(event);","typeGuard":null,"tryCatchPattern":"try {\n    TableSchema result = handler.handle(event);\n} catch (IllegalStateException e) {\n    handler.reset(currentSchema);\n    // retry once or fail the pipeline with context\n}","preventionTips":["Always pair reset(schema) with each handle() call","Treat the handler as single-use per event","Store the schema returned by handle() and reset with it before the next event","Add an assert in wrapper code that get() != null before dispatch"],"tags":["schema-change","state","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}