File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
main/java/com/ibm/eventstreams/connect/mqsource/processor
test/java/com/ibm/eventstreams/connect/mqsource Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,13 @@ public ConnectHeaders convertJmsPropertiesToKafkaHeaders(final Message message)
4848
4949 jmsPropertyKeys .forEach (key -> {
5050 try {
51- connectHeaders .addString (key .toString (), message .getObjectProperty (key .toString ()).toString ());
51+ String value = "" ;
52+ if (message .getObjectProperty (key .toString ()) != null )
53+ {
54+ value = message .getObjectProperty (key .toString ()).toString ();
55+ }
56+ connectHeaders .addString (key .toString (), value );
57+ //connectHeaders.addString(key.toString(), message.getObjectProperty(key.toString()).toString());
5258 } catch (final JMSException e ) {
5359 // Not failing the message processing if JMS properties cannot be read for some
5460 // reason.
Original file line number Diff line number Diff line change @@ -44,22 +44,23 @@ public class JmsToKafkaHeaderConverterTest {
4444 @ Test
4545 public void convertJmsPropertiesToKafkaHeaders () throws JMSException {
4646
47- final List <String > keys = Arrays .asList ("facilityCountryCode" , "facilityNum" );
47+ final List <String > keys = Arrays .asList ("facilityCountryCode" , "facilityNum" , "nullProperty" );
4848
4949 final Enumeration <String > keyEnumeration = Collections .enumeration (keys );
5050
5151 // Arrange
5252 when (message .getPropertyNames ()).thenReturn (keyEnumeration );
5353 when (message .getObjectProperty ("facilityCountryCode" )).thenReturn ("US" );
5454 when (message .getObjectProperty ("facilityNum" )).thenReturn ("12345" );
55+ when (message .getObjectProperty ("nullProperty" )).thenReturn (null );
5556
5657 // Act
5758 final ConnectHeaders actualConnectHeaders = jmsToKafkaHeaderConverter
5859 .convertJmsPropertiesToKafkaHeaders (message );
5960
6061
6162 //Verify
62- assertEquals ("Both custom JMS properties were copied to kafka successfully." , 2 , actualConnectHeaders .size ());
63+ assertEquals ("Both custom JMS properties were copied to kafka successfully." , 3 , actualConnectHeaders .size ());
6364
6465
6566 }
You can’t perform that action at this time.
0 commit comments