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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SessionHelper#signalNegotiationEnd should pass reason through to listener #504

Closed
duco-lw opened this issue May 16, 2024 · 1 comment
Closed
Labels
bug An issue describing a bug in the code
Milestone

Comments

@duco-lw
Copy link
Contributor

duco-lw commented May 16, 2024

listener.sessionNegotiationEnd(this, c2sOptions, s2cOptions, negotiatedGuess, null);

The reason is not passed through to the listener:

    protected void signalNegotiationEnd(
            SessionListener listener,
            Map<KexProposalOption, String> c2sOptions, Map<KexProposalOption, String> s2cOptions,
            Map<KexProposalOption, String> negotiatedGuess, Throwable reason) {
        if (listener == null) {
            return;
        }

        listener.sessionNegotiationEnd(this, c2sOptions, s2cOptions, negotiatedGuess, null);
    }

The doc for this says the negotiation is successful if this is null:

    /**
     * Signals the end of the negotiation options handling
     *
     * @param session           The referenced {@link Session}
     * @param clientProposal    The client proposal options (un-modifiable)
     * @param serverProposal    The server proposal options (un-modifiable)
     * @param negotiatedOptions The successfully negotiated options so far - even if exception occurred (un-modifiable)
     * @param reason            Negotiation end reason - {@code null} if successful
     */
    default void sessionNegotiationEnd(
            Session session,
            Map<KexProposalOption, String> clientProposal,
            Map<KexProposalOption, String> serverProposal,
            Map<KexProposalOption, String> negotiatedOptions,
            Throwable reason) {
        // ignored
    }

* @param reason Negotiation end reason - {@code null} if successful

This looks like this will always be "successful", even in the error case?

        } catch (IOException | RuntimeException | Error e) {
            signalNegotiationEnd(c2sOptions, s2cOptions, negotiatedGuess, e);
            throw e;
        }

signalNegotiationEnd(c2sOptions, s2cOptions, negotiatedGuess, e);

Would changing the line from

        listener.sessionNegotiationEnd(this, c2sOptions, s2cOptions, negotiatedGuess, null);

to

        listener.sessionNegotiationEnd(this, c2sOptions, s2cOptions, negotiatedGuess, reason);

break anything?

@tomaswolf
Copy link
Member

Thanks for pointing this out.

Would ... break anything?

No, it would not. Feel free to provide a PR.

tomaswolf added a commit that referenced this issue May 16, 2024
…ass-reason

GH-504 Pass reason to sessionNegotiationEnd
@tomaswolf tomaswolf added the bug An issue describing a bug in the code label May 16, 2024
@tomaswolf tomaswolf added this to the 2.13.0 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing a bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants