ARTEMIS-4617 upgrade JLine to 3.25.1

I had to remove the indirect dependency between the maven plugin and jline
to avoid the maven plugin to parse some classes in jline that require experimental features on the JDK
even when they are not in use.
This commit is contained in:
Clebert Suconic 2024-02-01 11:11:02 -05:00 committed by clebertsuconic
parent 3f65f74753
commit 9d988dd9d0
12 changed files with 42 additions and 47 deletions

View File

@ -61,7 +61,7 @@ public class Artemis {
Object result = execute(fileHome, fileInstance, fileBrokerETC, true, args);
Object result = execute(fileHome, fileInstance, fileBrokerETC, true, true, args);
if (result instanceof Exception) {
// Set a nonzero status code for the exceptions caught and printed by org.apache.activemq.artemis.cli.Artemis.execute
System.exit(1);
@ -71,14 +71,14 @@ public class Artemis {
/**
* This is a good method for booting an embedded command
*/
public static Object execute(File artemisHome, File artemisInstance, File fileBrokerETC, boolean useSystemOut, List<String> args) throws Throwable {
return execute(artemisHome, artemisInstance, fileBrokerETC, useSystemOut, args.toArray(new String[args.size()]));
public static Object execute(File artemisHome, File artemisInstance, File fileBrokerETC, boolean useSystemOut, boolean enableShell, List<String> args) throws Throwable {
return execute(artemisHome, artemisInstance, fileBrokerETC, useSystemOut, enableShell, args.toArray(new String[args.size()]));
}
/**
* This is a good method for booting an embedded command
*/
public static Object execute(File fileHome, File fileInstance, File fileBrokerETC, boolean useSystemOut, String... args) throws Throwable {
public static Object execute(File fileHome, File fileInstance, File fileBrokerETC, boolean useSystemOut, boolean enableShell, String... args) throws Throwable {
ArrayList<File> dirs = new ArrayList<>();
if (fileHome != null) {
dirs.add(new File(fileHome, "lib"));
@ -151,10 +151,10 @@ public class Artemis {
URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
Thread.currentThread().setContextClassLoader(loader);
Class<?> clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis");
Method method = clazz.getMethod("execute", Boolean.TYPE, Boolean.TYPE, File.class, File.class, File.class, args.getClass());
Method method = clazz.getMethod("execute", Boolean.TYPE, Boolean.TYPE, Boolean.TYPE, File.class, File.class, File.class, args.getClass());
try {
return method.invoke(null, useSystemOut, useSystemOut, fileHome, fileInstance, fileBrokerETC, args);
return method.invoke(null, useSystemOut, useSystemOut, enableShell, fileHome, fileInstance, fileBrokerETC, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
} finally {

View File

@ -136,11 +136,6 @@
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
</dependency>
<!-- Jansi is an optional dependency for jline, to provide a proper ANSI Terminal -->
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>

View File

@ -72,6 +72,7 @@ import picocli.CommandLine.Command;
@Command(name = "artemis", description = "ActiveMQ Artemis Command Line")
public class Artemis implements Runnable {
CommandLine commandLine;
public CommandLine getCommandLine() {
@ -108,7 +109,7 @@ public class Artemis implements Runnable {
verifyManagementDTO(fileBrokerETC);
execute(true, true, fileHome, fileInstance, fileBrokerETC, args);
execute(true, true, true, fileHome, fileInstance, fileBrokerETC, args);
}
@ -131,14 +132,14 @@ public class Artemis implements Runnable {
}
public static Object internalExecute(String... args) throws Exception {
return internalExecute(null, null, null, args);
return internalExecute(false, null, null, null, args);
}
public static Object execute(File artemisHome, File artemisInstance, File etcFolder, List<String> args) throws Exception {
return execute(false, false, artemisHome, artemisInstance, etcFolder, args.toArray(new String[args.size()]));
return execute(false, false, false, artemisHome, artemisInstance, etcFolder, args.toArray(new String[args.size()]));
}
public static Object execute(boolean inputEnabled, boolean useSystemOut, File artemisHome, File artemisInstance, File etcFolder, String... args) throws Exception {
public static Object execute(boolean inputEnabled, boolean useSystemOut, boolean shellEnabled, File artemisHome, File artemisInstance, File etcFolder, String... args) throws Exception {
// using a default etc in case that is not set in the variables
if (etcFolder == null && artemisInstance != null) {
@ -162,7 +163,7 @@ public class Artemis implements Runnable {
ActionContext.setSystem(context);
try {
return internalExecute(artemisHome, artemisInstance, etcFolder, args, context);
return internalExecute(shellEnabled, artemisHome, artemisInstance, etcFolder, args, context);
} catch (ConfigurationException configException) {
context.err.println(configException.getMessage());
context.out.println();
@ -180,7 +181,7 @@ public class Artemis implements Runnable {
} catch (RuntimeException | InvalidOptionsError re) {
context.err.println(re.getMessage());
context.out.println();
HelpAction.help(buildCommand(true, true), "help");
HelpAction.help(buildCommand(true, true, shellEnabled), "help");
return re;
} finally {
ActionContext.setSystem(new ActionContext());
@ -191,13 +192,13 @@ public class Artemis implements Runnable {
* This method is used to validate exception returns.
* Useful on test cases
*/
private static Object internalExecute(File artemisHome, File artemisInstance, File etcFolder, String[] args) throws Exception {
return internalExecute(artemisHome, artemisInstance, etcFolder, args, new ActionContext());
private static Object internalExecute(boolean shellEnabled, File artemisHome, File artemisInstance, File etcFolder, String[] args) throws Exception {
return internalExecute(shellEnabled, artemisHome, artemisInstance, etcFolder, args, new ActionContext());
}
public static Object internalExecute(File artemisHome, File artemisInstance, File etcFolder, String[] args, ActionContext context) throws Exception {
public static Object internalExecute(boolean shellEnabled, File artemisHome, File artemisInstance, File etcFolder, String[] args, ActionContext context) throws Exception {
boolean isInstance = artemisInstance != null || System.getProperty("artemis.instance") != null;
CommandLine commandLine = buildCommand(isInstance, !isInstance);
CommandLine commandLine = buildCommand(isInstance, !isInstance, shellEnabled);
Object userObject = parseAction(commandLine, args);
@ -246,12 +247,7 @@ public class Artemis implements Runnable {
return parseResult.commandSpec().userObject();
}
public static CommandLine buildCommand(boolean includeInstanceCommands, boolean includeHomeCommands) {
return buildCommand(includeInstanceCommands, includeHomeCommands, false);
}
public static CommandLine buildCommand(boolean includeInstanceCommands, boolean includeHomeCommands, boolean fromShell) {
public static CommandLine buildCommand(boolean includeInstanceCommands, boolean includeHomeCommands, boolean shellEnabled) {
Artemis artemis = new Artemis();
CommandLine commandLine = new CommandLine(artemis);
@ -264,7 +260,7 @@ public class Artemis implements Runnable {
commandLine.addSubcommand(new AutoCompletion());
// we don't include the shell in the shell
if (!fromShell) {
if (shellEnabled) {
commandLine.addSubcommand(new Shell(commandLine));
}
@ -275,7 +271,7 @@ public class Artemis implements Runnable {
commandLine.addSubcommand(new QueueGroup(commandLine));
commandLine.addSubcommand(new AddressGroup(commandLine));
if (fromShell) {
if (shellEnabled) {
commandLine.addSubcommand(new Connect());
commandLine.addSubcommand(new Disconnect());
}

View File

@ -86,7 +86,7 @@ public class Shell implements Runnable {
PicocliCommands.PicocliCommandsFactory factory = new PicocliCommands.PicocliCommandsFactory();
CommandLine commandLine = Artemis.buildCommand(isInstance, !isInstance, true);
CommandLine commandLine = Artemis.buildCommand(isInstance, !isInstance, false);
PicocliCommands picocliCommands = new PicocliCommands(commandLine);
@ -119,7 +119,7 @@ public class Shell implements Runnable {
while (true) {
try {
// We build a new command every time, as they could have state from previous executions
systemRegistry.setCommandRegistries(new PicocliCommands(Artemis.buildCommand(isInstance, !isInstance, true)));
systemRegistry.setCommandRegistries(new PicocliCommands(Artemis.buildCommand(isInstance, !isInstance, false)));
systemRegistry.cleanUp();
line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null);
systemRegistry.execute(line);

View File

@ -42,7 +42,7 @@ public class AutoCompletion implements Runnable {
@Override
public void run() {
try {
CommandLine artemisCommand = Artemis.buildCommand(true, true);
CommandLine artemisCommand = Artemis.buildCommand(true, true, true);
AutoComplete.bash(startScript, autoCompleteFile, null, artemisCommand);
System.out.println("Type the following commands before you can use auto-complete:");
System.out.println("*******************************************************************************************************************************");

View File

@ -1288,14 +1288,14 @@ public class ArtemisTest extends CliTestBase {
* it will read from the InputStream in the ActionContext. It can't read the password since it's using
* System.console.readPassword() for that.
*/
assertEquals(Long.valueOf(100), Artemis.internalExecute(null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));
assertEquals(Long.valueOf(100), Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin"}, context));
/*
* This is the same as above except it will prompt the user to re-enter both the URL and the username.
*/
in = new ByteArrayInputStream("tcp://localhost:61616\nadmin\n".getBytes());
context = new ActionContext(in, System.out, System.err);
assertEquals(Long.valueOf(100), Artemis.internalExecute(null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
assertEquals(Long.valueOf(100), Artemis.internalExecute(false, null, null, null, new String[] {"producer", "--destination", "queue://q1", "--message-count", "100", "--password", "admin", "--url", "tcp://badhost:11111"}, context));
} finally {
stopServer();
}

View File

@ -71,6 +71,18 @@
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-cli</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<!-- see https://github.com/jline/jline3/issues/937 -->
<groupId>info.picocli</groupId>
<artifactId>picocli-shell-jline3</artifactId>
</exclusion>
<exclusion>
<!-- see https://github.com/jline/jline3/issues/937 -->
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>

View File

@ -120,7 +120,7 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
}
}
} else {
Artemis.execute(home, location, etc, useSystemOutput, args);
Artemis.execute(home, location, etc, useSystemOutput, false, args);
}
Thread.sleep(600);

View File

@ -261,7 +261,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
commandLineStream.println("# These are the commands used to create " + instance.getName());
commandLineStream.println(getCommandline(listCommands));
Artemis.execute(home, null, null, useSystemOutput, listCommands);
Artemis.execute(home, null, null, useSystemOutput, false, listCommands);
if (configuration != null) {
String[] list = configuration.list();

View File

@ -100,7 +100,7 @@ public class ArtemisUpgradePlugin extends ArtemisAbstractPlugin {
getLog().debug("***** Server upgrading at " + instance + " with home=" + home + " *****");
try {
Artemis.execute(home, null, null, useSystemOutput, listCommands);
Artemis.execute(home, null, null, useSystemOutput, false, listCommands);
} catch (Throwable e) {
getLog().error(e);
throw new MojoFailureException(e.getMessage());

10
pom.xml
View File

@ -138,8 +138,7 @@
<hawtbuff.version>1.11</hawtbuff.version>
<hawtdispatch.version>1.22</hawtdispatch.version>
<picocli.version>4.7.5</picocli.version>
<jline.version>3.23.0</jline.version>
<jansi.version>2.4.1</jansi.version>
<jline.version>3.25.1</jline.version>
<jakarta.activation-api.version>1.2.2</jakarta.activation-api.version>
<jakarta.annotation-api.version>1.3.5</jakarta.annotation-api.version>
<jakarta.ejb-api.version>3.2.6</jakarta.ejb-api.version>
@ -622,13 +621,6 @@
<version>${jline.version}</version>
<!-- License: BSD 3-Clause -->
</dependency>
<dependency>
<!-- used by jline to provide an ansi terminal -->
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>${jansi.version}</version>
<!-- License: Apache 2.0 -->
</dependency>
<!--needed to compile transport jar-->
<dependency>
<groupId>org.jctools</groupId>

View File

@ -341,7 +341,7 @@ public class HelperCreate extends HelperBase {
logger.debug("server created at {} with home = {}", artemisInstance, artemisHome);
artemisInstance.mkdirs();
Artemis.execute(false, true, artemisHome, null, null, (String[]) listCommands.toArray(new String[listCommands.size()]));
Artemis.execute(false, true, false, artemisHome, null, null, (String[]) listCommands.toArray(new String[listCommands.size()]));
if (configuration != null) {
String[] list = configuration.list();