Skip to content

NIFI-15441 ListenUDP - include sending port in 'sender' attr; correct attr doc#10743

Merged
exceptionfactory merged 4 commits intoapache:mainfrom
greyp9:NIFI-15441
Jan 15, 2026
Merged

NIFI-15441 ListenUDP - include sending port in 'sender' attr; correct attr doc#10743
exceptionfactory merged 4 commits intoapache:mainfrom
greyp9:NIFI-15441

Conversation

@greyp9
Copy link
Copy Markdown
Contributor

@greyp9 greyp9 commented Jan 7, 2026

Summary

NIFI-15441

  • Update ListenUDP documentation to reflect output FlowFile attribute udp.port as being the listening port (do not change behavior).
  • Update ListenUDP output FlowFile attribute udp.sender to include remote port, via use of InetSocketAddress.toString(). Example: from /127.0.0.1 to /127.0.0.1:54545

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • [-] New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • [-] New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@exceptionfactory exceptionfactory changed the title ListenUDP - include sending port in 'sender' attr; correct attr doc NIFI-15441 ListenUDP - include sending port in 'sender' attr; correct attr doc Jan 8, 2026
Copy link
Copy Markdown
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for proposing this adjustment @greyp9.

Although changing udp.sender to include the port number preserves the host, the addition of the port may have an impact on flow designs that expect udp.sender to contain only the host address.

Given the long-standing nature of this FlowFile attribute value, it seems better to introduce the sending port in a different attribute, with udp.sender.port as a good potential option. That would provide the additional information, without changing the current definition of udp.sender.

@greyp9
Copy link
Copy Markdown
Contributor Author

greyp9 commented Jan 8, 2026

Thanks for proposing this adjustment @greyp9.

Although changing udp.sender to include the port number preserves the host, the addition of the port may have an impact on flow designs that expect udp.sender to contain only the host address.

Given the long-standing nature of this FlowFile attribute value, it seems better to introduce the sending port in a different attribute, with udp.sender.port as a good potential option. That would provide the additional information, without changing the current definition of udp.sender.

Thanks, sounds good.

this(sender, null, data, responder);
}

public StandardEvent(final String sender, final String senderPort, final byte[] data, final ChannelResponder<C> responder) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a second ctor here so as not to impact ListenUDPRecord. Not sure if we want to propagate the PR there as well.

mockEvents.add(new StandardEvent<>(sender1, message, responder));
mockEvents.add(new StandardEvent<>(sender2, message, responder));
mockEvents.add(new StandardEvent<>(sender2, message, responder));
mockEvents.add(new StandardEvent<>(sender1, senderPort1, message, responder));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm looking at this again, we may want to use the three arg ctor here?

Copy link
Copy Markdown
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @greyp9. The implementation looks good, I noted one more minor comment on a test assertion. I agree with keeping this scoped to ListenUDP, perhaps ListenUDPRecord could be considered in a separate Jira issue after this one is completed.

flowFile.assertContentEquals("This is message " + (i + 1));
assertEquals(String.valueOf(port), flowFile.getAttribute(ListenUDP.UDP_PORT_ATTR));
assertTrue(StringUtils.isNotEmpty(flowFile.getAttribute(ListenUDP.UDP_SENDER_ATTR)));
assertEquals(5, flowFile.getAttribute(ListenUDP.UDP_SENDER_PORT_ATTR).length()); // send port expected to be in ephemeral range
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On some machines, the ephemeral range starts with 1024. Instead of checking the length, using StringUtils.isNumeric() seems like a better check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On some machines, the ephemeral range starts with 1024. Instead of checking the length, using StringUtils.isNumeric() seems like a better check.

That's definitely better; thanks!

Copy link
Copy Markdown
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @greyp9, the latest version looks good, +1 merging

@exceptionfactory exceptionfactory merged commit 0024b1d into apache:main Jan 15, 2026
7 checks passed
mark-bathori pushed a commit to mark-bathori/nifi that referenced this pull request Feb 5, 2026
…che#10743)

Signed-off-by: David Handermann <exceptionfactory@apache.org>
yisun-anetac pushed a commit to Eng-Anetac/nifi that referenced this pull request Apr 4, 2026
…che#10743)

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants