Repository: apache/kafka
File: streams/src/test/java/org/apache/kafka/streams/processor/internals/RecordCollectorTest.java (Java)

Code before:
                taskId,
                getExceptionalStreamsProducerOnSend(exception),
                new ProductionExceptionHandler() {
                    @Override
                    public void configure(final Map<String, ?> configs) {

                    }

                    @Override
                    public ProductionExceptionHandlerResponse handle(final ErrorHandlerContext context, final ProducerRecord<byte[], byte[]> record, final Exception exception) {
                        sourceRawData[0] = context.sourceRawKey();
                        sourceRawData[1] = context.sourceRawValue();
                        return ProductionExceptionHandlerResponse.CONTINUE;
                    }
                },
                streamsMetrics,
                topology
        );

        collector.send(topic, "3", "0", null, null, stringSerializer, stringSerializer, sinkNodeName, context, streamPartitioner);

        assertNull(sourceRawData[0]);
        assertNull(sourceRawData[1]);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void shouldHaveRawDataDuringExceptionInSerialization() {
        final byte[][] sourceRawData = new byte[][]{new byte[]{}, new byte[]{}};
        try (final ErrorStringSerializer errorSerializer = new ErrorStringSerializer()) {
            final RecordCollector collector = newRecordCollector(
                    new ProductionExceptionHandler() {
                        @Override
                        @SuppressWarnings({"rawtypes", "unused"})
                        public ProductionExceptionHandlerResponse handleSerializationException(final ErrorHandlerContext context, final ProducerRecord record, final Exception exception, final SerializationExceptionOrigin origin) {
                            sourceRawData[0] = context.sourceRawKey();
                            sourceRawData[1] = context.sourceRawValue();
                            return ProductionExceptionHandlerResponse.CONTINUE;
                        }

                        @Override
                        public void configure(final Map<String, ?> configs) {

                        }
                    }
            );
            collector.initialize();

            collector.send(topic, "hello", "val", null, 0, null, errorSerializer, stringSerializer, sinkNodeName, context);

            assertNotNull(sourceRawData[0]);

Review comment (suggestion):
Excuse me, which one requires this suppression? My IDE says the suppression is redundant :(

<img width="1755" height="250" alt="螢幕快照 2025-08-28 15-31-32" src="https://github.com/user-attachments/assets/3a31fd90-7451-42a4-8dbf-5be1ad57b581" />


Code after:
                taskId,
                getExceptionalStreamsProducerOnSend(exception),
                new ProductionExceptionHandler() {
                    @Override
                    public void configure(final Map<String, ?> configs) {

                    }

                    @SuppressWarnings("deprecation")
                    @Override
                    public ProductionExceptionHandlerResponse handle(final ErrorHandlerContext context, final ProducerRecord<byte[], byte[]> record, final Exception exception) {
                        sourceRawData[0] = context.sourceRawKey();
                        sourceRawData[1] = context.sourceRawValue();
                        return ProductionExceptionHandlerResponse.CONTINUE;
                    }
                },
                streamsMetrics,
                topology
        );

        collector.send(topic, "3", "0", null, null, stringSerializer, stringSerializer, sinkNodeName, context, streamPartitioner);

        assertNull(sourceRawData[0]);
        assertNull(sourceRawData[1]);
    }

    @Test
    public void shouldHaveRawDataDuringExceptionInSerialization() {
        final byte[][] sourceRawData = new byte[][]{new byte[]{}, new byte[]{}};
        try (final ErrorStringSerializer errorSerializer = new ErrorStringSerializer()) {
            final RecordCollector collector = newRecordCollector(
                    new ProductionExceptionHandler() {
                        @SuppressWarnings({"deprecation", "rawtypes"})
                        @Override
                        public ProductionExceptionHandlerResponse handleSerializationException(final ErrorHandlerContext context, final ProducerRecord record, final Exception exception, final SerializationExceptionOrigin origin) {
                            sourceRawData[0] = context.sourceRawKey();
                            sourceRawData[1] = context.sourceRawValue();
                            return ProductionExceptionHandlerResponse.CONTINUE;
                        }

                        @Override
                        public void configure(final Map<String, ?> configs) {

                        }
                    }
            );
            collector.initialize();

            collector.send(topic, "hello", "val", null, 0, null, errorSerializer, stringSerializer, sinkNodeName, context);

            assertNotNull(sourceRawData[0]);