Skip to content

Commit 9f8c22f

Browse files
authored
Review fixes for restlet-2.0:testing (#17016)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 4be7d10 commit 9f8c22f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

instrumentation/restlet/restlet-2.0/testing/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/spring/AbstractSpringServerTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,32 @@
1010
import org.restlet.Component;
1111
import org.restlet.Server;
1212
import org.restlet.routing.Router;
13-
import org.springframework.context.ApplicationContext;
1413
import org.springframework.context.support.ClassPathXmlApplicationContext;
1514

1615
public abstract class AbstractSpringServerTest extends AbstractRestletServerTest {
1716

1817
protected Router router;
18+
private ClassPathXmlApplicationContext context;
1919

2020
protected abstract String getConfigurationName();
2121

2222
@Override
2323
protected void setupServer(Component component) {
24-
ApplicationContext context = new ClassPathXmlApplicationContext(getConfigurationName());
24+
context = new ClassPathXmlApplicationContext(getConfigurationName());
2525
router = (Router) context.getBean("testRouter");
2626
Server server = (Server) context.getBean("testServer", "http", port);
2727
component.getServers().add(server);
2828
}
2929

30+
@Override
31+
protected void stopServer(Component component) throws Exception {
32+
try {
33+
super.stopServer(component);
34+
} finally {
35+
context.close();
36+
}
37+
}
38+
3039
@Override
3140
protected void setupRouting() {
3241
attach(router);

0 commit comments

Comments
 (0)