Index: shell/commands/src/main/java/org/apache/karaf/shell/commands/TailAction.java =================================================================== --- shell/commands/src/main/java/org/apache/karaf/shell/commands/TailAction.java (revision 1044331) +++ shell/commands/src/main/java/org/apache/karaf/shell/commands/TailAction.java (working copy) @@ -34,6 +34,7 @@ public class TailAction extends AbstractAction { private static final int DEFAULT_NUMBER_OF_LINES = 10; + private static final long DEFAULT_SLEEP_TIME = 20l; @Option(name = "-n", aliases = {}, description = "The number of lines to display, starting at 1.", required = false, multiValued = false) private int numberOfLines; @@ -91,24 +92,28 @@ /** * prints the tail of the file / url - * + * * @param reader * @throws IOException + * @throws InterruptedException */ - private void tail(final BufferedReader reader) throws IOException { - + private void tail(final BufferedReader reader) throws InterruptedException, IOException { if (numberOfLines < 1) { numberOfLines = DEFAULT_NUMBER_OF_LINES; } - + + if (sleepInterval < 1) { + sleepInterval = DEFAULT_SLEEP_TIME; + } + LinkedList lines = new LinkedList(); String line; while ((line = reader.readLine()) != null) { - lines.add(line); - if (lines.size() > numberOfLines) { - lines.removeFirst(); - } + lines.add(line); + if (lines.size() > numberOfLines) { + lines.removeFirst(); } + } for (String l : lines) { System.out.println(l); @@ -116,13 +121,9 @@ //If command is running as continuous while (continuous) { - try { - Thread.sleep(sleepInterval); - while ((line = reader.readLine()) != null) { - System.out.println(line); - } - } catch (InterruptedException ex) { - return; + Thread.sleep(sleepInterval); + while ((line = reader.readLine()) != null) { + System.out.println(line); } } }