Refactor code to work around Eclipse compiler bug

Refactor code to work around the Eclipse compiler bug reported at
https://github.com/eclipse-jdt/eclipse.jdt.core/issues/378

Closes gh-32264
pull/32224/head
Phillip Webb 2 years ago
parent 0555dda63d
commit 127d320636

@ -456,11 +456,14 @@ public class SpringApplication {
if (this.environment != null) {
return this.environment;
}
return switch (this.webApplicationType) {
case SERVLET -> new ApplicationServletEnvironment();
case REACTIVE -> new ApplicationReactiveWebEnvironment();
default -> new ApplicationEnvironment();
};
switch (this.webApplicationType) {
case SERVLET:
return new ApplicationServletEnvironment();
case REACTIVE:
return new ApplicationReactiveWebEnvironment();
default:
return new ApplicationEnvironment();
}
}
/**

@ -33,11 +33,14 @@ class ReactiveWebServerApplicationContextFactory implements ApplicationContextFa
@Override
public ConfigurableApplicationContext create(WebApplicationType webApplicationType) {
if (webApplicationType != WebApplicationType.REACTIVE) {
return null;
return (webApplicationType != WebApplicationType.REACTIVE) ? null : createContext();
}
private ConfigurableApplicationContext createContext() {
if (!AotDetector.useGeneratedArtifacts()) {
return new AnnotationConfigReactiveWebServerApplicationContext();
}
return AotDetector.useGeneratedArtifacts() ? new ReactiveWebServerApplicationContext()
: new AnnotationConfigReactiveWebServerApplicationContext();
return new ReactiveWebServerApplicationContext();
}
}

@ -33,11 +33,14 @@ class ServletWebServerApplicationContextFactory implements ApplicationContextFac
@Override
public ConfigurableApplicationContext create(WebApplicationType webApplicationType) {
if (webApplicationType != WebApplicationType.SERVLET) {
return null;
return (webApplicationType != WebApplicationType.SERVLET) ? null : createContext();
}
private ConfigurableApplicationContext createContext() {
if (!AotDetector.useGeneratedArtifacts()) {
return new AnnotationConfigServletWebServerApplicationContext();
}
return AotDetector.useGeneratedArtifacts() ? new ServletWebServerApplicationContext()
: new AnnotationConfigServletWebServerApplicationContext();
return new ServletWebServerApplicationContext();
}
}

Loading…
Cancel
Save