karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [4/4] git commit: KARAF-3021 - Keyboard still read after log:tail cancelled
Date Wed, 04 Jun 2014 19:10:22 GMT
KARAF-3021 - Keyboard still read after log:tail cancelled


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8a3090b5
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8a3090b5
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8a3090b5

Branch: refs/heads/master
Commit: 8a3090b5cf2fa3a82b44e3f9681e8964504b146f
Parents: 5532278
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Wed Jun 4 16:39:56 2014 -0230
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Wed Jun 4 16:39:56 2014 -0230

----------------------------------------------------------------------
 .../main/java/org/apache/karaf/log/command/LogTail.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/8a3090b5/log/src/main/java/org/apache/karaf/log/command/LogTail.java
----------------------------------------------------------------------
diff --git a/log/src/main/java/org/apache/karaf/log/command/LogTail.java b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
index bf2801e..d433c48 100644
--- a/log/src/main/java/org/apache/karaf/log/command/LogTail.java
+++ b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
@@ -46,8 +46,9 @@ public class LogTail extends DisplayLog {
     @Override
     public Object execute() throws Exception {
         PrintEventThread printThread = new PrintEventThread();
+        ReadKeyBoardThread readKeyboardThread = new ReadKeyBoardThread(this, Thread.currentThread());
         executorService.execute(printThread);
-        new Thread(new ReadKeyBoardThread(this, Thread.currentThread())).start();
+        executorService.execute(readKeyboardThread);
         while (!Thread.currentThread().isInterrupted()) {
             try {
                 Thread.sleep(200);
@@ -56,6 +57,7 @@ public class LogTail extends DisplayLog {
             }
         }
         printThread.abort();
+        readKeyboardThread.abort();
         executorService.shutdownNow();  
         return null;      
     }
@@ -63,12 +65,18 @@ public class LogTail extends DisplayLog {
     class ReadKeyBoardThread implements Runnable {
         private LogTail logTail;
         private Thread sessionThread;
+        boolean readKeyboard = true;
         public ReadKeyBoardThread(LogTail logtail, Thread thread) {
             this.logTail = logtail;
             this.sessionThread = thread;
         }
+
+        public void abort() {
+            readKeyboard = false;            
+        }
+
         public void run() {
-            for (;;) {
+            while (readKeyboard) {
                 try {
                     int c = this.logTail.session.getKeyboard().read();
                     if (c < 0) {


Mime
View raw message