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

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

Closed
pshem opened this issue Oct 5, 2023 · 2 comments
Closed
Milestone

Comments

@pshem
Copy link

pshem commented Oct 5, 2023

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?

norrisjeremy added a commit to norrisjeremy/jsch that referenced this issue Nov 13, 2023
…ExtInputStream() is called after Channel.connect().
@norrisjeremy
Copy link
Contributor

Hi @pshem,

I've included a change to add some logger warnings when getInputStream() or getExtInputStream() are called after connect() as part of #431.

Thanks,
Jeremy

@pshem
Copy link
Author

pshem commented Nov 20, 2023

Thank you very much - my older self would have noticed (we'd spent a week looking over debug level messages from JSch to figure out what was wrong before reading the documentation 🥲 )

@pshem pshem closed this as completed Nov 20, 2023
@mwiede mwiede added this to the 0.2.13 milestone Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants