Skip to content
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

WFCORE-5247 IllegalArgumentException and CLI crash with read-attribute in /system-property #4464

Merged
merged 1 commit into from Feb 25, 2021

Conversation

parsharma
Copy link
Contributor

@github-actions github-actions bot added the deps-ok Dependencies have been checked, and there are no significant changes label Jan 28, 2021
@bstansberry
Copy link
Contributor

@jfdenise Please review

addrNode.add(node.getType(), node.getName());
for (OperationRequestAddress.Node node : address) {
if (!(node.getName() == null)) {
addrNode.add(node.getType(), node.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parsharma , in this case you are replacing the current address (that is being built) by the empty address, so you loose the context (the various cd commands the user did). In order to keep the context, you could detect that the node.getName() returns null and in this case use the "*" value for the name to express the fact that the node name has not been set.
As a side note, it would be nice if you could add a test. It should be added in this file:
https://github.com/wildfly/wildfly-core/blob/master/testsuite/standalone/src/test/java/org/jboss/as/test/integration/management/cli/CliCompletionTestCase.java

for(OperationRequestAddress.Node node : address) {
addrNode.add(node.getType(), node.getName());
for (OperationRequestAddress.Node node : address) {
if (!(node.getName() == null)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank-you for the change, I would suggest a tiny change to first deal with the null case if (node.getName() == null), it simplify a bit code reading.

@@ -118,6 +118,36 @@ public void complexOperationWithObjectAsAttributeTest() {
assertEquals(candidates.toString(), Arrays.asList(","), candidates);
}
}
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to add some tests. It would be great to cover the fix you are putting in place.
Something like:
CommandContext ctx = CLITestUtil.getCommandContext(TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), System.in, System.out);
ctx.connectController();
// cd into a type to validate that completion tha toccurs in this context is correct.
ctx.handle("cd /system-property");
try {
{
String cmd = "read-attribute ";
List candidates = new ArrayList<>();
ctx.getDefaultCommandCompleter().complete(ctx,
cmd, cmd.length(), candidates);
candidates = complete(ctx, cmd, null);
}
} finally {
ctx.terminateSession();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion @jfdenise. Please feel free to let me know if any further changes needed.

import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the order was wrong in the first place on this file, the static imports should be first - also can you please expand these back out instead of switching to a wildcard import?

Copy link
Contributor

@bstansberry bstansberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jean-Francois' approval is enough to get this merged but I'm adding mine because that will cause it to be shown as 'Approved' when looking at the PR queue.

@bstansberry bstansberry merged commit 7d9bbc5 into wildfly:master Feb 25, 2021
@parsharma parsharma deleted the WFCORE-5247 branch May 9, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps-ok Dependencies have been checked, and there are no significant changes
Projects
None yet
4 participants