From 370900b75edebec5f8fc4f069846b8f13a5d2dae Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 12 Jun 2026 07:29:46 +0200 Subject: [PATCH 1/5] Drop Mina and Netty from flume-ng-core Move the sources that pull in Apache Mina and Netty out of flume-ng-core into two new modules under flume-ng-sources: - flume-syslog-source (org.apache.flume.source.syslog): SyslogTcpSource, SyslogUDPSource, MultiportSyslogTCPSource and their shared parser/utils - flume-netcat-source (org.apache.flume.source.netcat): NetcatUdpSource The classes are repackaged so each module owns a distinct package, keeping the modules JPMS-friendly (no split packages). The short source aliases in SourceType keep working; only the target FQCNs change. flume-ng-core no longer depends on io.netty:netty-all or org.apache.mina:mina-core. The TLS unit tests no longer rely on checked-in keystore/PEM blobs: the X509Certificates helper moves to the flume-ng-sdk test-jar alongside a new TestKeyStores helper, and the stores are generated in memory with Bouncy Castle. The orphaned test resources are deleted. Also remove the dead Netty PatternRule class (no references). Assisted-By: Claude Opus 4.8 --- flume-bom/pom.xml | 10 ++ .../apache/flume/conf/source/SourceType.java | 8 +- flume-ng-core/pom.xml | 10 -- .../flume/netty/filter/PatternRule.java | 160 ------------------ .../source/TestDefaultSourceFactory.java | 4 - .../src/test/resources/certs/gencerts.sh | 31 ---- .../src/test/resources/certs/rootca.conf | 9 - .../src/test/resources/certs/server.conf | 9 - .../src/test/resources/keystorefile.jks | Bin 3518 -> 0 bytes .../src/test/resources/server.flume-crt.pem | 17 -- .../test/resources/server.flume-keystore.p12 | Bin 2447 -> 0 bytes .../src/test/resources/server.flume.pem | 23 --- flume-ng-core/src/test/resources/server.p12 | Bin 1637 -> 0 bytes .../src/test/resources/truststore.jks | Bin 687 -> 0 bytes .../src/test/resources/truststorefile.jks | Bin 775 -> 0 bytes flume-ng-dist/pom.xml | 8 + flume-ng-sdk/pom.xml | 13 ++ .../org/apache/flume/util/TestKeyStores.java | 77 +++++++++ .../apache/flume/util}/X509Certificates.java | 8 +- .../flume/source/http/TestHTTPSource.java | 26 +-- flume-ng-sources/flume-netcat-source/pom.xml | 58 +++++++ .../flume/source/netcat}/NetcatUdpSource.java | 3 +- .../source/netcat}/TestNetcatUdpSource.java | 2 +- flume-ng-sources/flume-syslog-source/pom.xml | 104 ++++++++++++ .../syslog}/MultiportSyslogTCPSource.java | 3 +- .../flume/source/syslog}/SyslogParser.java | 2 +- .../SyslogSourceConfigurationConstants.java | 2 +- .../flume/source/syslog}/SyslogTcpSource.java | 3 +- .../flume/source/syslog}/SyslogUDPSource.java | 3 +- .../flume/source/syslog}/SyslogUtils.java | 2 +- .../syslog}/TestMultiportSyslogTCPSource.java | 18 +- .../source/syslog}/TestSyslogParser.java | 2 +- .../source/syslog}/TestSyslogTcpSource.java | 20 ++- .../source/syslog}/TestSyslogUdpSource.java | 2 +- .../flume/source/syslog}/TestSyslogUtils.java | 2 +- flume-ng-sources/pom.xml | 2 + 36 files changed, 331 insertions(+), 310 deletions(-) delete mode 100644 flume-ng-core/src/main/java/org/apache/flume/netty/filter/PatternRule.java delete mode 100755 flume-ng-core/src/test/resources/certs/gencerts.sh delete mode 100644 flume-ng-core/src/test/resources/certs/rootca.conf delete mode 100644 flume-ng-core/src/test/resources/certs/server.conf delete mode 100644 flume-ng-core/src/test/resources/keystorefile.jks delete mode 100644 flume-ng-core/src/test/resources/server.flume-crt.pem delete mode 100644 flume-ng-core/src/test/resources/server.flume-keystore.p12 delete mode 100644 flume-ng-core/src/test/resources/server.flume.pem delete mode 100644 flume-ng-core/src/test/resources/server.p12 delete mode 100644 flume-ng-core/src/test/resources/truststore.jks delete mode 100644 flume-ng-core/src/test/resources/truststorefile.jks create mode 100644 flume-ng-sdk/src/test/java/org/apache/flume/util/TestKeyStores.java rename {flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http => flume-ng-sdk/src/test/java/org/apache/flume/util}/X509Certificates.java (94%) create mode 100644 flume-ng-sources/flume-netcat-source/pom.xml rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-netcat-source/src/main/java/org/apache/flume/source/netcat}/NetcatUdpSource.java (98%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat}/TestNetcatUdpSource.java (99%) create mode 100644 flume-ng-sources/flume-syslog-source/pom.xml rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/MultiportSyslogTCPSource.java (99%) rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/SyslogParser.java (99%) rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/SyslogSourceConfigurationConstants.java (98%) rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/SyslogTcpSource.java (98%) rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/SyslogUDPSource.java (98%) rename {flume-ng-core/src/main/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog}/SyslogUtils.java (99%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog}/TestMultiportSyslogTCPSource.java (97%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog}/TestSyslogParser.java (99%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog}/TestSyslogTcpSource.java (94%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog}/TestSyslogUdpSource.java (99%) rename {flume-ng-core/src/test/java/org/apache/flume/source => flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog}/TestSyslogUtils.java (99%) diff --git a/flume-bom/pom.xml b/flume-bom/pom.xml index 774b2cab9b..97cf0ad7c2 100644 --- a/flume-bom/pom.xml +++ b/flume-bom/pom.xml @@ -217,6 +217,16 @@ flume-taildir-source ${flume-taildir.version} + + org.apache.flume.flume-ng-sources + flume-syslog-source + ${project.version} + + + org.apache.flume.flume-ng-sources + flume-netcat-source + ${project.version} + org.apache.flume flume-shared-kafka diff --git a/flume-ng-configuration/src/main/java/org/apache/flume/conf/source/SourceType.java b/flume-ng-configuration/src/main/java/org/apache/flume/conf/source/SourceType.java index f26bb59467..5792d8dcea 100644 --- a/flume-ng-configuration/src/main/java/org/apache/flume/conf/source/SourceType.java +++ b/flume-ng-configuration/src/main/java/org/apache/flume/conf/source/SourceType.java @@ -61,21 +61,21 @@ public enum SourceType implements ComponentWithClassName { * * @see org.apache.flume.source.SyslogTcpSource */ - SYSLOGTCP("org.apache.flume.source.SyslogTcpSource"), + SYSLOGTCP("org.apache.flume.source.syslog.SyslogTcpSource"), /** * MultiportSyslogTCPSource * * @see org.apache.flume.source.MultiportSyslogTCPSource */ - MULTIPORT_SYSLOGTCP("org.apache.flume.source.MultiportSyslogTCPSource"), + MULTIPORT_SYSLOGTCP("org.apache.flume.source.syslog.MultiportSyslogTCPSource"), /** * SyslogUDPSource * * @see org.apache.flume.source.SyslogUDPSource */ - SYSLOGUDP("org.apache.flume.source.SyslogUDPSource"), + SYSLOGUDP("org.apache.flume.source.syslog.SyslogUDPSource"), /** * Spool directory source @@ -117,7 +117,7 @@ public enum SourceType implements ComponentWithClassName { * * @see org.apache.flume.source.NetcatUdpSource */ - NETCATUDP("org.apache.flume.source.NetcatUdpSource"); + NETCATUDP("org.apache.flume.source.netcat.NetcatUdpSource"); private final String sourceClassName; diff --git a/flume-ng-core/pom.xml b/flume-ng-core/pom.xml index b33f5c71c5..4c75ace44e 100644 --- a/flume-ng-core/pom.xml +++ b/flume-ng-core/pom.xml @@ -133,11 +133,6 @@ commons-lang - - io.netty - netty-all - - org.apache.httpcomponents httpclient @@ -156,11 +151,6 @@ test - - org.apache.mina - mina-core - - diff --git a/flume-ng-core/src/main/java/org/apache/flume/netty/filter/PatternRule.java b/flume-ng-core/src/main/java/org/apache/flume/netty/filter/PatternRule.java deleted file mode 100644 index 31cc2b67cd..0000000000 --- a/flume-ng-core/src/main/java/org/apache/flume/netty/filter/PatternRule.java +++ /dev/null @@ -1,160 +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.flume.netty.filter; - -import io.netty.handler.ipfilter.IpFilterRule; -import io.netty.handler.ipfilter.IpFilterRuleType; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class PatternRule represents an IP filter rule using string patterns. - *
- * Rule Syntax: - *
- *
- * Rule ::= [n|i]:address          n stands for computer name, i for ip address
- * address ::= <regex> | localhost
- * regex is a regular expression with '*' as multi character and '?' as single character wild card
- * 
- *
- * Example: allow localhost: - *
- * new PatternRule(true, "n:localhost") - *
- * Example: allow local lan: - *
- * new PatternRule(true, "i:192.168.0.*") - *
- * Example: block all - *
- * new PatternRule(false, "n:*") - *
- *

- * For some reason Netty 4 didn't copy this from Netty 3. The code was copied from the Netty 3 PatternRule - * and modifed as required to match the new version of IpFilterRule. - */ -public class PatternRule implements IpFilterRule { - - private static final Logger logger = LoggerFactory.getLogger(PatternRule.class); - private static final String LOCALHOST = "127.0.0.1"; - private final IpFilterRuleType ruleType; - private Pattern ipPattern; - private Pattern namePattern; - private boolean localhost; - - /** - * Construct the IpFilterRule from a pattern. - * - * @param ruleType The RuleType (accept or deny) - * @param pattern The pattern. - */ - public PatternRule(IpFilterRuleType ruleType, String pattern) { - this.ruleType = ruleType; - parse(pattern); - } - - private static String addRule(String pattern, String rule) { - if (rule == null || rule.length() == 0) { - return pattern; - } - if (pattern.length() != 0) { - pattern += "|"; - } - rule = rule.replaceAll("\\.", "\\\\."); - rule = rule.replaceAll("\\*", ".*"); - rule = rule.replaceAll("\\?", "."); - pattern += '(' + rule + ')'; - return pattern; - } - - private static boolean isLocalhost(InetAddress address) { - try { - if (address.equals(InetAddress.getLocalHost())) { - return true; - } - } catch (UnknownHostException e) { - if (logger.isInfoEnabled()) { - logger.info("error getting ip of localhost", e); - } - } - try { - InetAddress[] addrs = InetAddress.getAllByName(LOCALHOST); - for (InetAddress addr : addrs) { - if (addr.equals(address)) { - return true; - } - } - } catch (UnknownHostException e) { - if (logger.isInfoEnabled()) { - logger.info("error getting ip of localhost", e); - } - } - return false; - } - - @Override - public boolean matches(InetSocketAddress inetSocketAddress) { - InetAddress inetAddress = inetSocketAddress.getAddress(); - if (localhost && isLocalhost(inetAddress)) { - return true; - } - if (ipPattern != null && ipPattern.matcher(inetAddress.getHostAddress()).matches()) { - return true; - } - if (namePattern != null) { - return namePattern.matcher(inetAddress.getHostName()).matches(); - } - return false; - } - - @Override - public IpFilterRuleType ruleType() { - return ruleType; - } - - private void parse(String pattern) { - if (pattern == null) { - return; - } - - String[] acls = pattern.split(","); - - String ip = ""; - String name = ""; - for (String c : acls) { - c = c.trim(); - if ("n:localhost".equals(c)) { - localhost = true; - } else if (c.startsWith("n:")) { - name = addRule(name, c.substring(2)); - } else if (c.startsWith("i:")) { - ip = addRule(ip, c.substring(2)); - } - } - if (ip.length() != 0) { - ipPattern = Pattern.compile(ip); - } - if (name.length() != 0) { - namePattern = Pattern.compile(name); - } - } -} diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestDefaultSourceFactory.java b/flume-ng-core/src/test/java/org/apache/flume/source/TestDefaultSourceFactory.java index df445b6ccb..08897f919c 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestDefaultSourceFactory.java +++ b/flume-ng-core/src/test/java/org/apache/flume/source/TestDefaultSourceFactory.java @@ -60,11 +60,7 @@ private void verifySourceCreation(String name, String type, Class typeClass) public void testSourceCreation() throws Exception { verifySourceCreation("seq-src", "seq", SequenceGeneratorSource.class); verifySourceCreation("netcat-src", "netcat", NetcatSource.class); - verifySourceCreation("netcat-udp-src", "netcatudp", NetcatUdpSource.class); verifySourceCreation("exec-src", "exec", ExecSource.class); - verifySourceCreation("syslogtcp-src", "syslogtcp", SyslogTcpSource.class); - verifySourceCreation("multiport_syslogtcp-src", "multiport_syslogtcp", MultiportSyslogTCPSource.class); - verifySourceCreation("syslogudp-src", "syslogudp", SyslogUDPSource.class); // verifySourceCreation("spooldir-src", "spooldir", SpoolDirectorySource.class); // verifySourceCreation("thrift-src", "thrift", ThriftSource.class); verifySourceCreation("custom-src", MockSource.class.getCanonicalName(), MockSource.class); diff --git a/flume-ng-core/src/test/resources/certs/gencerts.sh b/flume-ng-core/src/test/resources/certs/gencerts.sh deleted file mode 100755 index 0fb0263de8..0000000000 --- a/flume-ng-core/src/test/resources/certs/gencerts.sh +++ /dev/null @@ -1,31 +0,0 @@ -mkdir tmp -rm ../truststorefile.jks -rm ../keystorefile.jks -rm ../server.flume-keystore.p12 -# Create the CA key and certificate -openssl req -config rootca.conf -new -x509 -nodes -keyout tmp/flume-cacert.key -out tmp/flume-ca.crt -days 10960 -# Create the trust store and import the certificate -keytool -keystore ../truststorefile.jks -storetype jks -importcert -file 'tmp/flume-ca.crt' -keypass password -storepass password -alias flume-cacert -noprompt -#Import the root certificate -keytool -keystore ../keystorefile.jks -alias flume-ca -importcert -file tmp/flume-ca.crt -keypass password -storepass password -noprompt -# Create the client private key in the client key store -keytool -genkeypair -keyalg RSA -alias client -keystore ../keystorefile.jks -storepass password -keypass password -validity 10960 -keysize 2048 -dname "CN=client.flume, C=US" -# Create a signing request for the client # -keytool -keystore ../keystorefile.jks -alias client -certreq -file tmp/client.csr -keypass password -storepass password -# Sign the client certificate -openssl x509 -req -CA 'tmp/flume-ca.crt' -CAkey 'tmp/flume-cacert.key' -in tmp/client.csr -out tmp/client.crt_signed -days 10960 -CAcreateserial -passin pass:password -# Verify the signed certificate -openssl verify -CAfile 'tmp/flume-ca.crt' tmp/client.crt_signed -#Import the client's signed certificate -keytool -keystore ../keystorefile.jks -alias client -importcert -file tmp/client.crt_signed -keypass password -storepass password -noprompt -#Verify the keystore -keytool -list -v -keystore ../keystorefile.jks -storepass password -# Create the server private key in the server key store -keytool -genkeypair -keyalg RSA -alias server -keystore ../server.flume-keystore.p12 -storepass password -storetype PKCS12 -keypass password -validity 10960 -keysize 2048 -dname "CN=server.flume, C=US" -# Create a signing request for the server # -keytool -keystore ../server.flume-keystore.p12 -alias server -certreq -file tmp/server.csr -keypass password -storepass password -# Sign the server certificate -openssl x509 -req -CA 'tmp/flume-ca.crt' -CAkey 'tmp/flume-cacert.key' -in tmp/server.csr -out ../server.flume-crt.pem -days 10960 -CAcreateserial -passin pass:password -# Extract the private key -openssl pkcs12 -in ../server.flume-keystore.p12 -passin pass:password -nokeys -out ../server.flume.pem -rm -rf tmp diff --git a/flume-ng-core/src/test/resources/certs/rootca.conf b/flume-ng-core/src/test/resources/certs/rootca.conf deleted file mode 100644 index 722e9c39bc..0000000000 --- a/flume-ng-core/src/test/resources/certs/rootca.conf +++ /dev/null @@ -1,9 +0,0 @@ -[ req ] -distinguished_name = CA_DN -prompt = no -output_password = password -default_bits = 2048 - -[ CA_DN ] -C = US -CN = flume-ca diff --git a/flume-ng-core/src/test/resources/certs/server.conf b/flume-ng-core/src/test/resources/certs/server.conf deleted file mode 100644 index 7a9fb58356..0000000000 --- a/flume-ng-core/src/test/resources/certs/server.conf +++ /dev/null @@ -1,9 +0,0 @@ -[ req ] -distinguished_name = CA_DN -prompt = no -output_password = password -default_bits = 2048 - -[ CA_DN ] -C = US -CN = server.flume diff --git a/flume-ng-core/src/test/resources/keystorefile.jks b/flume-ng-core/src/test/resources/keystorefile.jks deleted file mode 100644 index d62e957925330ff91081544bb593c0ba34d73146..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3518 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 E0E(*o(f|Me diff --git a/flume-ng-core/src/test/resources/server.flume-crt.pem b/flume-ng-core/src/test/resources/server.flume-crt.pem deleted file mode 100644 index 9e3774427d..0000000000 --- a/flume-ng-core/src/test/resources/server.flume-crt.pem +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICwjCCAaoCCQD8AQyla5FbDjANBgkqhkiG9w0BAQsFADAgMQswCQYDVQQGEwJV -UzERMA8GA1UEAwwIZmx1bWUtY2EwIBcNMjMwMzIyMDAyODM0WhgPMjA1MzAzMjQw -MDI4MzRaMCQxCzAJBgNVBAYTAlVTMRUwEwYDVQQDEwxzZXJ2ZXIuZmx1bWUwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEEAUShlX2lWDYiEgcZL1JzWFw -auNkdxOGo1DtD3YaZdrU1GS2UwspLm0qcSFEF1Sx6uVTABdgjZGnxJLSTJkabVu/ -iMuP+EQrE/4AWJoyuuaYMSG0EGeP+mttTtLHYyt/k9NJkABYxFZkNqdDuo+lF/Vs -QdW3icym0vqMwiIvE+VKw9j3F+zFZizfx6MiBH0uuNrXHFCNUg52/cbeyiXO1mks -yruOV+PF8/44zAepjLWiJgp7Wo6ejXmLvR+k68RwB5V7fXrzPYueM9GQDmLffkdO -ZhrcafiRFGlzWSmC820Eb2b5+cVnm96XAlUXE5ao5o58oMmcufMnJ5k2UbFJAgMB -AAEwDQYJKoZIhvcNAQELBQADggEBAHBGpqraT39aw/HVrJdmpsw8CwSmdiir+NYk -5PprbIKAyf/P/9ObKcqesO8d8CQZVvzzm+Ok2rgcALDIl/TbbAVUPizIrN4AiH+Z -BPOqDFF4taWkw73iMDiq61QS8SpJIOxxmL8PsK5eefuABrpumnVgW5X9BT/uMIqW -NOwiyII3NVvtlErcdAL/ZTYWc3S8CEWVRc88ZpIBSLB4/tqQbPM+m+ZtYMSKi3Sh -ugOjonPuteeQqu6R7HRYOajepKdGe048Moq90v0IrDI8v+rbezLFpEWOnG0fUDEq -LfA9l7e/q1ukXRW4ccJWZWXLrZbEbX5hJeTlyYhHciwB5jfueMM= ------END CERTIFICATE----- diff --git a/flume-ng-core/src/test/resources/server.flume-keystore.p12 b/flume-ng-core/src/test/resources/server.flume-keystore.p12 deleted file mode 100644 index da51f355d1082ae5f95403474f6fbb6f4dc4d1ea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2447 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 ARsaA1 diff --git a/flume-ng-core/src/test/resources/server.flume.pem b/flume-ng-core/src/test/resources/server.flume.pem deleted file mode 100644 index 6bc71ed797..0000000000 --- a/flume-ng-core/src/test/resources/server.flume.pem +++ /dev/null @@ -1,23 +0,0 @@ -Bag Attributes - friendlyName: server - localKeyID: 54 69 6D 65 20 31 36 37 39 34 34 34 39 31 33 33 33 39 -subject=/C=US/CN=server.flume -issuer=/C=US/CN=server.flume ------BEGIN CERTIFICATE----- -MIIC6TCCAdGgAwIBAgIEMlDgqzANBgkqhkiG9w0BAQsFADAkMQswCQYDVQQGEwJV -UzEVMBMGA1UEAxMMc2VydmVyLmZsdW1lMCAXDTIzMDMyMjAwMjgzM1oYDzIwNTMw -MzI0MDAyODMzWjAkMQswCQYDVQQGEwJVUzEVMBMGA1UEAxMMc2VydmVyLmZsdW1l -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxBAFEoZV9pVg2IhIHGS9 -Sc1hcGrjZHcThqNQ7Q92GmXa1NRktlMLKS5tKnEhRBdUserlUwAXYI2Rp8SS0kyZ -Gm1bv4jLj/hEKxP+AFiaMrrmmDEhtBBnj/prbU7Sx2Mrf5PTSZAAWMRWZDanQ7qP -pRf1bEHVt4nMptL6jMIiLxPlSsPY9xfsxWYs38ejIgR9Lrja1xxQjVIOdv3G3sol -ztZpLMq7jlfjxfP+OMwHqYy1oiYKe1qOno15i70fpOvEcAeVe3168z2LnjPRkA5i -335HTmYa3Gn4kRRpc1kpgvNtBG9m+fnFZ5velwJVFxOWqOaOfKDJnLnzJyeZNlGx -SQIDAQABoyEwHzAdBgNVHQ4EFgQUClD6FZ+qPIFrtBaz0swRTtWt1WEwDQYJKoZI -hvcNAQELBQADggEBALuX9E+tRWvvA9uULj9Iq+k9iUNMQzkmyzXGu7hY46ZU9lx+ -fNnLZq82zz9rHq8IhK4HsLIsPCLfNeXwG/TNR4zUHKI53lzkburxgu76soMUDbHX -8udyUgrs0YjQcppw6IOOmlZtgNeF2nu7jeoXrCaA07yXzehAqukHv7glWaV3oORc -rDkZvHfJ2G7hPbUYYIeouJsbG9rNukNPOY9JEYGFYzDxZ8hlFt7Lp/icbdpjFGDV -tkMtPpVz59B47j/Kk/k5zxaDLnD42svL8GByyM5UxvAqAlYnfMKiZqXfY0JbCpMC -e9Z5xOyt9F8NLFyjRsmBlJD61LuLb8hAZK/Ho70= ------END CERTIFICATE----- diff --git a/flume-ng-core/src/test/resources/server.p12 b/flume-ng-core/src/test/resources/server.p12 deleted file mode 100644 index 07eef5168f26c490dce6784c3fd7d585f565db9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1637 zcmY+DdpOez7{_<{Z4B886Y)eDWt9yFC99UZT*5+9E}2{-bD8FH)=*}ZH8GW#h=W|> zbh3(CX=qZpZDBD-E>V<6NRFQ8oYOgfywCeQ-|zFje|}gpah2FlmYo20a@s! zJaQETA`eQVLxgRmo-lcn*hi%y>Dxn3_|9mIs3*7UNcxkD&^e=@sdhcmr)l@p4wz2nUbFtfoR<^v;^SXMjJF~-#z};}4 z>0iw##V%Un4mITU#{1kP$=r;bt0OB1hG`jopPZU8211J|cEf1Rm(3Ov!|%6iYUIiM z3c0a^S22OtxR)2WyTd_B9OGo8yhQwsZRSvw$k#PKf$bbS$}cMg6@6@P)#@mnc|ojU zZ2Z}L`(=Tk)Mb!O?gvfx3eu&-qpXUj=Ny>4$j+WSi5V-SdrSP0&%1fw%$C4TLC_t} zx$BaGJe0{o!}&&jyhSFFynY<>uKczltj(A*TjqB=5p+76T$vBquaodub+hJ9Dzn{* zxlMPPFCid5eS-Q(T}gT0%--P5!}|g(AHNFLTk?XbpoPtq42A1EGuX$ne2yTozD&pF zP=KgjSxp$6zV_C|`GJbTQ04G$-;-V&?NO%5ZMy(#Y1o}H0^x;ZR`=Xn>&c4`Cve%? z6uZ!vG^6X#39iyy_R)HzR;X6g$sKcBIGm<4*#{od=kO>yXZogY~MCm4}g0j5z zY1o8m7)Q&IR%iTZ@nVPi7;;h0U9zf-*KQTRd4L79G$oN`73wRxDQn;_{s;UbI%E={ zL&nzPk+m6uEB>Q_0vNJZmaT=n|JeckVTS`jo|eOX;_<_dwevK`qTtc5(=GA%@=z0* zIx9L|`vtdkVq`30mD(d&7`xLutLH8wAw|WPE)-y-692~9QwAb$?@dA4o6SYrOru-aYi`z5~FZTPOSMkwZ-bS;f5URB>VnU+P)gO|C7; zZhRl)#7rLyiW0w!@hC7lUAv09+_WEQGjArBtEMs({S|_D=yI~BvOn^uxe2RhGv z%*cgyLcexx%H#Uf;%_m{F2^Yt-%eRF@Vh@z?>lV;+&u0owu}Mq>4>hKxpg8zMXwwO zv8u1*e?DdCFB&aan%hF{QP^e)edd_ zhkF_e>$cH4qmPX={U#pw=ix(=zUi3b<<3NI@{sc?NXKH_q$M|BmS|tqpH669hM@Y9 zC0k72Sc3}t0%&R02b;Dg6K^!2SSpGH`Z1*IY%*ACfEmf>o0>6*iTubm1Q2H;4nB(f zLWH?5a(U}xB8Edk2{tip?92+Q#9cbKY!Anh+}o}_O-bx7=_1>IxqZYtX8^FquAAxX z`RHLuyT9RqNd&`i^~Uvmnfm1^DKx20Ya7-_W@+FA1_()l3sq$o!MjxLNgwLzSL~MY z7~Ix>sYa;b(SYi4ZZleJ^u2FWk#_Mi>En<_aBnyckJH5=;4rK*6ru?O0jgmd#iE@t e>dgShdgDV1=>7}3cI%V? diff --git a/flume-ng-core/src/test/resources/truststore.jks b/flume-ng-core/src/test/resources/truststore.jks deleted file mode 100644 index 8c08349e0ff310b51fea4f7fc66a04b516550d2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 687 zcmezO_TO6u1_mY|W(3omIr+(nIT`uIB|s6I1C2Z{7+53pObsl7igFE_m@*BT7%wq# zGA!zuuPb@6aH#<=8>d#AN85K^Mn+av27^jNZUas>=1>+kVW!YvLqP+65QjsU!#A<0 zGAA)F#gNZ{2PDKU%<7b1o|$T>Y@i6@a|ug179=KTq$&jGreEuOmYtTJP%{CvuCDX-2;hxEO(>K-U=FxRzT02zYn!)mE&Zd)z4MTIgVEagFD5cEGcqtDI}aF* z%s_W_T1{W~>Eeucx9zNsl!<&z*jcyumsR`5NU^}$O$#>hzqvQ}#hHbd)@Ri-E2vA@ z-=37*_&U9H{r&$Z`MuSx*ncWBue@_TRzSgeg7aFozV}6f&T1#$aBll`JHlhttvHUT zk5$_9TdhuN$E)!~u6^TuezWY;h2?u)`*U=)&J{{Ze7&+M_MA~BxqK>{XF0V2$3VpKx5n30u%xrvdV0q8a^rY1&4 zhD$*o&X~1)XZWqdFkyFSZyLR&Jt$;%*Rjk<+|1+K(%W}Ob@?e8O zK;i4iW1AmoWj)^)$z8tj&Kau{nU*J89zC8N6rMZbpw#g|zUABfG`dfJSa7~E-|tf> z*J{Xkz_c2d1c_DOC*ohRF}GVe$v{9o=?WNzx$vdJF%%r z#{2#b<5%9BYXnbdGchwVFd~N#FlvAy#K^EfrGA!HNYcB|#jA`o-h`dbdMBV7{WU(d z_pJD2XT}8e@bo@eMVph(USCD-zIbiftNmuhrOZF_fj@Zdg&%)etKQUfXNlFMiikA7|zInk9Jnz9?W{@p^C6I)#p> z!VgZS+i#LjOZEv)f0y#E!S#UD<~9~F&QGDACM{dLO=P)|f`(~iep;1xoPh&dUS)*P zrk4Fj_MLohV(8aA_aVch?DqDYXmO)i{@%%ro1Cmd?Vm1xazQ}cWu^Zg Ilj+3^0ju9XaR2}S diff --git a/flume-ng-dist/pom.xml b/flume-ng-dist/pom.xml index 7bfe274287..0f328cb819 100644 --- a/flume-ng-dist/pom.xml +++ b/flume-ng-dist/pom.xml @@ -150,6 +150,14 @@ org.apache.flume.flume-ng-sources flume-taildir-source + + org.apache.flume.flume-ng-sources + flume-syslog-source + + + org.apache.flume.flume-ng-sources + flume-netcat-source + org.apache.flume flume-ng-environment-variable-config-filter diff --git a/flume-ng-sdk/pom.xml b/flume-ng-sdk/pom.xml index dc47f42b1a..eaaf42b6bc 100644 --- a/flume-ng-sdk/pom.xml +++ b/flume-ng-sdk/pom.xml @@ -44,6 +44,19 @@ test + + + org.bouncycastle + bcpkix-jdk18on + test + + + + org.bouncycastle + bcprov-jdk18on + test + + org.slf4j slf4j-api diff --git a/flume-ng-sdk/src/test/java/org/apache/flume/util/TestKeyStores.java b/flume-ng-sdk/src/test/java/org/apache/flume/util/TestKeyStores.java new file mode 100644 index 0000000000..7be6500271 --- /dev/null +++ b/flume-ng-sdk/src/test/java/org/apache/flume/util/TestKeyStores.java @@ -0,0 +1,77 @@ +/* + * 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.flume.util; + +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.KeyPair; +import java.security.KeyStore; +import java.security.cert.X509Certificate; + +/** + * Test helper that builds key and trust stores backed by a single self-signed certificate, + * so SSL tests can generate their TLS material in memory instead of shipping keystore files. + */ +public final class TestKeyStores { + + private final KeyPair keyPair; + private final X509Certificate certificate; + + private TestKeyStores(KeyPair keyPair, X509Certificate certificate) { + this.keyPair = keyPair; + this.certificate = certificate; + } + + /** + * Generates a self-signed credential for the given distinguished name (for example {@code CN=localhost}). + */ + public static TestKeyStores selfSigned(String dname) throws Exception { + KeyPair keyPair = X509Certificates.generateKeyPair(); + X509Certificate certificate = X509Certificates.generateSelfSignedCertificate(keyPair, dname); + return new TestKeyStores(keyPair, certificate); + } + + public X509Certificate certificate() { + return certificate; + } + + /** A keystore of the given type holding the private key and certificate under alias {@code key}. */ + public KeyStore keyStore(String type, String password) throws Exception { + KeyStore ks = KeyStore.getInstance(type); + ks.load(null, null); + ks.setKeyEntry("key", keyPair.getPrivate(), password.toCharArray(), new X509Certificate[] {certificate}); + return ks; + } + + /** A truststore of the given type holding only the certificate under alias {@code cert}. */ + public KeyStore trustStore(String type) throws Exception { + KeyStore ts = KeyStore.getInstance(type); + ts.load(null, null); + ts.setCertificateEntry("cert", certificate); + return ts; + } + + /** Writes {@link #keyStore} to {@code file} and returns its path. */ + public Path writeKeyStore(Path file, String type, String password) throws Exception { + KeyStore ks = keyStore(type, password); + try (OutputStream out = Files.newOutputStream(file)) { + ks.store(out, password.toCharArray()); + } + return file; + } +} diff --git a/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/X509Certificates.java b/flume-ng-sdk/src/test/java/org/apache/flume/util/X509Certificates.java similarity index 94% rename from flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/X509Certificates.java rename to flume-ng-sdk/src/test/java/org/apache/flume/util/X509Certificates.java index c98ece50f3..ac38450025 100644 --- a/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/X509Certificates.java +++ b/flume-ng-sdk/src/test/java/org/apache/flume/util/X509Certificates.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source.http; +package org.apache.flume.util; import java.math.BigInteger; import java.security.KeyPair; @@ -37,7 +37,7 @@ /** * Utility class to generate X.509 certificates for testing purposes. */ -final class X509Certificates { +public final class X509Certificates { private static final long MINUTE_IN_MILLIS = 60_000L; private static final long YEAR_IN_MILLIS = 365L * 24 * 60 * MINUTE_IN_MILLIS; @@ -54,7 +54,7 @@ final class X509Certificates { } } - static KeyPair generateKeyPair() { + public static KeyPair generateKeyPair() { return RSA_GENERATOR.generateKeyPair(); } @@ -66,7 +66,7 @@ static KeyPair generateKeyPair() { * @return a self-signed X.509 server certificate * @throws Exception if certificate creation or signing fails */ - static X509Certificate generateSelfSignedCertificate(KeyPair keyPair, String subjectDn) throws Exception { + public static X509Certificate generateSelfSignedCertificate(KeyPair keyPair, String subjectDn) throws Exception { long now = System.currentTimeMillis(); Date notBefore = new Date(now - MINUTE_IN_MILLIS); Date notAfter = new Date(now + YEAR_IN_MILLIS); diff --git a/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/TestHTTPSource.java b/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/TestHTTPSource.java index fc950b8d76..9c674cbc87 100644 --- a/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/TestHTTPSource.java +++ b/flume-ng-sources/flume-http-source/src/test/java/org/apache/flume/source/http/TestHTTPSource.java @@ -24,8 +24,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import jakarta.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.reflect.Type; @@ -35,9 +33,7 @@ import java.net.Socket; import java.net.URL; import java.net.UnknownHostException; -import java.security.KeyPair; import java.security.KeyStore; -import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -65,6 +61,7 @@ import org.apache.flume.conf.Configurables; import org.apache.flume.event.JSONEvent; import org.apache.flume.instrumentation.SourceCounter; +import org.apache.flume.util.TestKeyStores; import org.apache.flume.util.Whitebox; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; @@ -147,23 +144,12 @@ private static Context getDefaultSecureContextGlobalKeystore(int port) throws IO private static KeyStore trustStore; private static void generateSslStores() throws Exception { - KeyPair keyPair = X509Certificates.generateKeyPair(); - X509Certificate certificate = X509Certificates.generateSelfSignedCertificate(keyPair, "CN=localhost"); - - KeyStore keyStore = KeyStore.getInstance("JKS"); - keyStore.load(null, null); - keyStore.setKeyEntry( - "jetty", keyPair.getPrivate(), KEYSTORE_PASSWORD.toCharArray(), new X509Certificate[] {certificate}); - File keystoreFile = TEMP_FOLDER.newFile("keystore.jks"); - try (FileOutputStream out = new FileOutputStream(keystoreFile)) { - keyStore.store(out, KEYSTORE_PASSWORD.toCharArray()); - } - serverKeystorePath = keystoreFile.getAbsolutePath(); - + TestKeyStores credentials = TestKeyStores.selfSigned("CN=localhost"); + serverKeystorePath = credentials + .writeKeyStore(TEMP_FOLDER.newFile("keystore.jks").toPath(), "JKS", KEYSTORE_PASSWORD) + .toString(); // The test client only needs to trust the self-signed server certificate. - trustStore = KeyStore.getInstance("JKS"); - trustStore.load(null, null); - trustStore.setCertificateEntry("server", certificate); + trustStore = credentials.trustStore("JKS"); } @BeforeClass diff --git a/flume-ng-sources/flume-netcat-source/pom.xml b/flume-ng-sources/flume-netcat-source/pom.xml new file mode 100644 index 0000000000..3b99723a4e --- /dev/null +++ b/flume-ng-sources/flume-netcat-source/pom.xml @@ -0,0 +1,58 @@ + + + + + 4.0.0 + + + org.apache.flume + flume-ng-sources + 2.0.0-SNAPSHOT + + + org.apache.flume.flume-ng-sources + flume-netcat-source + Flume Netcat Source + + + org.apache.flume.source.netcat + + + + + org.apache.flume + flume-ng-sdk + + + org.apache.flume + flume-ng-core + + + + io.netty + netty-all + + + + junit + junit + test + + + + diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/NetcatUdpSource.java b/flume-ng-sources/flume-netcat-source/src/main/java/org/apache/flume/source/netcat/NetcatUdpSource.java similarity index 98% rename from flume-ng-core/src/main/java/org/apache/flume/source/NetcatUdpSource.java rename to flume-ng-sources/flume-netcat-source/src/main/java/org/apache/flume/source/netcat/NetcatUdpSource.java index be044b508e..f16c3ab8f9 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/NetcatUdpSource.java +++ b/flume-ng-sources/flume-netcat-source/src/main/java/org/apache/flume/source/netcat/NetcatUdpSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.netcat; import com.google.common.annotations.VisibleForTesting; import io.netty.bootstrap.Bootstrap; @@ -40,6 +40,7 @@ import org.apache.flume.conf.Configurables; import org.apache.flume.event.EventBuilder; import org.apache.flume.exception.ChannelException; +import org.apache.flume.source.AbstractSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestNetcatUdpSource.java b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSource.java similarity index 99% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestNetcatUdpSource.java rename to flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSource.java index 7266086a4f..3af5910dc9 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestNetcatUdpSource.java +++ b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.netcat; import com.google.common.base.Charsets; import java.io.IOException; diff --git a/flume-ng-sources/flume-syslog-source/pom.xml b/flume-ng-sources/flume-syslog-source/pom.xml new file mode 100644 index 0000000000..000736368f --- /dev/null +++ b/flume-ng-sources/flume-syslog-source/pom.xml @@ -0,0 +1,104 @@ + + + + + 4.0.0 + + + org.apache.flume + flume-ng-sources + 2.0.0-SNAPSHOT + + + org.apache.flume.flume-ng-sources + flume-syslog-source + Flume Syslog Source + + + org.apache.flume.source.syslog + + + + + org.apache.flume + flume-ng-sdk + + + org.apache.flume + flume-ng-core + + + org.apache.flume + flume-ng-sdk + tests + test + + + + com.google.guava + guava + + + + io.netty + netty-all + + + + org.apache.mina + mina-core + + + + junit + junit + test + + + + org.mockito + mockito-core + test + + + + org.bouncycastle + bcpkix-jdk18on + test + + + + org.bouncycastle + bcprov-jdk18on + test + + + + org.apache.logging.log4j + log4j-core + test + + + + org.apache.logging.log4j + log4j-slf4j-impl + test + + + + diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/MultiportSyslogTCPSource.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/MultiportSyslogTCPSource.java similarity index 99% rename from flume-ng-core/src/main/java/org/apache/flume/source/MultiportSyslogTCPSource.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/MultiportSyslogTCPSource.java index 8853857ccf..2a92c74686 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/MultiportSyslogTCPSource.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/MultiportSyslogTCPSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; @@ -38,6 +38,7 @@ import org.apache.flume.conf.LogPrivacyUtil; import org.apache.flume.event.EventBuilder; import org.apache.flume.instrumentation.SourceCounter; +import org.apache.flume.source.SslContextAwareAbstractSource; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.service.IoHandlerAdapter; import org.apache.mina.core.session.IdleStatus; diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogParser.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogParser.java similarity index 99% rename from flume-ng-core/src/main/java/org/apache/flume/source/SyslogParser.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogParser.java index 8e84a7cc82..97cd8af108 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogParser.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogParser.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import com.google.common.base.Preconditions; import com.google.common.cache.CacheBuilder; diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogSourceConfigurationConstants.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogSourceConfigurationConstants.java similarity index 98% rename from flume-ng-core/src/main/java/org/apache/flume/source/SyslogSourceConfigurationConstants.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogSourceConfigurationConstants.java index 8378f10568..e791a0162e 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogSourceConfigurationConstants.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogSourceConfigurationConstants.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; public final class SyslogSourceConfigurationConstants { diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogTcpSource.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogTcpSource.java similarity index 98% rename from flume-ng-core/src/main/java/org/apache/flume/source/SyslogTcpSource.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogTcpSource.java index 09bfa49522..48c587a7b5 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogTcpSource.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogTcpSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import com.google.common.annotations.VisibleForTesting; import io.netty.bootstrap.ServerBootstrap; @@ -45,6 +45,7 @@ import org.apache.flume.conf.Configurables; import org.apache.flume.exception.ChannelException; import org.apache.flume.instrumentation.SourceCounter; +import org.apache.flume.source.SslContextAwareAbstractSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUDPSource.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUDPSource.java similarity index 98% rename from flume-ng-core/src/main/java/org/apache/flume/source/SyslogUDPSource.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUDPSource.java index d5d159b02e..cb4862d392 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUDPSource.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUDPSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import com.google.common.annotations.VisibleForTesting; import io.netty.bootstrap.Bootstrap; @@ -37,6 +37,7 @@ import org.apache.flume.conf.Configurables; import org.apache.flume.exception.ChannelException; import org.apache.flume.instrumentation.SourceCounter; +import org.apache.flume.source.AbstractSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUtils.java similarity index 99% rename from flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java rename to flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUtils.java index 049020b4aa..ac65eea27a 100644 --- a/flume-ng-core/src/main/java/org/apache/flume/source/SyslogUtils.java +++ b/flume-ng-sources/flume-syslog-source/src/main/java/org/apache/flume/source/syslog/SyslogUtils.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import io.netty.buffer.ByteBuf; import java.io.ByteArrayOutputStream; diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestMultiportSyslogTCPSource.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestMultiportSyslogTCPSource.java similarity index 97% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestMultiportSyslogTCPSource.java rename to flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestMultiportSyslogTCPSource.java index 49c74421d6..8a63720de9 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestMultiportSyslogTCPSource.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestMultiportSyslogTCPSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -33,6 +33,8 @@ import java.net.UnknownHostException; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.cert.X509Certificate; import java.text.ParseException; import java.time.ZonedDateTime; @@ -59,10 +61,11 @@ import org.apache.flume.conf.Configurables; import org.apache.flume.exception.ChannelException; import org.apache.flume.instrumentation.SourceCounter; -import org.apache.flume.source.MultiportSyslogTCPSource.LineSplitter; -import org.apache.flume.source.MultiportSyslogTCPSource.MultiportSyslogHandler; -import org.apache.flume.source.MultiportSyslogTCPSource.ParsedBuffer; -import org.apache.flume.source.MultiportSyslogTCPSource.ThreadSafeDecoder; +import org.apache.flume.source.syslog.MultiportSyslogTCPSource.LineSplitter; +import org.apache.flume.source.syslog.MultiportSyslogTCPSource.MultiportSyslogHandler; +import org.apache.flume.source.syslog.MultiportSyslogTCPSource.ParsedBuffer; +import org.apache.flume.source.syslog.MultiportSyslogTCPSource.ThreadSafeDecoder; +import org.apache.flume.util.TestKeyStores; import org.apache.flume.util.Whitebox; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -231,9 +234,12 @@ public X509Certificate[] getAcceptedIssuers() { SocketFactory socketFactory = sslContext.getSocketFactory(); + Path keystore = TestKeyStores.selfSigned("CN=localhost") + .writeKeyStore(Files.createTempFile("server", ".p12"), "PKCS12", "password"); + Context context = new Context(); context.put("ssl", "true"); - context.put("keystore", "src/test/resources/server.flume-keystore.p12"); + context.put("keystore", keystore.toString()); context.put("keystore-password", "password"); context.put("keystore-type", "PKCS12"); diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogParser.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogParser.java similarity index 99% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogParser.java rename to flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogParser.java index 07200383af..ca6e53ed74 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogParser.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogParser.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import com.google.common.base.Charsets; import com.google.common.collect.Lists; diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogTcpSource.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java similarity index 94% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogTcpSource.java rename to flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java index feb955629d..fbfd874039 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogTcpSource.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogTcpSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -28,6 +28,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; +import java.nio.file.Path; import java.security.cert.X509Certificate; import java.time.LocalDateTime; import java.util.ArrayList; @@ -47,8 +48,12 @@ import org.apache.flume.channel.ReplicatingChannelSelector; import org.apache.flume.conf.Configurables; import org.apache.flume.exception.ChannelException; +import org.apache.flume.util.TestKeyStores; import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.slf4j.LoggerFactory; @@ -68,6 +73,17 @@ public class TestSyslogTcpSource { private final String bodyWithTimestamp = stamp1 + " " + data1; private final String bodyWithTandH = "<10>" + stamp1 + " " + host1 + " " + data1 + "\n"; + @ClassRule + public static final TemporaryFolder TEMP_FOLDER = new TemporaryFolder(); + + private static Path serverKeystore; + + @BeforeClass + public static void generateKeystore() throws Exception { + serverKeystore = TestKeyStores.selfSigned("CN=localhost") + .writeKeyStore(TEMP_FOLDER.newFile("server.p12").toPath(), "PKCS12", "password"); + } + private void init(String keepFields) { init(keepFields, new Context()); } @@ -96,7 +112,7 @@ private void init(String keepFields, Context context) { private void initSsl() { Context context = new Context(); context.put("ssl", "true"); - context.put("keystore", "src/test/resources/server.p12"); + context.put("keystore", serverKeystore.toString()); context.put("keystore-password", "password"); context.put("keystore-type", "PKCS12"); init("none", context); diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUdpSource.java similarity index 99% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java rename to flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUdpSource.java index 9979906cf7..7d8ce85a27 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUdpSource.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUdpSource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUtils.java similarity index 99% rename from flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java rename to flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUtils.java index fd8206cddc..9834ca3ee5 100644 --- a/flume-ng-core/src/test/java/org/apache/flume/source/TestSyslogUtils.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogUtils.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.flume.source; +package org.apache.flume.source.syslog; import static io.netty.buffer.Unpooled.*; import static org.junit.Assert.assertEquals; diff --git a/flume-ng-sources/pom.xml b/flume-ng-sources/pom.xml index 683ea2a531..3318e3fd2e 100644 --- a/flume-ng-sources/pom.xml +++ b/flume-ng-sources/pom.xml @@ -34,6 +34,8 @@ flume-http-source flume-taildir-source + flume-syslog-source + flume-netcat-source From 4f9dd92b7047473a4f955d6a4e76f61bf54c639c Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 12 Jun 2026 07:30:14 +0200 Subject: [PATCH 2/5] Open java.base packages for flume-ng-sdk SSLUtil tests AbstractSSLUtilTest injects environment variables by reflecting into java.lang.ProcessEnvironment, which fails with an InaccessibleObjectException on Java 16+ unless the relevant java.base packages are opened. Add the required --add-opens to the flume-ng-sdk surefire argLine. This is a pre-existing failure, unrelated to the Mina/Netty removal. Assisted-By: Claude Opus 4.8 --- flume-ng-sdk/pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/flume-ng-sdk/pom.xml b/flume-ng-sdk/pom.xml index eaaf42b6bc..8ddc7e3c59 100644 --- a/flume-ng-sdk/pom.xml +++ b/flume-ng-sdk/pom.xml @@ -106,6 +106,18 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + -Djava.net.preferIPv4Stack=true + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + + + From afdf9e44a58404c6520ba0935991d933b1d878c1 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 12 Jun 2026 07:56:04 +0200 Subject: [PATCH 3/5] Add source-factory tests for the syslog and netcat modules TestDefaultSourceFactory in flume-ng-core used to verify that the short aliases (syslogtcp, multiport_syslogtcp, syslogudp, netcatudp) resolve to their source classes. Those classes moved out of core, so restore the coverage in the modules that now own them, following the TestHTTPSourceFactory pattern. Assisted-By: Claude Opus 4.8 --- .../netcat/TestNetcatUdpSourceFactory.java | 41 ++++++++++++++ .../syslog/TestSyslogSourceFactory.java | 55 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java create mode 100644 flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java diff --git a/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java new file mode 100644 index 0000000000..b8ae3c703e --- /dev/null +++ b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java @@ -0,0 +1,41 @@ +/* + * 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.flume.source.netcat; + +import org.apache.flume.Source; +import org.apache.flume.SourceFactory; +import org.apache.flume.source.DefaultSourceFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestNetcatUdpSourceFactory { + + private SourceFactory sourceFactory; + + @Before + public void setUp() { + sourceFactory = new DefaultSourceFactory(); + } + + @Test + public void testNetcatUdpSourceCreation() throws Exception { + Source src = sourceFactory.create("netcat-udp-src", "netcatudp"); + Assert.assertNotNull(src); + Assert.assertTrue(src instanceof NetcatUdpSource); + } +} \ No newline at end of file diff --git a/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java new file mode 100644 index 0000000000..7d167ca733 --- /dev/null +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java @@ -0,0 +1,55 @@ +/* + * 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.flume.source.syslog; + +import org.apache.flume.Source; +import org.apache.flume.SourceFactory; +import org.apache.flume.source.DefaultSourceFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class TestSyslogSourceFactory { + + private SourceFactory sourceFactory; + + @Before + public void setUp() { + sourceFactory = new DefaultSourceFactory(); + } + + @Test + public void testSyslogTcpSourceCreation() throws Exception { + Source src = sourceFactory.create("syslogtcp-src", "syslogtcp"); + Assert.assertNotNull(src); + Assert.assertTrue(src instanceof SyslogTcpSource); + } + + @Test + public void testMultiportSyslogTcpSourceCreation() throws Exception { + Source src = sourceFactory.create("multiport_syslogtcp-src", "multiport_syslogtcp"); + Assert.assertNotNull(src); + Assert.assertTrue(src instanceof MultiportSyslogTCPSource); + } + + @Test + public void testSyslogUdpSourceCreation() throws Exception { + Source src = sourceFactory.create("syslogudp-src", "syslogudp"); + Assert.assertNotNull(src); + Assert.assertTrue(src instanceof SyslogUDPSource); + } +} \ No newline at end of file From 10cebc8752c16f5eff6c8c1fb62c675b36fee78d Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 12 Jun 2026 09:04:29 +0200 Subject: [PATCH 4/5] Adjust spotbugs violation ceilings after the source move The syslog and netcat sources accounted for 11 spotbugs violations (8 + 3) in flume-ng-core. Move those allowances to the new modules and tighten flume-ng-core to its current counts, which also absorbs the headroom left by earlier module extractions: - flume-ng-core: spotbugs 199 -> 152, pmd 121 -> 64 - flume-syslog-source: spotbugs 8 - flume-netcat-source: spotbugs 3 The moved code has no pmd violations, so only spotbugs ceilings are added to the new modules. Assisted-By: Claude Opus 4.8 --- flume-ng-core/pom.xml | 4 ++-- flume-ng-sources/flume-netcat-source/pom.xml | 2 ++ flume-ng-sources/flume-syslog-source/pom.xml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flume-ng-core/pom.xml b/flume-ng-core/pom.xml index 4c75ace44e..33d269607c 100644 --- a/flume-ng-core/pom.xml +++ b/flume-ng-core/pom.xml @@ -32,8 +32,8 @@ - 199 - 121 + 152 + 64 org.apache.flume.core diff --git a/flume-ng-sources/flume-netcat-source/pom.xml b/flume-ng-sources/flume-netcat-source/pom.xml index 3b99723a4e..91aca106c4 100644 --- a/flume-ng-sources/flume-netcat-source/pom.xml +++ b/flume-ng-sources/flume-netcat-source/pom.xml @@ -30,6 +30,8 @@ Flume Netcat Source + + 3 org.apache.flume.source.netcat diff --git a/flume-ng-sources/flume-syslog-source/pom.xml b/flume-ng-sources/flume-syslog-source/pom.xml index 000736368f..8f85d836f7 100644 --- a/flume-ng-sources/flume-syslog-source/pom.xml +++ b/flume-ng-sources/flume-syslog-source/pom.xml @@ -30,6 +30,8 @@ Flume Syslog Source + + 8 org.apache.flume.source.syslog From e67794d4b20a1be24e448e9c7d422724f411c618 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Fri, 12 Jun 2026 10:21:57 +0200 Subject: [PATCH 5/5] Formatting --- .../apache/flume/source/netcat/TestNetcatUdpSourceFactory.java | 2 +- .../org/apache/flume/source/syslog/TestSyslogSourceFactory.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java index b8ae3c703e..855733ca10 100644 --- a/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java +++ b/flume-ng-sources/flume-netcat-source/src/test/java/org/apache/flume/source/netcat/TestNetcatUdpSourceFactory.java @@ -38,4 +38,4 @@ public void testNetcatUdpSourceCreation() throws Exception { Assert.assertNotNull(src); Assert.assertTrue(src instanceof NetcatUdpSource); } -} \ No newline at end of file +} diff --git a/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java index 7d167ca733..1c559ac3b7 100644 --- a/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java +++ b/flume-ng-sources/flume-syslog-source/src/test/java/org/apache/flume/source/syslog/TestSyslogSourceFactory.java @@ -52,4 +52,4 @@ public void testSyslogUdpSourceCreation() throws Exception { Assert.assertNotNull(src); Assert.assertTrue(src instanceof SyslogUDPSource); } -} \ No newline at end of file +}