This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new b27b849caa NIFI-12188 Upgraded Commons Net from 3.9.0 to 3.10.0
b27b849caa is described below

commit b27b849caad6432be6a3b8a3aaebb2a3c1425d81
Author: exceptionfactory <exceptionfact...@apache.org>
AuthorDate: Fri Oct 6 08:23:27 2023 -0500

    NIFI-12188 Upgraded Commons Net from 3.9.0 to 3.10.0
    
    - Removed ProxyFTPClient extension of standard FTPClient no longer required 
following changes implemented in NET-650
    
    Signed-off-by: Pierre Villard <pierre.villard...@gmail.com>
    
    This closes #7855.
---
 .../processors/standard/ftp/ProxyFTPClient.java    | 55 ---------------
 .../standard/ftp/StandardFTPClientProvider.java    |  8 +--
 .../standard/ftp/ProxyFTPClientTest.java           | 78 ----------------------
 pom.xml                                            |  2 +-
 4 files changed, 4 insertions(+), 139 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClient.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClient.java
deleted file mode 100644
index 85ab10f923..0000000000
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClient.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.processors.standard.ftp;
-
-import org.apache.commons.net.ftp.FTPClient;
-
-import javax.net.SocketFactory;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Objects;
-
-/**
- * Proxy extension of FTP Client supporting connections using unresolved 
addresses
- */
-public class ProxyFTPClient extends FTPClient {
-    /**
-     * Proxy FTP Client constructor with required Socket Factory configured 
for proxy access
-     *
-     * @param socketFactory Socket Factory
-     */
-    public ProxyFTPClient(final SocketFactory socketFactory) {
-        setSocketFactory(Objects.requireNonNull(socketFactory, "Socket Factory 
required"));
-    }
-
-    /**
-     * Connect using host and port without attempting DNS resolution using 
InetAddress.getByName()
-     *
-     * @param host FTP host
-     * @param port FTP port number
-     * @throws IOException Thrown when failing to complete a socket connection
-     */
-    @Override
-    public void connect(final String host, final int port) throws IOException {
-        final InetSocketAddress socketAddress = new InetSocketAddress(host, 
port);
-
-        _socket_ = _socketFactory_.createSocket();
-
-        _socket_.connect(socketAddress, connectTimeout);
-        _connectAction_();
-    }
-}
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/StandardFTPClientProvider.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/StandardFTPClientProvider.java
index da2c3a22f7..e35346f9cd 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/StandardFTPClientProvider.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ftp/StandardFTPClientProvider.java
@@ -172,12 +172,10 @@ public class StandardFTPClientProvider implements 
FTPClientProvider {
 
         final Proxy.Type proxyType = proxyConfiguration.getProxyType();
 
-        FTPClient client;
-        if (Proxy.Type.DIRECT == proxyType) {
-            client = new FTPClient();
-        } else {
+        final FTPClient client = new FTPClient();
+        if (Proxy.Type.HTTP == proxyType || Proxy.Type.SOCKS == proxyType) {
             final SocketFactory socketFactory = 
SOCKET_FACTORY_PROVIDER.getSocketFactory(proxyConfiguration);
-            client = new ProxyFTPClient(socketFactory);
+            client.setSocketFactory(socketFactory);
             // Disable NAT workaround for proxy connections
             client.setPassiveNatWorkaroundStrategy(null);
         }
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClientTest.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClientTest.java
deleted file mode 100644
index a9ab69489a..0000000000
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/ftp/ProxyFTPClientTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.processors.standard.ftp;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import javax.net.SocketFactory;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.nio.charset.StandardCharsets;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-public class ProxyFTPClientTest {
-    @Mock
-    private SocketFactory socketFactory;
-
-    @Mock
-    private Socket socket;
-
-    @Captor
-    private ArgumentCaptor<InetSocketAddress> socketAddressCaptor;
-
-    private static final String HOST = "host.unresolved";
-
-    private static final String WELCOME_REPLY = "220 Welcome";
-
-    private ProxyFTPClient client;
-
-    @BeforeEach
-    public void setClient() {
-        client = new ProxyFTPClient(socketFactory);
-    }
-
-    @Test
-    public void testConnect() throws IOException {
-        when(socketFactory.createSocket()).thenReturn(socket);
-        when(socket.getInputStream()).thenReturn(new 
ByteArrayInputStream(WELCOME_REPLY.getBytes(StandardCharsets.US_ASCII)));
-        when(socket.getOutputStream()).thenReturn(new ByteArrayOutputStream());
-
-        client.connect(HOST, 0);
-
-        verify(socket).connect(socketAddressCaptor.capture(), anyInt());
-
-        final InetSocketAddress socketAddress = socketAddressCaptor.getValue();
-        assertNotNull(socketAddress);
-        assertEquals(HOST, socketAddress.getHostString());
-        assertEquals(0, socketAddress.getPort());
-    }
-}
diff --git a/pom.xml b/pom.xml
index d5a4aa8319..c0a48fe3c3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -114,7 +114,7 @@
         
<org.apache.commons.codec.version>1.16.0</org.apache.commons.codec.version>
         
<org.apache.commons.compress.version>1.24.0</org.apache.commons.compress.version>
         
<org.apache.commons.lang3.version>3.13.0</org.apache.commons.lang3.version>
-        <org.apache.commons.net.version>3.9.0</org.apache.commons.net.version>
+        <org.apache.commons.net.version>3.10.0</org.apache.commons.net.version>
         <org.apache.commons.io.version>2.14.0</org.apache.commons.io.version>
         
<org.apache.commons.text.version>1.10.0</org.apache.commons.text.version>
         
<org.apache.httpcomponents.httpclient.version>4.5.14</org.apache.httpcomponents.httpclient.version>

Reply via email to