Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve handshake error handling #24

Merged
merged 4 commits into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -40,19 +40,23 @@ public interface ControllerCommandHandlersFactory {
* @param controllerCommandContext the command context
* @return a list of command decorators
*/
List<CommandAdapter<? extends Command<?>, ? extends Command<?>, ? extends Reply<?>>> buildCommandAdapters(
default List<CommandAdapter<? extends Command<?>, ? extends Command<?>, ? extends Reply<?>>> buildCommandAdapters(
final ControllerCommandContext controllerCommandContext,
final ProtocolVersion protocolVersion
);
) {
return List.of();
}

/**
* Build a list of command decorators dedicated to the specified context.
* Build a list of reply decorators dedicated to the specified context.
*
* @param controllerCommandContext the command context
* @return a list of command decorators
* @return a list of reply decorators
*/
List<ReplyAdapter<? extends Reply<?>, ? extends Reply<?>>> buildReplyAdapters(
default List<ReplyAdapter<? extends Reply<?>, ? extends Reply<?>>> buildReplyAdapters(
final ControllerCommandContext controllerCommandContext,
final ProtocolVersion protocolVersion
);
) {
return List.of();
}
}
Expand Up @@ -68,7 +68,9 @@ public Completable register(final ExchangeConnector exchangeConnector) {
public Completable unregister(final ExchangeConnector exchangeConnector) {
return Completable
.defer(() -> {
exchangeConnectors.remove(exchangeConnector.targetId(), exchangeConnector);
if (exchangeConnector.targetId() != null) {
exchangeConnectors.remove(exchangeConnector.targetId(), exchangeConnector);
}
return exchangeConnector.close();
})
.doOnComplete(() -> log.debug("Connector successfully unregister for target [{}]", exchangeConnector.targetId()))
Expand Down
Expand Up @@ -92,7 +92,7 @@ public Completable initialize() {
if (err instanceof WebSocketConnectorException connectorException && connectorException.isRetryable()) {
return Flowable.timer(5000, TimeUnit.MILLISECONDS);
}
log.error("Unable to connect to Exchange Connect Endpoint, stop retrying.", err);
log.error("Unable to connect to Exchange Connect Endpoint, stop retrying.");
return Flowable.error(err);
})
);
Expand Down
Expand Up @@ -16,7 +16,6 @@
package io.gravitee.exchange.connector.websocket.channel;

import io.gravitee.exchange.api.channel.exception.ChannelException;
import io.gravitee.exchange.api.channel.exception.ChannelInitializationException;
import io.gravitee.exchange.api.command.Command;
import io.gravitee.exchange.api.command.CommandAdapter;
import io.gravitee.exchange.api.command.CommandHandler;
Expand Down Expand Up @@ -75,7 +74,10 @@ public Completable initialize() {
this.targetId = reply.getPayload().getTargetId();
this.active = true;
} else {
throw new ChannelInitializationException("Unable to parse hello reply payload");
throw new WebSocketConnectorException(
String.format("Hello handshake failed: %s", reply.getErrorDetails()),
false
);
}
});
})
Expand Down