]
Jean-Francois Denise moved WFLY-9621 to WFCORE-3484:
----------------------------------------------------
Project: WildFly Core (was: WildFly)
Key: WFCORE-3484 (was: WFLY-9621)
Component/s: CLI
(was: CLI)
Affects Version/s: 4.0.0.Alpha5
(was: 11.0.0.Final)
Nonintuitive error message when for loop is used inside of
if/try/batch constructs
----------------------------------------------------------------------------------
Key: WFCORE-3484
URL:
https://issues.jboss.org/browse/WFCORE-3484
Project: WildFly Core
Issue Type: Bug
Components: CLI
Affects Versions: 4.0.0.Alpha5
Reporter: Erich Duda
Assignee: Jean-Francois Denise
CLI enables to use for loop construct for looping over commands or operations. See
WFCORE-3236 for details. Because of design limitations of CLI, using of for loop is not
supported inside of if, try, for and batch constructs. However if you try to do that,
error message is not intuitive in all cases and it is difficult to find out why the code
does not work.
Let's see on real examples.
{code:title=Using for inside if}
[standalone@embedded /] if (outcome != success) of /system-property=test:read-resource
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] echo $propName
Unrecognized variable propName
{code}
As you can see in the example, when you write aforementioned commands into the CLI, no
error is thrown until you use the variable declared in the for construct. Additionally the
error message is not saying anything about that using of "for" is not allowed
inside of "if".
{code:title=Using for inside try}
[standalone@embedded /] try
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] echo $propName
Unrecognized variable propName
{code}
The same applies here as for "if" case.
{code:title=Using for inside batch}
[standalone@embedded /] batch
[standalone@embedded / #] for propName in
:read-children-names(child-type=system-property)
The command is not available in the current context (e.g. required subsystems or
connection to the controller might be unavailable).
{code}
In the batch case, the error message is better (it says that command is not available),
but still it is not clear why the command is not available.
{code:title=Using for inside for}
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
[standalone@embedded /] for propName in :read-children-names(child-type=system-property)
for is not allowed while in for block
{code}
Using of nested for loops generates nice error message which clearly explains what is
wrong. All other cases should throw similar error.