Skip to content

Commit 21793d5

Browse files
committed
Close RESTCONF server
Close RESTCONF server in Community Restconf stop procedure. Signed-off-by: Ivan Hrasko <[email protected]>
1 parent dd0c8a3 commit 21793d5

File tree

1 file changed

+12
-3
lines changed
  • lighty-modules/lighty-restconf-nb-community/src/main/java/io/lighty/modules/northbound/restconf/community/impl

1 file changed

+12
-3
lines changed

lighty-modules/lighty-restconf-nb-community/src/main/java/io/lighty/modules/northbound/restconf/community/impl/CommunityRestConf.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.slf4j.LoggerFactory;
3737

3838
public class CommunityRestConf extends AbstractLightyModule {
39-
4039
private static final Logger LOG = LoggerFactory.getLogger(CommunityRestConf.class);
4140

4241
private final DOMDataBroker domDataBroker;
@@ -47,12 +46,13 @@ public class CommunityRestConf extends AbstractLightyModule {
4746
private final DOMSchemaService domSchemaService;
4847
private final InetAddress inetAddress;
4948
private final String restconfServletContextPath;
49+
private final WebContextSecurer webContextSecurer;
5050
private final int httpPort;
5151
private AbstractLightyWebServer jettyServer;
5252
private LightyJettyServerProvider lightyServerBuilder;
5353
private JaxRsEndpoint jaxRsEndpoint;
54-
private WebContextSecurer webContextSecurer;
5554
private MdsalRestconfStreamRegistry mdsalRestconfStreamRegistry;
55+
private MdsalRestconfServer server;
5656

5757
public CommunityRestConf(final DOMDataBroker domDataBroker, final DOMRpcService domRpcService,
5858
final DOMNotificationService domNotificationService,
@@ -100,7 +100,7 @@ protected boolean initProcedure() throws ServletException {
100100
}
101101

102102
final MdsalDatabindProvider databindProvider = new MdsalDatabindProvider(domSchemaService);
103-
final var server = new MdsalRestconfServer(databindProvider, domDataBroker, domRpcService,
103+
this.server = new MdsalRestconfServer(databindProvider, domDataBroker, domRpcService,
104104
domActionService, domMountPointService);
105105

106106
this.jettyServer = this.lightyServerBuilder.getServer();
@@ -152,6 +152,15 @@ protected boolean stopProcedure() {
152152
stopFailed = true;
153153
}
154154
}
155+
if (server != null) {
156+
try {
157+
server.close();
158+
LOG.info("MDSAL RESTCONF server stopped");
159+
} catch (final Exception e) {
160+
LOG.error("{} failed to stop!", this.server.getClass(), e);
161+
stopFailed = true;
162+
}
163+
}
155164
if (this.lightyServerBuilder != null) {
156165
this.lightyServerBuilder = null;
157166
}

0 commit comments

Comments
 (0)