Skip to content

Commit a2d4f69

Browse files
committed
CommonsExecWebServerFactoryBean.isEagerInit = true
This ensures that the server starts up even if it is not referenced. Closes gh-53
1 parent 05db52b commit a2d4f69

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import org.springframework.beans.factory.BeanNameAware;
2828
import org.springframework.beans.factory.DisposableBean;
29-
import org.springframework.beans.factory.FactoryBean;
29+
import org.springframework.beans.factory.SmartFactoryBean;
3030
import org.springframework.util.Assert;
3131
import org.springframework.util.ClassUtils;
3232

@@ -40,7 +40,7 @@
4040
* @author Daniel Garnier-Moiroux
4141
*/
4242
public class CommonsExecWebServerFactoryBean
43-
implements FactoryBean<CommonsExecWebServer>, DisposableBean, BeanNameAware {
43+
implements SmartFactoryBean<CommonsExecWebServer>, DisposableBean, BeanNameAware {
4444

4545
private static final String DEFAULT_SPRING_BOOT_MAIN_CLASSNAME = "org.springframework.experimental.boot.server.exec.main.SpringBootApplicationMain";
4646

@@ -99,6 +99,11 @@ public CommonsExecWebServerFactoryBean addSystemProperties(Map<String, String> s
9999
return this;
100100
}
101101

102+
@Override
103+
public boolean isEagerInit() {
104+
return true;
105+
}
106+
102107
private CommonsExecWebServer build() {
103108
CommandLine commandLine = new CommandLine(this.executable);
104109
commandLine.addArguments(createSystemPropertyArgs(), false);

spring-boot-testjars/src/test/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBeanTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ void serverPortWhenSpecifiedThenNotOverridden() throws Exception {
111111
assertThat(server.getCommandLine().getArguments()).contains("-D" + portSystemProperty + "=" + expectedPort);
112112
}
113113

114+
// gh-53
115+
@Test
116+
void isEagerInitIsTrue() {
117+
CommonsExecWebServerFactoryBean factory = CommonsExecWebServerFactoryBean.builder();
118+
assertThat(factory.isEagerInit()).isTrue();
119+
}
120+
114121
private static URLClassLoader getClassLoaderFromArgs(String classpathArgs) throws MalformedURLException {
115122
var paths = new ArrayList<URL>();
116123
for (String path : classpathArgs.split(":")) {

0 commit comments

Comments
 (0)