Skip to content
Open
Show file tree
Hide file tree
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 Mar 17, 2026
4e64227
KNOX-3278: Update groovy to 5.0.4 and jline to 3.30.6, plus jna to 5.…
bonampak Mar 18, 2026
ce91d2e
KNOX-3278: refactor commands and REPL shell.
bonampak Mar 18, 2026
e815c3c
KNOX-3278: fix checkstyle errors and logging configuration in maven-s…
bonampak Mar 18, 2026
9d2c76f
KNOX-3278: Fix forbiddenapis check: use Locale.ROOT in printf.
bonampak Mar 18, 2026
58f8740
KNOX-3278: Fix KnoxShellTableCallHistoryTest shouldRollbackToValidPre…
bonampak Mar 20, 2026
44dfac3
KNOX-3278: Removing comments and unused methods
bonampak Mar 20, 2026
0437c93
KNOX-3278: Fix missing newlines at end of file.
bonampak Mar 20, 2026
cf082ab
KNOX-3278: Restoring SelectCommand to use Swing JTextArea for multili…
bonampak Mar 20, 2026
2cb83ec
KNOX-3278: Removing KnoxLoginDialog (JLine3 supports password input).
bonampak Mar 20, 2026
b26c621
KNOX-3278: Correcting undeclared jline module dependencies.
bonampak Mar 20, 2026
ebcaead
KNOX-3278: Correcting pmd findings.
bonampak Mar 20, 2026
ecb0f45
KNOX-3278: Update rest-assured to 6.0.0 (needed for Groovy 5)
bonampak Mar 20, 2026
e914af0
KNOX-3278: command completion pt1
bonampak Mar 23, 2026
c168b5c
KNOX-3278: command completion pt2
bonampak Mar 23, 2026
c4a3906
KNOX-3278: correct checkstyle errors
bonampak Mar 24, 2026
ec150f6
KNOX-3278: correct undeclared jline module dependencies.
bonampak Mar 24, 2026
6a4c6c6
KNOX-3278: cleanup DataSourceCommand completer.
bonampak Mar 27, 2026
8e49fd3
KNOX-3278: add :x and :q as exit commands.
bonampak Mar 30, 2026
3aafe58
KNOX-3278: add '?' as help command alias.
bonampak Mar 30, 2026
c5d63cc
KNOX-3278: import, load and show commands added.
bonampak Mar 30, 2026
63eeb63
KNOX-3278: purge command added.
bonampak Mar 30, 2026
0ac946d
KNOX-3278: Correcting load command and alias.
bonampak Mar 31, 2026
ced8096
KNOX-3278: Adding completer for ShowCommand.
bonampak Mar 31, 2026
783aee2
KNOX-3278: Correct checkstyle error on shortcut handling
bonampak Apr 1, 2026
531ccb0
KNOX-3278: Renaming SimpleCommandRegistry to KnoxShellCommandRegistry…
bonampak Apr 8, 2026
b06371b
KNOX-3278: No need to exclude Log4j2Plugins.dat from the shaded knoxh…
bonampak Apr 15, 2026
b08b20e
KNOX-3278: correcting knoxshell.sh to use -jar instead of main class …
bonampak Apr 15, 2026
ca30d36
KNOX-3278: excluding Log4j2Plugins.dat from the shaded knoxhsell jar …
bonampak Apr 15, 2026
5556484
KNOX-3278: get rid of useless warning javax.* types are not being woven
bonampak Apr 15, 2026
ddc891a
KNOX-3278: fix log4j2 WARNING: sun.reflect.Reflection.getCallerClass …
bonampak Apr 15, 2026
294fc5b
KNOX-3278: Fix purge command, simplify import and show commands.
bonampak Apr 16, 2026
206050b
KNOX-3278: Fix ImportCommand and add support for static imports.
bonampak Apr 16, 2026
5dfe353
KNOX-3278: Catch Throwable similarly to legacy GroovySh.
bonampak Apr 16, 2026
cf3fa40
KNOX-3278: Make LoadCommand handle multi-file loading as in legacy Gr…
bonampak Apr 16, 2026
eeb8d4b
KNOX-3278: wrap GroovyEngine completer into SafeCompleter to handle u…
bonampak Apr 16, 2026
b50ee89
KNOX-3278: correct knoxshell.sh to use launcher and correctly load cl…
bonampak Apr 16, 2026
6d85aae
KNOX-3278: fix no endline at end of file.
bonampak Apr 17, 2026
0533c3d
KNOX-3278: refactor Shell.java pt1
bonampak Apr 17, 2026
543095e
KNOX-3278: refactor Shell.java pt2
bonampak Apr 17, 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/* -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>
Copy link
Copy Markdown
Contributor Author

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.

</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
Expand Up @@ -63,4 +63,4 @@ public String name() {
return name;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public boolean validate() {
}
return rc;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public HttpDelete(URI uri) {
public String getMethod() {
return org.apache.http.client.methods.HttpDelete.METHOD_NAME;
}
}
}
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
}
}
}
Loading
Loading