Use try with close
See gh-33987
This commit is contained in:
committed by
Phillip Webb
parent
0e68cae57f
commit
d3efd7e091
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -320,17 +320,14 @@ class EndpointDiscovererTests {
|
||||
private void load(ApplicationContext parent, Class<?> configuration,
|
||||
Consumer<AnnotationConfigApplicationContext> consumer) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
if (parent != null) {
|
||||
context.setParent(parent);
|
||||
}
|
||||
context.register(configuration);
|
||||
context.refresh();
|
||||
try {
|
||||
try (context) {
|
||||
if (parent != null) {
|
||||
context.setParent(parent);
|
||||
}
|
||||
context.register(configuration);
|
||||
context.refresh();
|
||||
consumer.accept(context);
|
||||
}
|
||||
finally {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
Reference in New Issue
Block a user