Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9d33639
KNOX-3278: Update jline.version to 3.25.1.
bonampak Mar 17, 2026
e2cda67
KNOX-3278: Update groovy to 5.0.4 and jline to 3.30.6, plus jna to 5.…
bonampak Mar 18, 2026
c7f301c
KNOX-3278: refactor commands and REPL shell.
bonampak Mar 18, 2026
f754c9e
KNOX-3278: fix checkstyle errors and logging configuration in maven-s…
bonampak Mar 18, 2026
7ab5402
KNOX-3278: Fix forbiddenapis check: use Locale.ROOT in printf.
bonampak Mar 18, 2026
7f5ccdd
KNOX-3278: Fix KnoxShellTableCallHistoryTest shouldRollbackToValidPre…
bonampak Mar 20, 2026
fc4a14f
KNOX-3278: Removing comments and unused methods
bonampak Mar 20, 2026
d83293c
KNOX-3278: Fix missing newlines at end of file.
bonampak Mar 20, 2026
d1203dc
KNOX-3278: Restoring SelectCommand to use Swing JTextArea for multili…
bonampak Mar 20, 2026
f79b9bd
KNOX-3278: Removing KnoxLoginDialog (JLine3 supports password input).
bonampak Mar 20, 2026
1bc98da
KNOX-3278: Correcting undeclared jline module dependencies.
bonampak Mar 20, 2026
be392fe
KNOX-3278: Correcting pmd findings.
bonampak Mar 20, 2026
8ab1077
KNOX-3278: Update rest-assured to 6.0.0 (needed for Groovy 5)
bonampak Mar 20, 2026
177d4b1
KNOX-3278: command completion pt1
bonampak Mar 23, 2026
51f4eb6
KNOX-3278: command completion pt2
bonampak Mar 23, 2026
b2ef69c
KNOX-3278: correct checkstyle errors
bonampak Mar 24, 2026
b5b756b
KNOX-3278: correct undeclared jline module dependencies.
bonampak Mar 24, 2026
90d68c2
KNOX-3278: cleanup DataSourceCommand completer.
bonampak Mar 27, 2026
d662d4d
KNOX-3278: add :x and :q as exit commands.
bonampak Mar 30, 2026
88cb370
KNOX-3278: add '?' as help command alias.
bonampak Mar 30, 2026
ae5aa92
KNOX-3278: import, load and show commands added.
bonampak Mar 30, 2026
a2f0562
KNOX-3278: purge command added.
bonampak Mar 30, 2026
44a3903
KNOX-3278: Correcting load command and alias.
bonampak Mar 31, 2026
c5792a8
KNOX-3278: Adding completer for ShowCommand.
bonampak Mar 31, 2026
a75ba41
KNOX-3278: Correct checkstyle error on shortcut handling
bonampak Apr 1, 2026
d09574f
KNOX-3278: Renaming SimpleCommandRegistry to KnoxShellCommandRegistry…
bonampak Apr 8, 2026
c178ee2
KNOX-3278: No need to exclude Log4j2Plugins.dat from the shaded knoxh…
bonampak Apr 15, 2026
ef062b6
KNOX-3278: correcting knoxshell.sh to use -jar instead of main class …
bonampak Apr 15, 2026
64c96f0
KNOX-3278: excluding Log4j2Plugins.dat from the shaded knoxhsell jar …
bonampak Apr 15, 2026
064664a
KNOX-3278: get rid of useless warning javax.* types are not being woven
bonampak Apr 15, 2026
0b5760c
KNOX-3278: fix log4j2 WARNING: sun.reflect.Reflection.getCallerClass …
bonampak Apr 15, 2026
1c071ba
KNOX-3278: Fix purge command, simplify import and show commands.
bonampak Apr 16, 2026
4ffa3ee
KNOX-3278: Fix ImportCommand and add support for static imports.
bonampak Apr 16, 2026
7b6e92c
KNOX-3278: Catch Throwable similarly to legacy GroovySh.
bonampak Apr 16, 2026
ab07b76
KNOX-3278: Make LoadCommand handle multi-file loading as in legacy Gr…
bonampak Apr 16, 2026
b065c4c
KNOX-3278: wrap GroovyEngine completer into SafeCompleter to handle u…
bonampak Apr 16, 2026
6af0bf1
KNOX-3278: correct knoxshell.sh to use launcher and correctly load cl…
bonampak Apr 16, 2026
c08b6fd
KNOX-3278: fix no endline at end of file.
bonampak Apr 17, 2026
56a44f1
KNOX-3278: refactor Shell.java pt1
bonampak Apr 17, 2026
a1cd8b4
KNOX-3278: refactor Shell.java pt2
bonampak Apr 17, 2026
d72cfa5
KNOX-3238: review findings: keep Launcher because of logging and remo…
bonampak Jul 28, 2026
29f1ece
KNOX-3278: review findings: Restore KnoxLoginDialog for credential co…
bonampak Jul 29, 2026
9cd8129
KNOX-3278: review findings: Revert LoginCommand to use KnoxLoginDialog.
bonampak Jul 29, 2026
1161af1
KNOX-3278: review findings: Replace inline FQN with import
bonampak Aug 18, 2026
e7f5f61
KNOX-3278: review findings: revert trailing newlines in files that wo…
bonampak Aug 18, 2026
9230a8a
KNOX-3278: review findings: remove override for KnoxShellCommandRegis…
bonampak Aug 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions gateway-provider-security-jwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
</dependency>

<dependency>
<groupId>org.apache.knox</groupId>
<artifactId>gateway-test-utils</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion gateway-shell-release/home/bin/knoxshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function main {

checkJava
buildAppJavaOpts
$JAVA "${APP_JAVA_OPTS[@]}" -Dlog4j.configurationFile=conf/knoxshell-log4j2.xml -javaagent:"$APP_BIN_DIR"/../lib/aspectjweaver.jar -cp "$APP_JAR":lib/* org.apache.knox.gateway.shell.Shell "$@" || exit 1
$JAVA "${APP_JAVA_OPTS[@]}" -Dlog4j.configurationFile=conf/knoxshell-log4j2.xml -javaagent:"$APP_BIN_DIR"/../lib/aspectjweaver.jar -cp "$APP_JAR":lib/* org.apache.knox.gateway.launcher.Launcher "$@" || exit 1

return 0
}
Expand Down
3 changes: 1 addition & 2 deletions gateway-shell-release/home/conf/knoxshell-log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<Properties>
<Property name="app.log.dir">logs</Property>
<Property name="app.log.dir">${sys:launcher.dir}/../logs</Property>
<Property name="app.log.file">${sys:launcher.name}.log</Property>
</Properties>
<Appenders>
Expand Down
8 changes: 8 additions & 0 deletions gateway-shell-release/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -54,6 +61,7 @@
<excludes>
<exclude>schema/**</exclude>
<exclude>**/*.ldif</exclude>
<exclude>META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat</exclude>
</excludes>
</filter>
<filter>
Expand Down
30 changes: 18 additions & 12 deletions gateway-shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-groovysh</artifactId>
<exclusions>
<exclusion>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
Expand All @@ -69,20 +63,32 @@
<artifactId>groovy-json</artifactId>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jansi</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<artifactId>jline-builtins</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<groupId>org.jline</groupId>
<artifactId>jline-console</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal</artifactId>
</dependency>
<dependency>
<groupId>net.minidev</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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 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
}
}
}
Loading
Loading