You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "Jiang, Ning (Willem)" <Ni...@iona.com> on 2006/12/21 13:55:16 UTC

答复: PMD issue [was Re: svn commit: r488948 [1/3]]

The question is exception build need to call the Message's toString() method.

:)

-----Original Message-----
From: James Mao [mailto:james.mao@iona.com]
Sent: 12/21/2006 (星期四) 17:09
To: cxf-dev@incubator.apache.org
Subject: Re: PMD issue [was Re: svn commit: r488948 [1/3]]
 
Question is why not throw the exception when you trying to retrieve the 
opName?
> Hi Dan,
>
> I just looked into this PMD error in Eclipse, find this is your code's 
> error :)
>
>  OperationInfo(InterfaceInfo it, QName n) {
>        intf = it;
>        setName(n);
>    }
>    OperationInfo(OperationInfo op) {
>        intf = op.getInterface();
>        setName(op.getName());
>    }
>   ...      public final void setName(QName name) {
>        if (name == null) {
>            throw new NullPointerException(
>                new Message("OPERATION.NAME.NOT.NULL", LOG).toString());
>        }              opName = name;
>    }
>
> The code is looked like this, the setName(QName name) is called in the 
> OperationInfo, and if the name is null the setName() will call the 
> Messsage. toString() which can be overridden. So the PMD think your 
> code violated the rule of not calling overridden methods.
>
> I tried to set the Message.toString to be final, but PMD error still 
> there, so I changed the throw new NullPointerException(...) to throw 
> new NullPointerException("Operation Name cannot be null.");
>
> So I commited these change , and change the PMD rule back.
>
> Cheers,
>
> Willem.
>
> Dan Diephouse wrote:
>
>> On 12/20/06, dandiep@apache.org <da...@apache.org> wrote:
>>
>>>
>>>
>>>     
>>> incubator/cxf/trunk/buildtools/src/main/resources/cxf-pmd-ruleset.xml
>>>
>>>
>>
>> I forgot to add in my commit notes: I had to change this as PMD seems to
>> have a bug in it. It thought I was calling toString() in the 
>> constructor and
>> that violated the rule of not calling overridden methods. However I'm 
>> not
>> calling it AFAIK. Let me know if I missed something...
>>
>> - Dan
>>
>
>



Re: 答复: PMD issue [was Re: svn commit: r488948 [1/3]]

Posted by Willem Jiang <ni...@iona.com>.
Hi James,

Yes, I just worked around the Message toString, which can handle the
different language.

But if we throw the null point exception in the Get method, it is also
hard to find the real murder by looking up the stack trace.

Regards,

Willem.

James Mao wrote:

>I know toString cause the problem, my question is, this really dose not
>solve the real problem, i mean is it possible to throw the exception
>when you Get the null point, not the time you set the null pointer.
>
>Cheers,
>James.
>  
>
>>The question is exception build need to call the Message's toString() method.
>>
>>:)
>>
>>-----Original Message-----
>>From: James Mao [mailto:james.mao@iona.com]
>>Sent: 12/21/2006 (星期四) 17:09
>>To: cxf-dev@incubator.apache.org
>>Subject: Re: PMD issue [was Re: svn commit: r488948 [1/3]]
>> 
>>Question is why not throw the exception when you trying to retrieve the 
>>opName?
>>  
>>    
>>
>>>Hi Dan,
>>>
>>>I just looked into this PMD error in Eclipse, find this is your code's 
>>>error :)
>>>
>>> OperationInfo(InterfaceInfo it, QName n) {
>>>       intf = it;
>>>       setName(n);
>>>   }
>>>   OperationInfo(OperationInfo op) {
>>>       intf = op.getInterface();
>>>       setName(op.getName());
>>>   }
>>>  ...      public final void setName(QName name) {
>>>       if (name == null) {
>>>           throw new NullPointerException(
>>>               new Message("OPERATION.NAME.NOT.NULL", LOG).toString());
>>>       }              opName = name;
>>>   }
>>>
>>>The code is looked like this, the setName(QName name) is called in the 
>>>OperationInfo, and if the name is null the setName() will call the 
>>>Messsage. toString() which can be overridden. So the PMD think your 
>>>code violated the rule of not calling overridden methods.
>>>
>>>I tried to set the Message.toString to be final, but PMD error still 
>>>there, so I changed the throw new NullPointerException(...) to throw 
>>>new NullPointerException("Operation Name cannot be null.");
>>>
>>>So I commited these change , and change the PMD rule back.
>>>
>>>Cheers,
>>>
>>>Willem.
>>>
>>>Dan Diephouse wrote:
>>>
>>>    
>>>      
>>>
>>>>On 12/20/06, dandiep@apache.org <da...@apache.org> wrote:
>>>>
>>>>      
>>>>        
>>>>
>>>>>    
>>>>>incubator/cxf/trunk/buildtools/src/main/resources/cxf-pmd-ruleset.xml
>>>>>
>>>>>
>>>>>        
>>>>>          
>>>>>
>>>>I forgot to add in my commit notes: I had to change this as PMD seems to
>>>>have a bug in it. It thought I was calling toString() in the 
>>>>constructor and
>>>>that violated the rule of not calling overridden methods. However I'm 
>>>>not
>>>>calling it AFAIK. Let me know if I missed something...
>>>>
>>>>- Dan
>>>>
>>>>      
>>>>        
>>>>
>>>    
>>>      
>>>
>>  
>>    
>>
>
>
>  
>


Re: 答复: PMD issue [was Re: svn commit: r488948 [1/3]]

Posted by James Mao <ja...@iona.com>.
I know toString cause the problem, my question is, this really dose not
solve the real problem, i mean is it possible to throw the exception
when you Get the null point, not the time you set the null pointer.

Cheers,
James.
> The question is exception build need to call the Message's toString() method.
>
> :)
>
> -----Original Message-----
> From: James Mao [mailto:james.mao@iona.com]
> Sent: 12/21/2006 (星期四) 17:09
> To: cxf-dev@incubator.apache.org
> Subject: Re: PMD issue [was Re: svn commit: r488948 [1/3]]
>  
> Question is why not throw the exception when you trying to retrieve the 
> opName?
>   
>> Hi Dan,
>>
>> I just looked into this PMD error in Eclipse, find this is your code's 
>> error :)
>>
>>  OperationInfo(InterfaceInfo it, QName n) {
>>        intf = it;
>>        setName(n);
>>    }
>>    OperationInfo(OperationInfo op) {
>>        intf = op.getInterface();
>>        setName(op.getName());
>>    }
>>   ...      public final void setName(QName name) {
>>        if (name == null) {
>>            throw new NullPointerException(
>>                new Message("OPERATION.NAME.NOT.NULL", LOG).toString());
>>        }              opName = name;
>>    }
>>
>> The code is looked like this, the setName(QName name) is called in the 
>> OperationInfo, and if the name is null the setName() will call the 
>> Messsage. toString() which can be overridden. So the PMD think your 
>> code violated the rule of not calling overridden methods.
>>
>> I tried to set the Message.toString to be final, but PMD error still 
>> there, so I changed the throw new NullPointerException(...) to throw 
>> new NullPointerException("Operation Name cannot be null.");
>>
>> So I commited these change , and change the PMD rule back.
>>
>> Cheers,
>>
>> Willem.
>>
>> Dan Diephouse wrote:
>>
>>     
>>> On 12/20/06, dandiep@apache.org <da...@apache.org> wrote:
>>>
>>>       
>>>>     
>>>> incubator/cxf/trunk/buildtools/src/main/resources/cxf-pmd-ruleset.xml
>>>>
>>>>
>>>>         
>>> I forgot to add in my commit notes: I had to change this as PMD seems to
>>> have a bug in it. It thought I was calling toString() in the 
>>> constructor and
>>> that violated the rule of not calling overridden methods. However I'm 
>>> not
>>> calling it AFAIK. Let me know if I missed something...
>>>
>>> - Dan
>>>
>>>       
>>     
>
>
>