Repository: karaf
Updated Branches:
  refs/heads/master 024bbc7b5 -> 5ca604ae8


[KARAF-4299] NoSuchElementException when clearing history


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

Branch: refs/heads/master
Commit: 5ca604ae818875442a06557b91f3b9fa592f442c
Parents: 024bbc7
Author: Andrea Cosentino <[email protected]>
Authored: Sun Jan 31 11:42:20 2016 +0100
Committer: Andrea Cosentino <[email protected]>
Committed: Sun Jan 31 11:42:20 2016 +0100

----------------------------------------------------------------------
 .../org/apache/karaf/shell/commands/impl/HistoryAction.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/5ca604ae/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/HistoryAction.java
----------------------------------------------------------------------
diff --git 
a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/HistoryAction.java
 
b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/HistoryAction.java
index 09ddeb1..d665a03 100644
--- 
a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/HistoryAction.java
+++ 
b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/HistoryAction.java
@@ -42,14 +42,17 @@ public class HistoryAction implements Action {
         if (history != null && clear) {
             history.clear();
         }
-        for (int index = history.first(); index <= history.last(); index++) {
-            System.out.println(
+        
+        if (!clear) {
+            for (int index = history.first(); index <= history.last(); 
index++) {
+                System.out.println(
                     Ansi.ansi()
                         .a("  ")
                         .a(Ansi.Attribute.INTENSITY_BOLD).render("%3d", 
index).a(Ansi.Attribute.INTENSITY_BOLD_OFF)
                         .a("  ")
                         .a(history.get(index))
                         .toString());
+            }
         }
         return null;
     }

Reply via email to