Skip to content

Commit f8888ab

Browse files
committed
add Springboot4 to CI workflow
1 parent 54d3dc6 commit f8888ab

File tree

11 files changed

+152
-46
lines changed

11 files changed

+152
-46
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ jobs:
8282
- name: Build with Spring Boot 3.3.x
8383
run: ./gha_build.sh springboot3 false false -Dspringboot.version=3.3.6 -Dspring.version=6.1.15 -Dspringsecurity.version=6.3.5 -Ddependency-check.skip=true
8484

85+
build_springboot4:
86+
name: Build and test SpringBoot 4
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v3
90+
- name: Set up JDK 17
91+
uses: actions/setup-java@v3
92+
with:
93+
distribution: 'corretto'
94+
java-version: 17
95+
- name: Build latest
96+
run: ./gha_build.sh springboot4 true true
8597
# temporarily disabled as Struts is not released at the moment
8698
# build_struts2:
8799
# name: Build and test Struts

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsProxyHttpServletRequest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,22 @@ private List<String> getHeaderValues(String key) {
607607

608608
if (request.getRequestSource() == RequestSource.API_GATEWAY) {
609609
if ("referer".equals(key.toLowerCase(Locale.ENGLISH))) {
610-
values.add(request.getRequestContext().getIdentity().getCaller());
611-
return values;
610+
if (request.getRequestContext() != null && request.getRequestContext().getIdentity() != null) {
611+
String caller = request.getRequestContext().getIdentity().getCaller();
612+
if (caller != null) {
613+
values.add(caller);
614+
return values;
615+
}
616+
}
612617
}
613618
if ("user-agent".equals(key.toLowerCase(Locale.ENGLISH))) {
614-
values.add(request.getRequestContext().getIdentity().getUserAgent());
615-
return values;
619+
if (request.getRequestContext() != null && request.getRequestContext().getIdentity() != null) {
620+
String userAgent = request.getRequestContext().getIdentity().getUserAgent();
621+
if (userAgent != null) {
622+
values.add(userAgent);
623+
return values;
624+
}
625+
}
616626
}
617627
}
618628

aws-serverless-java-container-springboot4/pom.xml

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,127 @@
7676
<version>${spring.version}</version>
7777
<optional>true</optional>
7878
</dependency>
79+
80+
<!-- Jakarta Servlet API for Spring Boot 4.0 -->
81+
<dependency>
82+
<groupId>jakarta.servlet</groupId>
83+
<artifactId>jakarta.servlet-api</artifactId>
84+
<version>6.1.0</version>
85+
<scope>provided</scope>
86+
</dependency>
87+
88+
<!-- Test dependencies -->
89+
<dependency>
90+
<groupId>org.springframework.boot</groupId>
91+
<artifactId>spring-boot-starter</artifactId>
92+
<version>${springboot.version}</version>
93+
<scope>test</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter-webmvc</artifactId>
98+
<version>${springboot.version}</version>
99+
<scope>test</scope>
100+
</dependency>
101+
102+
<dependency>
103+
<groupId>org.springframework.boot</groupId>
104+
<artifactId>spring-boot-starter-webflux</artifactId>
105+
<version>${springboot.version}</version>
106+
<scope>test</scope>
107+
<exclusions>
108+
<exclusion>
109+
<groupId>org.springframework.boot</groupId>
110+
<artifactId>spring-boot-starter-reactor-netty</artifactId>
111+
</exclusion>
112+
</exclusions>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.springframework.boot</groupId>
116+
<artifactId>spring-boot-starter-data-jpa</artifactId>
117+
<version>${springboot.version}</version>
118+
<scope>test</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.springframework.boot</groupId>
122+
<artifactId>spring-boot-starter-validation</artifactId>
123+
<version>${springboot.version}</version>
124+
<scope>test</scope>
125+
</dependency>
126+
127+
<dependency>
128+
<groupId>org.springframework.boot</groupId>
129+
<artifactId>spring-boot-starter-webmvc-test</artifactId>
130+
<version>${springboot.version}</version>
131+
<scope>test</scope>
132+
</dependency>
133+
<dependency>
134+
<groupId>com.h2database</groupId>
135+
<artifactId>h2</artifactId>
136+
<version>2.3.232</version>
137+
<scope>test</scope>
138+
</dependency>
139+
<dependency>
140+
<groupId>org.springframework.boot</groupId>
141+
<artifactId>spring-boot-starter-security</artifactId>
142+
<version>${springboot.version}</version>
143+
<scope>test</scope>
144+
</dependency>
145+
<dependency>
146+
<groupId>org.springframework.security</groupId>
147+
<artifactId>spring-security-web</artifactId>
148+
<version>${springsecurity.version}</version>
149+
<scope>test</scope>
150+
</dependency>
151+
<dependency>
152+
<groupId>org.springframework.security</groupId>
153+
<artifactId>spring-security-config</artifactId>
154+
<version>${springsecurity.version}</version>
155+
<scope>test</scope>
156+
</dependency>
157+
79158
</dependencies>
80159

160+
<profiles>
161+
<profile>
162+
<id>security-tests</id>
163+
<activation>
164+
<property>
165+
<name>test</name>
166+
<value>SecurityAppTest</value>
167+
</property>
168+
</activation>
169+
<dependencies>
170+
<dependency>
171+
<groupId>org.springframework.boot</groupId>
172+
<artifactId>spring-boot-starter-security</artifactId>
173+
<version>${springboot.version}</version>
174+
<scope>test</scope>
175+
</dependency>
176+
<dependency>
177+
<groupId>org.springframework.security</groupId>
178+
<artifactId>spring-security-web</artifactId>
179+
<version>${springsecurity.version}</version>
180+
<scope>test</scope>
181+
</dependency>
182+
<dependency>
183+
<groupId>org.springframework.security</groupId>
184+
<artifactId>spring-security-config</artifactId>
185+
<version>${springsecurity.version}</version>
186+
<scope>test</scope>
187+
</dependency>
188+
</dependencies>
189+
</profile>
190+
</profiles>
191+
81192
<build>
82193
<plugins>
83194
<plugin>
84195
<groupId>org.apache.maven.plugins</groupId>
85196
<artifactId>maven-compiler-plugin</artifactId>
86197
<configuration>
87-
<source>25</source>
88-
<target>25</target>
198+
<source>17</source>
199+
<target>17</target>
89200
</configuration>
90201
</plugin>
91202
</plugins>

aws-serverless-java-container-springboot4/src/main/java/com/amazonaws/serverless/proxy/spring/SpringBootLambdaContainerHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.slf4j.LoggerFactory;
1919
import org.springframework.boot.WebApplicationType;
2020
import org.springframework.boot.builder.SpringApplicationBuilder;
21-
import org.springframework.boot.web.context.servlet.AnnotationConfigServletWebApplicationContext;
21+
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
2222
import org.springframework.context.ConfigurableApplicationContext;
2323

2424
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
@@ -197,7 +197,7 @@ public void initialize()
197197
}
198198
applicationContext = builder.run();
199199
if (springWebApplicationType == WebApplicationType.SERVLET) {
200-
((AnnotationConfigServletWebApplicationContext)applicationContext).setServletContext(getServletContext());
200+
((AnnotationConfigServletWebServerApplicationContext)applicationContext).setServletContext(getServletContext());
201201
AwsServletRegistration reg = (AwsServletRegistration)getServletContext().getServletRegistration(DISPATCHER_SERVLET_REGISTRATION_NAME);
202202
if (reg != null) {
203203
reg.setLoadOnStartup(1);

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/AwsSpringHttpProcessingUtilsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.junit.jupiter.params.provider.MethodSource;
1313
import org.springframework.boot.SpringApplication;
1414
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
15-
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
15+
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
1616
import org.springframework.cloud.function.serverless.web.ServerlessMVC;
1717
import org.springframework.cloud.function.serverless.web.ServerlessServletContext;
1818
import org.springframework.context.ConfigurableApplicationContext;

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/jpaapp/JpaApplication.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
import org.springframework.context.annotation.Bean;
88
import org.springframework.context.annotation.Import;
99

10-
@SpringBootApplication(exclude = {
11-
org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration.class,
12-
org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration.class,
13-
org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration.class,
14-
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
15-
})
10+
@SpringBootApplication
1611
@Import(MessageController.class)
1712
public class JpaApplication {}

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/securityapp/SecurityApplication.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
77
import org.springframework.web.reactive.config.EnableWebFlux;
88

9-
@SpringBootApplication(exclude = {
10-
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
11-
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class
12-
})
9+
@SpringBootApplication
1310
@EnableWebFluxSecurity
1411
@EnableWebFlux
1512
@Import(SecurityConfig.class)

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/securityapp/SecurityConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ public class SecurityConfig
2121
@Bean
2222
public SecurityWebFilterChain securitygWebFilterChain(
2323
ServerHttpSecurity http) {
24-
return http.authorizeExchange()
25-
.anyExchange().authenticated().and().csrf().disable()
26-
.httpBasic()
27-
.and().build();
24+
return http.authorizeExchange(exchanges -> exchanges
25+
.anyExchange().authenticated())
26+
.csrf(csrf -> csrf.disable())
27+
.httpBasic(httpBasic -> {})
28+
.build();
2829
}
2930

3031
@Bean

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/servletapp/ServletApplication.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@
99
import org.springframework.web.bind.annotation.RequestParam;
1010
import org.springframework.web.bind.annotation.RestController;
1111

12-
@SpringBootApplication(exclude = {
13-
org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration.class,
14-
org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration.class,
15-
org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration.class,
16-
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
17-
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
18-
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class
19-
})
12+
@SpringBootApplication
2013
@Import(MessageController.class)
2114
@RestController
2215
public class ServletApplication {

aws-serverless-java-container-springboot4/src/test/java/com/amazonaws/serverless/proxy/spring/slowapp/SlowTestApplication.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
import java.time.Instant;
88

9-
@SpringBootApplication(exclude = {
10-
org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration.class,
11-
org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration.class,
12-
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
13-
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class
14-
})
9+
@SpringBootApplication
1510
public class SlowTestApplication {
1611

1712
@Component

0 commit comments

Comments
 (0)