Skip to content

channel.getInputStream() should warn if the channel has already connected #403

@pshem

Description

@pshem

We recently fixed a bug in our code where we were doing two things in the wrong order, which would lead to a race condition.

Examples, such as

jsch/examples/ScpTo.java

Lines 43 to 45 in c6970b8

InputStream in = channel.getInputStream();
channel.connect();
show you should first grab an InputStream and then connect.

Our code had:

channel.connect();
InputStream in = channel.getInputStream();
List<String> response = readStream(in);

It mostly worked, but would occasionally fail, mostly when testing connections between two fastest machines located nearby.

Would it be possible to log a warning when you getInputStream() but the channel has already connected, or is that a valid scenario in some circumstances?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions