Repository: karaf Updated Branches: refs/heads/master 438233e5d -> 3005e7e01
[KARAF-3383] Avoid exception causing completion to fail if a completer class can not be loaded (because of an optional package for example). Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/72630a3a Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/72630a3a Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/72630a3a Branch: refs/heads/master Commit: 72630a3ad680e00f5ffb0cb00d6b124747e9fa14 Parents: 438233e Author: Guillaume Nodet <gno...@gmail.com> Authored: Tue Nov 18 23:37:12 2014 +0100 Committer: Guillaume Nodet <gno...@gmail.com> Committed: Thu Nov 27 08:47:40 2014 +0100 ---------------------------------------------------------------------- .../impl/action/command/ArgumentCompleter.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/72630a3a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java ---------------------------------------------------------------------- diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java index 1bd04cc..d87d0f9 100644 --- a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java +++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java @@ -134,14 +134,18 @@ public class ArgumentCompleter implements Completer { if (field != null) { Completion ann = field.getAnnotation(Completion.class); if (ann != null) { - Class clazz = ann.value(); - String[] value = ann.values(); - if (clazz != null) { - if (clazz == StringsCompleter.class) { - completer = new StringsCompleter(value, ann.caseSensitive()); - } else { - completer = command.getCompleter(clazz); + try { + Class clazz = ann.value(); + String[] value = ann.values(); + if (clazz != null) { + if (clazz == StringsCompleter.class) { + completer = new StringsCompleter(value, ann.caseSensitive()); + } else { + completer = command.getCompleter(clazz); + } } + } catch (Throwable t) { + // Ignore in case the completer class is not even available } } else { completer = getDefaultCompleter(field, option.multiValued());