[
https://issues.jboss.org/browse/WFLY-670?page=com.atlassian.jira.plugin.s...
]
Kabir Khan commented on WFLY-670:
---------------------------------
It is correct that the JMX spec allows you to put in checks. However, the
jboss-service.xml configuration from our SAR format is an extension to the JMX spec. My
memory is rusty, but I am 99% sure that the JMX spec itself does not contain any
configuration, injection and dependency mechanisms, which is why SAR was invented at JBoss
to get around this. This was important since we used the JMX microcontroller based on the
SAR format as our mechanism to wire services together since at least JBoss 4 (and pretty
sure 3, and perhaps even earlier). So this null on stop/uninjection has always happened
using our mechanism for attributes that were set via a jboss-service.xml.
So I would say that although this example does not violate the spec, it is a user error
not following the rules for something configured via jboss-service.xml. A few suggestions
to get around this:
* Remove the null check
* Provide an alternative setter which does not check for null
* Probably the best: Extend ServiceMBeanSupport, then change the setter to only perform
this check if in STARTED state, e.g.
{code}
public class Test extends ServiceMBeanSupport implements TestMBean {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
if (getState() == STARTED && text == null) {
throw new NullPointerException("Parameter can not be
null");
}
this.text = text;
}
}
{code}
I don’t remember if ServiceMBeanSupport implementing ServiceMBean is enough, or if you
also need to make your TestMBean interface extend ServiceMBean.
Using "attribute" tag causes injection of null values
-----------------------------------------------------
Key: WFLY-670
URL:
https://issues.jboss.org/browse/WFLY-670
Project: WildFly
Issue Type: Bug
Components: JMX
Reporter: Anders Welen
Assignee: Tomasz Adamski
Priority: Minor
Fix For: Awaiting Volunteers
Using "attribute" tag in "jboss-service.xml" in a SAR archive causes
injection of null values. Even if your code can handle this it makes it impossible to use
primitive datatypes.
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)