{"record":{"id":"1ba9d64eb10e1892","repo":"LMAX-Exchange/disruptor","slug":"batchrewindstrategy-cannot-be-null-when-building-a","errorCode":null,"errorMessage":"batchRewindStrategy cannot be null when building a BatchEventProcessor","messagePattern":"batchRewindStrategy cannot be null when building a BatchEventProcessor","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/lmax/disruptor/BatchEventProcessorBuilder.java","lineNumber":80,"sourceCode":"     * Construct a {@link EventProcessor} that will automatically track the progress by updating its sequence when\n     * the {@link EventHandler#onEvent(Object, long, boolean)} method returns.\n     *\n     * @param dataProvider           to which events are published.\n     * @param sequenceBarrier        on which it is waiting.\n     * @param rewindableEventHandler is the delegate to which events are dispatched.\n     * @param batchRewindStrategy    a {@link BatchRewindStrategy} for customizing how to handle a {@link RewindableException}.\n     * @param <T>                    event implementation storing the data for sharing during exchange or parallel coordination of an event.\n     * @return the BatchEventProcessor\n     */\n    public <T> BatchEventProcessor<T> build(\n            final DataProvider<T> dataProvider,\n            final SequenceBarrier sequenceBarrier,\n            final RewindableEventHandler<? super T> rewindableEventHandler,\n            final BatchRewindStrategy batchRewindStrategy)\n    {\n        if (null == batchRewindStrategy)\n        {\n            throw new NullPointerException(\"batchRewindStrategy cannot be null when building a BatchEventProcessor\");\n        }\n\n        return new BatchEventProcessor<>(\n                dataProvider, sequenceBarrier, rewindableEventHandler, maxBatchSize, batchRewindStrategy\n        );\n    }\n}\n","sourceCodeStart":62,"sourceCodeEnd":88,"githubUrl":"https://github.com/LMAX-Exchange/disruptor/blob/c871ca49826a6be7ada6957f6fbafcfecf7b1f87/src/main/java/com/lmax/disruptor/BatchEventProcessorBuilder.java#L62-L88","documentation":"Thrown by BatchEventProcessorBuilder.build(...) when batchRewindStrategy is null while constructing a processor for a RewindableEventHandler. The rewind path needs a strategy (e.g. SagaBatchRewindStrategy) to decide how many retries to attempt before giving up, so a null strategy cannot be defaulted silently.","triggerScenarios":"Calling the four-argument build(dataProvider, sequenceBarrier, rewindableEventHandler, null), or passing a strategy field that was never initialised.","commonSituations":"Builder wiring copied from an example where the strategy was created inline; dependency injection leaving the strategy bean null in a test profile; upgrading Disruptor versions where build() gained the batchRewindStrategy parameter and call sites were not all updated.","solutions":["Pass a concrete BatchRewindStrategy, e.g. new SagaBatchRewindStrategy(3), to build(...).","If you do not want retries, still pass a strategy that immediately rethrows (implement BatchRewindStrategy to throw the exception).","If using DI, ensure the strategy bean is defined and injected in all profiles including tests."],"exampleFix":"// before\nBatchEventProcessor<Event> p = builder.build(ringBuffer, barrier, handler, null);\n\n// after\nBatchEventProcessor<Event> p = builder.build(ringBuffer, barrier, handler, new SagaBatchRewindStrategy(3));","handlingStrategy":"validation","validationCode":"BatchRewindStrategy strategy = (strategyBean != null)\n        ? strategyBean\n        : new SagaBatchRewindStrategy(3);","typeGuard":"static boolean isUsableStrategy(BatchRewindStrategy s) { return s != null; }","tryCatchPattern":null,"preventionTips":["Never pass a literal null to builder.build(...); always construct a strategy inline.","Enable nullness annotations (@NonNull) on your own builder wrappers around Disruptor."],"tags":["disruptor","builder","null-check","rewind","validation"],"backgroundTag":null,"analyzedSha":"c871ca49826a6be7ada6957f6fbafcfecf7b1f87","analyzedAt":"2026-08-14T14:22:36.358Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}