Skip to content

Commit

Permalink
Keep it simple, System.exit()
Browse files Browse the repository at this point in the history
  • Loading branch information
espenhw committed Mar 2, 2009
1 parent c8d16b3 commit 05db3f1
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/main/groovy/org/grumblesmurf/malabar/GroovyServer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import org.codehaus.groovy.tools.shell.util.Logger;

import java.net.*;

import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.ClosedByInterruptException;

import java.util.concurrent.CountDownLatch;

class GroovyServer
Expand All @@ -53,8 +49,8 @@ class GroovyServer
compileServerReady.await();
evalServerReady.await();
startConsole();
compileThread.interrupt();
evalThread.interrupt();
println "Shutting down"
System.exit(0);
} else {
System.exit(1);
}
Expand Down Expand Up @@ -83,21 +79,14 @@ class GroovySocketServer
}

void run() {
ServerSocketChannel serverChannel = ServerSocketChannel.open();
ServerSocket server = serverChannel.socket();
ServerSocket server = new ServerSocket();
server.bind(new InetSocketAddress(InetAddress.getByName(null), port));
latch.countDown();
Socket client = server.accept();
try {
SocketChannel clientChannel = serverChannel.accept();
Socket client = clientChannel.socket();
try {
new Groovysh(new IO(client.inputStream, client.outputStream, client.outputStream)).run();
} finally {
client.close();
}
} catch (ClosedByInterruptException e) {
// Do nothing, this is normal
new Groovysh(new IO(client.inputStream, client.outputStream, client.outputStream)).run();
} finally {
client.close();
server.close();
}
}
Expand Down

0 comments on commit 05db3f1

Please sign in to comment.