Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Expect.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.nio.channels.Pipe;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.Pipe.SinkChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -86,10 +87,18 @@ private static Pipe.SourceChannel inputStreamToSelectableChannel(
final InputStream input) throws IOException {
Pipe pipe = Pipe.open();
pipe.source().configureBlocking(false);
final OutputStream out = Channels.newOutputStream(pipe.sink());
Thread piping = new Thread(new Runnable() {

class OneShotTask implements Runnable {

SinkChannel sink;
InputStream input;
OneShotTask(SinkChannel s, InputStream in) { sink = s; input=in; }

@Override
public void run() {

final OutputStream out = Channels.newOutputStream(pipe.sink());

//LOG
byte[] buffer = new byte[1024];
try {
Expand All @@ -115,7 +124,8 @@ public void run() {
}
}
}
});
}
Thread piping = new Thread(new OneShotTask(pipe.sink(), input));
piping.setName("Piping InputStream to SelectableChannel Thread");
piping.setDaemon(true);
piping.start();
Expand Down