Fix: Enhance JMS Header Handling for Null Values with proper Kafka Header Mapping #154
+57
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces enhancements and tests to handle JMS message headers, specifically addressing cases where headers may have
null
values. It ensures that null properties are correctly processed and optionally copied to Kafka headers based on configuration. The changes include updates to both the main implementation and corresponding test cases.Enhancements to JMS Header Processing:
src/main/java/com/ibm/eventstreams/connect/mqsource/processor/JmsToKafkaHeaderConverter.java
: Updated theconvertJmsPropertiesToKafkaHeaders
method to handlenull
JMS properties gracefully by usingObjects.toString
to convertnull
tonull
instead of throwing an exception.New Test Cases for JMS Header Handling:
src/integration/java/com/ibm/eventstreams/connect/mqsource/MQSourceTaskIT.java
: Added two integration tests:verifyJmsMessageWithNullHeaders
: Verifies that JMS message headers withnull
values are correctly copied to Kafka headers when the copy feature is enabled.verifyJmsMessageNoHeaderCopied_WhenCopyDisabledHavingNullHeader
: Ensures no headers are copied to Kafka when the copy feature is disabled, even if some headers havenull
values.src/test/java/com/ibm/eventstreams/connect/mqsource/JmsToKafkaHeaderConverterTest.java
: Enhanced the unit testconvertJmsPropertiesToKafkaHeaders
to include a scenario where one of the JMS properties isnull
, verifying that it is handled correctly.Minor Code Improvements:
src/main/java/com/ibm/eventstreams/connect/mqsource/processor/JmsToKafkaHeaderConverter.java
: Added an import forjava.util.Objects
to support the new null-handling logic.Fixes #145
Type of change
How Has This Been Tested?
Checklist