-
Notifications
You must be signed in to change notification settings - Fork 268
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
Open
bonampak
wants to merge
40
commits into
apache:master
Choose a base branch
from
bonampak:KNOX-3278
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
c33b2ba
KNOX-3278: Update jline.version to 3.25.1.
bonampak 4e64227
KNOX-3278: Update groovy to 5.0.4 and jline to 3.30.6, plus jna to 5.…
bonampak ce91d2e
KNOX-3278: refactor commands and REPL shell.
bonampak e815c3c
KNOX-3278: fix checkstyle errors and logging configuration in maven-s…
bonampak 9d2c76f
KNOX-3278: Fix forbiddenapis check: use Locale.ROOT in printf.
bonampak 58f8740
KNOX-3278: Fix KnoxShellTableCallHistoryTest shouldRollbackToValidPre…
bonampak 44dfac3
KNOX-3278: Removing comments and unused methods
bonampak 0437c93
KNOX-3278: Fix missing newlines at end of file.
bonampak cf082ab
KNOX-3278: Restoring SelectCommand to use Swing JTextArea for multili…
bonampak 2cb83ec
KNOX-3278: Removing KnoxLoginDialog (JLine3 supports password input).
bonampak b26c621
KNOX-3278: Correcting undeclared jline module dependencies.
bonampak ebcaead
KNOX-3278: Correcting pmd findings.
bonampak ecb0f45
KNOX-3278: Update rest-assured to 6.0.0 (needed for Groovy 5)
bonampak e914af0
KNOX-3278: command completion pt1
bonampak c168b5c
KNOX-3278: command completion pt2
bonampak c4a3906
KNOX-3278: correct checkstyle errors
bonampak ec150f6
KNOX-3278: correct undeclared jline module dependencies.
bonampak 6a4c6c6
KNOX-3278: cleanup DataSourceCommand completer.
bonampak 8e49fd3
KNOX-3278: add :x and :q as exit commands.
bonampak 3aafe58
KNOX-3278: add '?' as help command alias.
bonampak c5d63cc
KNOX-3278: import, load and show commands added.
bonampak 63eeb63
KNOX-3278: purge command added.
bonampak 0ac946d
KNOX-3278: Correcting load command and alias.
bonampak ced8096
KNOX-3278: Adding completer for ShowCommand.
bonampak 783aee2
KNOX-3278: Correct checkstyle error on shortcut handling
bonampak 531ccb0
KNOX-3278: Renaming SimpleCommandRegistry to KnoxShellCommandRegistry…
bonampak b06371b
KNOX-3278: No need to exclude Log4j2Plugins.dat from the shaded knoxh…
bonampak b08b20e
KNOX-3278: correcting knoxshell.sh to use -jar instead of main class …
bonampak ca30d36
KNOX-3278: excluding Log4j2Plugins.dat from the shaded knoxhsell jar …
bonampak 5556484
KNOX-3278: get rid of useless warning javax.* types are not being woven
bonampak ddc891a
KNOX-3278: fix log4j2 WARNING: sun.reflect.Reflection.getCallerClass …
bonampak 294fc5b
KNOX-3278: Fix purge command, simplify import and show commands.
bonampak 206050b
KNOX-3278: Fix ImportCommand and add support for static imports.
bonampak 5dfe353
KNOX-3278: Catch Throwable similarly to legacy GroovySh.
bonampak cf3fa40
KNOX-3278: Make LoadCommand handle multi-file loading as in legacy Gr…
bonampak eeb8d4b
KNOX-3278: wrap GroovyEngine completer into SafeCompleter to handle u…
bonampak b50ee89
KNOX-3278: correct knoxshell.sh to use launcher and correctly load cl…
bonampak 6d85aae
KNOX-3278: fix no endline at end of file.
bonampak 0533c3d
KNOX-3278: refactor Shell.java pt1
bonampak 543095e
KNOX-3278: refactor Shell.java pt2
bonampak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,4 +63,4 @@ public String name() { | |
| return name; | ||
| } | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,4 +59,4 @@ public boolean validate() { | |
| } | ||
| return rc; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxShellCommandRegistry.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
gateway-shell/src/main/java/org/apache/knox/gateway/shell/SafeCompleter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>Otherwise the Log4j2Plugins.dat will be overwritten by our plugins and will not contain the ones shipped by log4j2.