This is an automated email from the ASF dual-hosted git repository. rgoers pushed a commit to branch spring-boot-4 in repository https://gitbox.apache.org/repos/asf/logging-flume-spring-boot.git
commit 49858ccfe28950af1d08ca42018c179b113e9868 Author: Ralph Goers <[email protected]> AuthorDate: Mon Jun 15 07:54:43 2026 -0700 Upgrade to Spring Boot 4 --- checkstyle-header.txt | 16 ---- flume-spring-boot-dist/pom.xml | 3 +- flume-spring-boot/pom.xml | 50 ++++++++++++- .../boot/config/AbstractFlumeConfiguration.java | 25 ++++--- .../spring/boot/config/SpringConfiguration.java | 7 +- .../flume/spring/boot/runner/SpringFlume.java | 4 +- .../apache/flume/spring/app/TestSpringFlume.java | 4 +- .../apache/flume/spring/app/config/AppConfig.java | 15 ++-- ...k.boot.autoconfigure.AutoConfiguration.imports} | 2 +- .../src/test/resources/log4j2-test.xml | 2 +- pom.xml | 87 +++++----------------- 11 files changed, 102 insertions(+), 113 deletions(-) diff --git a/checkstyle-header.txt b/checkstyle-header.txt deleted file mode 100644 index 4f33236..0000000 --- a/checkstyle-header.txt +++ /dev/null @@ -1,16 +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. - */ diff --git a/flume-spring-boot-dist/pom.xml b/flume-spring-boot-dist/pom.xml index a98dab5..b3b3d32 100644 --- a/flume-spring-boot-dist/pom.xml +++ b/flume-spring-boot-dist/pom.xml @@ -23,7 +23,8 @@ limitations under the License. <parent> <groupId>org.apache.flume</groupId> <artifactId>flume-spring-boot-parent</artifactId> - <version>2.0.0</version> + <version>2.1.0-SNAPSHOT.0</version> + <relativePath>../pom.xml</relativePath> </parent> <artifactId>flume-spring-boot-dist</artifactId> diff --git a/flume-spring-boot/pom.xml b/flume-spring-boot/pom.xml index 96d1ee5..4601e12 100644 --- a/flume-spring-boot/pom.xml +++ b/flume-spring-boot/pom.xml @@ -21,7 +21,8 @@ limitations under the License. <parent> <artifactId>flume-spring-boot-parent</artifactId> <groupId>org.apache.flume</groupId> - <version>2.0.0</version> + <version>2.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> @@ -30,7 +31,8 @@ limitations under the License. <properties> <module.name>org.apache.flume.spring.boot</module.name> - <spring-boot.version>2.7.5</spring-boot.version> + <spring-boot.version>4.1.0</spring-boot.version> + <gson.version>2.14.0</gson.version> </properties> <dependencyManagement> <dependencies> @@ -76,15 +78,55 @@ limitations under the License. <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>${gson.version}</version> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> - <!-- log dependencies --> <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-log4j2</artifactId> + <artifactId>spring-boot-resttestclient</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-restclient</artifactId> + <scope>test</scope> + </dependency> + <!-- log dependencies --> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-1.2-api</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <scope>test</scope> </dependency> </dependencies> <build> diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java index 79db452..641aacc 100644 --- a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/AbstractFlumeConfiguration.java @@ -33,7 +33,8 @@ import java.util.List; import java.util.Map; /** - * + * The primarily provides helper methods to create and configure the various Flume components. + * The do not have to be used. */ public abstract class AbstractFlumeConfiguration { @@ -60,6 +61,7 @@ public abstract class AbstractFlumeConfiguration { } source.setName(name); Configurables.configure(source, createContext(params)); + ChannelProcessor channelProcessor = new ChannelProcessor(selector); source.setChannelProcessor(new ChannelProcessor(selector)); return SourceRunner.forSource(source); } @@ -105,17 +107,18 @@ public abstract class AbstractFlumeConfiguration { return sink; } - protected ChannelSelector createChannelSelector(Class<? extends ChannelSelector> clazz, - Map<String, String> params) { - ChannelSelector selector; - try { - selector = clazz.newInstance(); - } catch (Exception ex) { - throw new FlumeException("Unable to create channel selector " + clazz.getName(), ex); + protected ChannelSelector createChannelSelector(Class<? extends ChannelSelector> clazz, + List<Channel> channels, Map<String, String> params) { + ChannelSelector selector; + try { + selector = clazz.newInstance(); + } catch (Exception ex) { + throw new FlumeException("Unable to create channel selector " + clazz.getName(), ex); + } + selector.setChannels(channels); + Configurables.configure(selector, createContext(params)); + return selector; } - Configurables.configure(selector, createContext(params)); - return selector; - } /** * Creates a List from a Varargs array. diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java index eac9a76..6ceedfc 100644 --- a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/config/SpringConfiguration.java @@ -28,7 +28,12 @@ import org.springframework.context.annotation.Configuration; import java.util.Map; /** - * + * This is the heart of a Flume application. Use your custom Java configuration + * file to define the Channels, SinkRunners, and SourceRunners as beans. + * Your configuration can define each channel, sinkRunner, and sourceRunner + * as individual beans in which case Spring will automatically add them to the + * relevant map using the bean name as the key, or you can provide bean methods + * that return the entire map. */ @Configuration public class SpringConfiguration { diff --git a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java index 2ddecad..2cc312c 100644 --- a/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java +++ b/flume-spring-boot/src/main/java/org/apache/flume/spring/boot/runner/SpringFlume.java @@ -24,8 +24,8 @@ import org.apache.flume.node.MaterializedConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; import java.util.List; /** diff --git a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java index b30af88..c2f1510 100644 --- a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java +++ b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/TestSpringFlume.java @@ -25,7 +25,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.resttestclient.TestRestTemplate; +import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -37,6 +38,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = {FlumeApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureTestRestTemplate public class TestSpringFlume { @LocalServerPort diff --git a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java index 0f1bc2b..a80657d 100644 --- a/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java +++ b/flume-spring-boot/src/test/java/org/apache/flume/spring/app/config/AppConfig.java @@ -18,6 +18,7 @@ package org.apache.flume.spring.app.config; import org.apache.flume.Channel; import org.apache.flume.ChannelSelector; +import org.apache.flume.Context; import org.apache.flume.Sink; import org.apache.flume.SinkRunner; import org.apache.flume.SourceRunner; @@ -27,10 +28,11 @@ import org.apache.flume.sink.DefaultSinkProcessor; import org.apache.flume.sink.NullSink; import org.apache.flume.source.SequenceGeneratorSource; import org.apache.flume.spring.boot.config.AbstractFlumeConfiguration; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; import java.util.HashMap; import java.util.Map; @@ -38,7 +40,7 @@ import java.util.Map; /** * */ -@Configuration +@AutoConfiguration @ComponentScan(basePackages="org.apache.flume.spring.app") public class AppConfig extends AbstractFlumeConfiguration { @@ -55,16 +57,19 @@ public class AppConfig extends AbstractFlumeConfiguration { } @Bean - public Channel memoryChannel(Map<String, String> channel1Properties) { + public Channel memoryChannel(@Qualifier("channel1Properties")Map<String, String> channel1Properties) { return configureChannel("channel1", MemoryChannel.class, channel1Properties); } @Bean - public SourceRunner seqSource(Channel memoryChannel, Map<String, String> source1Properties) { + public SourceRunner seqSource(Channel memoryChannel, @Qualifier("source1Properties")Map<String, String> source1Properties) { ChannelSelector selector = new ReplicatingChannelSelector(); selector.setChannels(listOf(memoryChannel)); - return configureSource("source1", SequenceGeneratorSource.class, selector, + SourceRunner runner = configureSource("source1", SequenceGeneratorSource.class, selector, source1Properties); + Context context = source1Properties != null ? new Context(source1Properties) : new Context(); + runner.getSource().getChannelProcessor().configure(context); + return runner; } @Bean diff --git a/flume-spring-boot/src/test/resources/META-INF/spring.factories b/flume-spring-boot/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports similarity index 87% rename from flume-spring-boot/src/test/resources/META-INF/spring.factories rename to flume-spring-boot/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 10241f5..7542133 100644 --- a/flume-spring-boot/src/test/resources/META-INF/spring.factories +++ b/flume-spring-boot/src/test/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apache.flume.spring.app.config.AppConfig \ No newline at end of file +org.apache.flume.spring.app.config.AppConfig \ No newline at end of file diff --git a/flume-spring-boot/src/test/resources/log4j2-test.xml b/flume-spring-boot/src/test/resources/log4j2-test.xml index a98e448..5baa09d 100644 --- a/flume-spring-boot/src/test/resources/log4j2-test.xml +++ b/flume-spring-boot/src/test/resources/log4j2-test.xml @@ -24,7 +24,7 @@ </Appenders> <Loggers> <Logger name="org.apache.flume" level="INFO" /> - <Root level="INFO"> + <Root level="TRACE"> <AppenderRef ref="Console" /> </Root> </Loggers> diff --git a/pom.xml b/pom.xml index cee6ed5..68947de 100644 --- a/pom.xml +++ b/pom.xml @@ -21,40 +21,43 @@ limitations under the License. <modelVersion>4.0.0</modelVersion> <parent> - <groupId>org.apache</groupId> - <artifactId>apache</artifactId> - <version>29</version> + <groupId>org.apache.flume</groupId> + <artifactId>flume-parent</artifactId> + <version>2.0.0-SNAPSHOT</version> + <relativePath /> </parent> <groupId>org.apache.flume</groupId> <artifactId>flume-spring-boot-parent</artifactId> <name>Flume Spring Boot Parent</name> - <version>2.0.1-SNAPSHOT</version> + <version>2.1.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> - <ReleaseVersion>2.0.1</ReleaseVersion> + <ReleaseVersion>2.1.0</ReleaseVersion> <ReleaseManager>Ralph Goers</ReleaseManager> <ReleaseKey>B3D8E1BA</ReleaseKey> <SigningUserName>[email protected]</SigningUserName> <checksum-maven-plugin.version>1.11</checksum-maven-plugin.version> <findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version> - <flume.version>1.11.0</flume.version> - <log4j.version>2.23.0</log4j.version> - <maven.compiler.source>11</maven.compiler.source> - <maven.compiler.target>11</maven.compiler.target> + <flume.version>2.0.0-SNAPSHOT</flume.version> <module.name>org.apache.flume.spring.boot</module.name> <mvn-gpg-plugin.version>1.6</mvn-gpg-plugin.version> <mvn-javadoc-plugin.version>2.9</mvn-javadoc-plugin.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <rat.version>0.12</rat.version> - <slf4j.version>1.7.36</slf4j.version> - <spotbugs-maven-plugin.version>4.7.2.1</spotbugs-maven-plugin.version> - <spotless-maven-plugin.version>2.27.2</spotless-maven-plugin.version> - <spring-boot.version>2.7.18</spring-boot.version> + <spring-boot.version>4.1.0</spring-boot.version> </properties> <dependencyManagement> <dependencies> + <dependency> + <groupId>org.apache.flume</groupId> + <artifactId>flume-dependencies</artifactId> + <version>${flume.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + <!-- Override the versions in this repo --> <dependency> <groupId>org.apache.flume</groupId> <artifactId>flume-spring-boot</artifactId> @@ -67,62 +70,6 @@ limitations under the License. <type>pom</type> <scope>import</scope> </dependency> - <dependency> - <groupId>org.apache.flume</groupId> - <artifactId>flume-ng-configuration</artifactId> - <version>${flume.version}</version> - </dependency> - <dependency> - <groupId>org.apache.flume</groupId> - <artifactId>flume-ng-core</artifactId> - <version>${flume.version}</version> - </dependency> - <dependency> - <groupId>org.apache.flume</groupId> - <artifactId>flume-ng-node</artifactId> - <version>${flume.version}</version> - </dependency> - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-api</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-1.2-api</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-jcl</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-jul</artifactId> - <version>${log4j.version}</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> </dependencies> </dependencyManagement> @@ -175,7 +122,7 @@ limitations under the License. <name>Ralph Goers</name> <id>rgoers</id> <email>[email protected]</email> - <organization>Intuit</organization> + <organization>Nextiva</organization> </developer> </developers>
