- authenticateFuture.addListener(new SshFutureListener<AuthFuture>() {
- @Override
- public void operationComplete(final AuthFuture future) {
- if (future.isSuccess()) {
- handleSshAuthenticated(session, ctx);
- } else {
- // Exception does not have to be set in the future, add simple exception in such case
- final Throwable exception = future.getException() == null
- ? new IllegalStateException("Authentication failed") : future.getException();
- handleSshSetupFailure(ctx, exception);
- }
+ final ClientSession localSession = session;
+ authenticateFuture.addListener(future1 -> {
+ if (future1.isSuccess()) {
+ handleSshAuthenticated(localSession, ctx);
+ } else {
+ // Exception does not have to be set in the future, add simple exception in such case
+ final Throwable exception = future1.getException() == null
+ ? new IllegalStateException("Authentication failed") : future1.getException();
+ handleSshSetupFailure(ctx, exception);