- if (command instanceof ExtendedDbusCommand) {
- ((ExtendedDbusCommand) command).handleCommand(ns, ts, dBusConn, outputWriter);
- } else if (command instanceof LocalCommand) {
- try {
- ((LocalCommand) command).handleCommand(ns, new DbusManagerImpl(ts, dBusConn), outputWriter);
+ if (command instanceof LocalCommand localCommand) {
+ try (final var m = new DbusManagerImpl(ts, dBusConn)) {
+ localCommand.handleCommand(ns, m, outputWriter);