-
Notifications
You must be signed in to change notification settings - Fork 271
KNOX-3278: Update JLine to 3.30.6 #1181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c33b2ba
4e64227
ce91d2e
e815c3c
9d2c76f
58f8740
44dfac3
0437c93
cf082ab
2cb83ec
b26c621
ebcaead
ecb0f45
e914af0
c168b5c
c4a3906
ec150f6
6a4c6c6
8e49fd3
3aafe58
c5d63cc
63eeb63
0ac946d
ced8096
783aee2
531ccb0
b06371b
b08b20e
ca30d36
5556484
ddc891a
294fc5b
206050b
5dfe353
cf3fa40
eeb8d4b
b50ee89
6d85aae
0533c3d
543095e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,8 +43,15 @@ | |
| <configuration> | ||
| <createDependencyReducedPom>false</createDependencyReducedPom> | ||
| <transformers> | ||
| <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> | ||
| <resource>META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule</resource> | ||
| </transformer> | ||
| <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> | ||
| <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
| <mainClass>org.apache.knox.gateway.launcher.Launcher</mainClass> | ||
| <manifestEntries> | ||
| <Multi-Release>true</Multi-Release> | ||
| </manifestEntries> | ||
| </transformer> | ||
| </transformers> | ||
| <filters> | ||
|
|
@@ -54,6 +61,7 @@ | |
| <excludes> | ||
| <exclude>schema/**</exclude> | ||
| <exclude>**/*.ldif</exclude> | ||
| <exclude>META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat</exclude> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we use maven-shade-plugin:3.4.1 and org.apache.logging.log4j:log4j-transform-maven-shade-plugin-extensions, this can be fixed by adding |
||
| </excludes> | ||
| </filter> | ||
| <filter> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,4 +63,4 @@ public String name() { | |
| return name; | ||
| } | ||
|
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,4 +59,4 @@ public boolean validate() { | |
| } | ||
| return rc; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.knox.gateway.shell; | ||
| import org.jline.console.CommandRegistry; | ||
| import org.jline.console.CommandMethods; | ||
| import org.jline.console.CommandInput; | ||
| import org.jline.console.CmdDesc; | ||
| import org.jline.reader.Completer; | ||
| import org.jline.reader.impl.completer.NullCompleter; | ||
| import org.jline.reader.impl.completer.SystemCompleter; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| public class KnoxShellCommandRegistry implements CommandRegistry { | ||
|
|
||
| private final Map<String, CommandMethods> commands; | ||
| private final Map<String, String> aliases; | ||
|
|
||
| public KnoxShellCommandRegistry(Map<String, CommandMethods> commands, Map<String, String> aliases) { | ||
| this.commands = commands; | ||
| this.aliases = aliases != null ? aliases : Collections.emptyMap(); | ||
| } | ||
|
|
||
| @Override | ||
| public String name() { | ||
| return ""; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasCommand(String command) { | ||
| return commands.containsKey(command) || aliases.containsKey(command); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> commandNames() { | ||
| return commands.keySet(); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String, String> commandAliases() { | ||
| return aliases; | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> commandInfo(String command) { | ||
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| @Override | ||
| public CmdDesc commandDescription(List<String> args) { | ||
| return new CmdDesc(false); // Disables floating tooltip widgets for these commands | ||
| } | ||
|
|
||
| @Override | ||
| public SystemCompleter compileCompleters() { | ||
| SystemCompleter out = new SystemCompleter(); | ||
|
|
||
| // Add all our main commands to the JLine completion engine | ||
| for (String cmd : commands.keySet()) { | ||
| out.add(cmd, getCompletersForCommand(cmd)); | ||
| } | ||
|
|
||
| // Tell JLine to wire up all shortcuts to the exact same completion logic | ||
| out.addAliases(aliases); | ||
| return out; | ||
| } | ||
|
|
||
| @Override | ||
| public Object invoke(CommandSession session, String command, Object... args) throws Exception { | ||
| // Resolve shortcut to full command, or keep as-is | ||
| String actualCommand = aliases.getOrDefault(command, command); | ||
| CommandMethods methods = commands.get(actualCommand); | ||
|
|
||
| if (methods != null && methods.execute() != null) { | ||
| CommandInput input = new CommandInput(command, args, session); | ||
| return methods.execute().apply(input); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private List<Completer> getCompletersForCommand(String command) { | ||
| String actualCommand = aliases.getOrDefault(command, command); | ||
| CommandMethods methods = commands.get(actualCommand); | ||
|
|
||
| if (methods != null && methods.compileCompleter() != null) { | ||
| return methods.compileCompleter().apply(actualCommand); | ||
| } | ||
| return Collections.singletonList(NullCompleter.INSTANCE); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.knox.gateway.shell; | ||
|
|
||
| import org.jline.reader.Candidate; | ||
| import org.jline.reader.Completer; | ||
| import org.jline.reader.LineReader; | ||
| import org.jline.reader.ParsedLine; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A wrapper to protect JLine from crashing when underlying completers | ||
| * (like Groovy's reflection completer) throw unexpected JVM exceptions. | ||
| */ | ||
| public class SafeCompleter implements Completer { | ||
| private final Completer delegate; | ||
|
|
||
| public SafeCompleter(Completer delegate) { | ||
| this.delegate = delegate; | ||
| } | ||
|
|
||
| @Override | ||
| public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) { | ||
| if (delegate == null) { | ||
| return; | ||
| } | ||
| try { | ||
| delegate.complete(reader, line, candidates); | ||
| } catch (Throwable t) { | ||
| // ignore | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change from shell.Shell to launcher.Launcher?