dev@glassfish.java.net

Re: NotNull vs Element(required=true)

From: Jerome Dochez <jerome.dochez_at_oracle.com>
Date: Mon, 19 Jul 2010 09:42:20 -0700

On 7/19/10 9:37 AM, Joseph Fialli wrote:
>
>
> On 7/19/10 12:28 PM, Jerome Dochez wrote:
>> On 7/19/10 9:11 AM, Bobby Bissett wrote:
>>> What's the difference between these (in
>>> com.sun.enterprise.config.serverbeans.Config.java) *supposed* to be?
>>>
>>> 1)
>>> @Element(required=true)
>>> GroupManagementService getGroupManagementService();
>>>
>>> 2)
>>> @Element
>>> @NotNull
>>> GroupManagementService getGroupManagementService();
>>>
>>> I can try them both, but what is the difference *supposed* to be? We
>>> have default values for all children in the group-management-service
>>> element, but suddenly we're not seeing the element in domain.xml at
>>> all and are getting NPEs in the code. It worked until a couple days
>>> ago, and we didn't change anything. By "worked" I mean the element
>>> was present in the config element of domain.xml as
>>> <group-management-service/>.
>> we don't write out empty elements, and your group-management-service
>> element seem pretty empty to me...
> We removed @NotNull on getGroupManagementService() when it was causing
> it to get written out multiple times.
> The <group-management-service/> was getting written out till Friday.
> This had all been working since MS2.
yes but I fixed the multiple times bug, so I think it's time to put it
back...
>
>>>
>>> FWIW, attempt 1 above still fails. Still getting null from
>>> config.getGroupManagementService() and I don't see the element in
>>> domain.xml (does required=true do anything?).
>> I think @Element(required=true) does nothing. I can certainly make it
>> consistent with @NotNull (which was meant to be a general @NotNull
>> annotation, not just for config-api).
>>>
>>> Also, attempt 2 above does the same thing.
>> you mean you also get null when doing getGroupManagementService()
>> after adding @NotNull ?
> Yes. I had Mahesh try this too.
>
> Element [group-management-service] has one defaulted attribute and one
> child element which all its attributes are defaulted.
>
> The child element getFailureDetection() has both @NotNull and
> @Element(required=true).
>
> We are definitely being impacted by defaulting since manually adding
> an attribute in domain.xml addresses the issue.
ok let me try to understand.

you add @NotNull to getGroupManagementService() and you get a instance
back.
that GroupManagementService has a child element FailureDetection which
is also annotated with @NotNull but it's null.

so the parent is not null, but the child is ?
>
> -Joe
>
>
>
>>> This is related to issue 12719 and we don't know what magic in
>>> config-api is needed to fix it besides manually adding everything in
>>> the create-cluster decorator and abandoning defaults/notnulls.
>>>
>>> For defaults, we have defaults and elements like this in
>>> com.sun.enterprise.config.serverbeans.GroupManagementService:
>>>
>>> @Attribute (defaultValue="5000")
>>> @Min(value=1000)
>>> @Max(value=120000)
>>> String getGroupDiscoveryTimeoutInMillis();
>>>
>>> and:
>>>
>>> @Element //(required=true)
>>> @NotNull
>>> FailureDetection getFailureDetection();
>>>
>>> FailureDetection has its own defaults that we also need.
>>>
>>> Thanks,
>>> Bobby
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>