Bug 1005131

Summary: read-resource() call returns Incorrect 'udefined' result for datasources
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Ondrej Chaloupka <ochaloup>
Component: Domain ManagementAssignee: Brian Stansberry <brian.stansberry>
Status: CLOSED NOTABUG QA Contact: Petr Kremensky <pkremens>
Severity: medium Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.1.1CC: brian.stansberry, emuckenh
Target Milestone: ---   
Target Release: EAP 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-06 13:05:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ondrej Chaloupka 2013-09-06 09:31:57 UTC
In case that you call in jboss-cli read-resource() on datasource subsystem you will get datasource as undefined:
/subsystem=datasources:read-resource()                                 
{
    "outcome" => "success",
    "result" => {
        "xa-data-source" => undefined,
        "data-source" => {"ExampleDS" => undefined},
        "jdbc-driver" => {"h2" => undefined}
    }
}


This makes problem in case of using DMR api and commands. When you call the same command in your app and you want to check existence of the data source in this way:
modelNodeReturn.get("result").get("data-source").get("ExampleDS").isDefined();
you will get "false". But the datasource exists and it's quite nicely defined.
Command should return true.

Workaround:
The isDefined() starts to work when the command is called with recursive=true.

As sort of reproducer could be used my testing class
https://github.com/ochaloup/jboss-dmr-test/blob/4446a1ce387126e9ba2b5dea93c83c36bbfea5e4/src/main/java/ochaloup/OperationsMain.java

Comment 1 Alexey Loubyansky 2013-09-06 10:07:49 UTC
This is not going to change. ModelNode.isDefined() has a different meaning. You are supposed to use recursive=true.

BTW, in case of data-source's, if there is data-source=XXX, it means XXX is actually there. The management won't allow XXX to be undefined.

Comment 2 Ondrej Chaloupka 2013-09-06 10:25:14 UTC
Hi Alex,

ok, I see. Just it isn't much intuitive. I would expect that isDefined() returns true in any case that a node is 'somelike' defined.

I understand that I can visually see that data-source=XXX is defined in cli. But when I want to check this in code then I can't check anything visually.

In case that it's supposed behavior and you think that it's ok for users then please close this bugzilla.

Thanks