nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pvill...@apache.org
Subject [nifi] branch main updated: NIFI-8654 Changed SNMP TestAgent to use getAvailableUdpPort()
Date Fri, 04 Jun 2021 21:11:02 GMT
This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 9af136a  NIFI-8654 Changed SNMP TestAgent to use getAvailableUdpPort()
9af136a is described below

commit 9af136ad13034d24c877b01000dec4e28134801d
Author: exceptionfactory <exceptionfactory@apache.org>
AuthorDate: Thu Jun 3 08:56:09 2021 -0500

    NIFI-8654 Changed SNMP TestAgent to use getAvailableUdpPort()
    
    Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>
    
    This closes #5120.
---
 .../src/test/java/org/apache/nifi/snmp/testagents/TestAgent.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/testagents/TestAgent.java
b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/testagents/TestAgent.java
index 02e4cc9..06ad0b3 100644
--- a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/testagents/TestAgent.java
+++ b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/testagents/TestAgent.java
@@ -44,19 +44,19 @@ public abstract class TestAgent extends BaseAgent {
 
     protected static final String BOOT_COUNTER_NAME_TEMPLATE = "target/bootCounter%s_%s.agent";
     protected static final String CONFIG_NAME_TEMPLATE = "target/conf%s_%s.agent";
-    protected final String host;
+    protected final String address;
     protected final int port;
 
     public TestAgent(final File bootCounterFile, final File configFile, final CommandProcessor
commandProcessor, final String host) {
         super(bootCounterFile, configFile, commandProcessor);
-        port = NetworkUtils.availablePort();
-        this.host = host + "/" + port;
+        port = NetworkUtils.getAvailableUdpPort();
+        this.address = String.format("udp:%s/%d", host, port);
     }
 
     @Override
     protected void initTransportMappings() {
         transportMappings = new TransportMapping[1];
-        final Address transportAddress = GenericAddress.parse(host);
+        final Address transportAddress = GenericAddress.parse(address);
         final TransportMapping<? extends Address> transportMapping = TransportMappings.getInstance().createTransportMapping(transportAddress);
         transportMappings[0] = transportMapping;
     }

Mime
View raw message