File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
hivemq-edge/src/main/java/com/hivemq Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 3434import org .jetbrains .annotations .NotNull ;
3535import org .jetbrains .annotations .Nullable ;
3636import com .hivemq .http .JaxrsHttpServer ;
37+ import org .jetbrains .annotations .VisibleForTesting ;
3738import org .slf4j .Logger ;
3839import org .slf4j .LoggerFactory ;
3940
@@ -174,6 +175,11 @@ public void start(final @Nullable EmbeddedExtension embeddedExtension)
174175
175176 public void stop () {
176177 stopGateway ();
178+ }
179+
180+ @ VisibleForTesting
181+ public void shutdownProtocolAdapters () {
182+ injector .protocolAdapterManager ().shutdown ();
177183 try {
178184 Runtime .getRuntime ().removeShutdownHook (shutdownThread );
179185 } catch (final IllegalStateException ignored ) {
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ private void performStop(
213213
214214 try {
215215 hiveMQServer .stop ();
216+ hiveMQServer .shutdownProtocolAdapters ();
216217 } catch (final Exception ex ) {
217218 if (desiredState == State .CLOSED ) {
218219 log .error ("Exception during running shutdown hook." , ex );
Original file line number Diff line number Diff line change @@ -152,6 +152,18 @@ public void start() {
152152 protocolAdapterConfig .registerConsumer (this ::refresh );
153153 }
154154
155+ @ VisibleForTesting
156+ public void shutdown () {
157+ protocolAdapters .entrySet ().stream ().forEach (entry -> {
158+ try {
159+ entry .getValue ().stopAsync (true ).get ();
160+ } catch (final InterruptedException | ExecutionException e ) {
161+ log .error ("Exception happened while shutting down adapter: " , e );
162+ throw new RuntimeException (e );
163+ }
164+ });
165+ }
166+
155167 public void refresh (final @ NotNull List <ProtocolAdapterEntity > configs ) {
156168 executorService .submit (() -> {
157169 log .info ("Refreshing adapters" );
You can’t perform that action at this time.
0 commit comments