cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Min Chen <min.c...@citrix.com>
Subject Re: [ISSUES] Master VMware is broken
Date Thu, 23 Jan 2014 17:16:39 GMT
It failed in invoking addVmwareDC, where we will invoke vmware API to get
CustomeField. Using java generics, class reflection failed in finding that
declared method, thus throwing NoSuchMethodFound exception.

Thanks
-min

On 1/22/14 10:52 PM, "Hugo Trippaers" <hugo@trippaers.nl> wrote:

>Sorry about that :-(  Thanks for finding and fixing it.
>
>Where did you encounter the error? I wonder why i didnĀ¹t catch it with my
>tests against vmware.
>
>Cheers,
>
>Hugo
>
>On 23 jan. 2014, at 03:01, Min Chen <min.chen@citrix.com> wrote:
>
>> FYI, I checked in a fix 206c35c620a8e7a707f371e5a9e5dfd795912f5b for
>>this
>> to unblock my testing.
>> 
>> Thanks
>> -min
>> 
>> On 1/22/14 5:43 PM, "Kelven Yang" <kelven.yang@citrix.com> wrote:
>> 
>>> Master VMware was broken by this commit
>>> 
>>> author  Hugo 
>>> 
>>>Trippaers<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=sea
>>>rc
>>> 
>>>h;h=b20add810e5751f53946f695b6223a8016f104a5;s=Hugo+Trippaers;st=author>
>>> 
>>><htrippaers@schubergphilis.com><https://git-wip-us.apache.org/repos/asf?
>>>p=
>>> 
>>>cloudstack.git;a=search;h=b20add810e5751f53946f695b6223a8016f104a5;s=htr
>>>ip
>>> paers@schubergphilis.com;st=author>
>>>       Wed, 22 Jan 2014 08:34:46 +0000 (09:34 +0100)
>>> committer       Hugo
>>> 
>>>Trippaers<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=sea
>>>rc
>>> 
>>>h;h=b20add810e5751f53946f695b6223a8016f104a5;s=Hugo+Trippaers;st=committ
>>>er
>>>> 
>>>> 
>>>><htrippaers@schubergphilis.com><https://git-wip-us.apache.org/repos/asf
>>>>?p
>>>> 
>>>>=cloudstack.git;a=search;h=b20add810e5751f53946f695b6223a8016f104a5;s=h
>>>>tr
>>>> ippaers@schubergphilis.com;st=committer>
>>>       Wed, 22 Jan 2014 08:37:34 +0000 (09:37 +0100)
>>> commit  b20add810e5751f53946f695b6223a8016f104a5
>>> tree    
>>> 
>>>89e7e66704b09959bc5d77e4e20562e6dcc05306<https://git-wip-us.apache.org/r
>>>ep
>>> 
>>>os/asf?p=cloudstack.git;a=tree;h=89e7e66704b09959bc5d77e4e20562e6dcc0530
>>>6;
>>> hb=b20add810e5751f53946f695b6223a8016f104a5>
>>> 
>>>tree<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=tree;h=8
>>>9e
>>> 
>>>7e66704b09959bc5d77e4e20562e6dcc05306;hb=b20add810e5751f53946f695b6223a8
>>>01
>>> 6f104a5> | 
>>> 
>>>snapshot<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=snap
>>>sh
>>> ot;h=b20add810e5751f53946f695b6223a8016f104a5;sf=tgz>
>>> parent  
>>> 
>>>86124138a1a9129dedaf0f73fcd570156bfe53f6<https://git-wip-us.apache.org/r
>>>ep
>>> 
>>>os/asf?p=cloudstack.git;a=commit;h=86124138a1a9129dedaf0f73fcd570156bfe5
>>>3f
>>> 6>  
>>> 
>>>commit<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=commit
>>>;h
>>> =86124138a1a9129dedaf0f73fcd570156bfe53f6> |
>>> 
>>>diff<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=commitdi
>>>ff
>>> 
>>>;h=b20add810e5751f53946f695b6223a8016f104a5;hp=86124138a1a9129dedaf0f73f
>>>cd
>>> 570156bfe53f6>
>>> Get rid of compiler warnings in vmware-base
>>> 
>>> Min and I spent two hours on this to trace down the cause,  Hugo,
>>>please
>>> do test before check-in even if it seems like to remove compiler
>>>warning,
>>> but because of the tricky business with Java generics, it does cause
>>> problem at runtime
>>> 
>>> One of the problem comes from following code, please checkout my
>>>comments
>>> below.
>>> 
>>> -Kelven
>>> 
>>> 
>>> import org.apache.log4j.Logger;
>>> 
>>> @@ 
>>> 
>>>-144,6<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;f
>>>=v
>>> 
>>>mware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3c2c
>>>81
>>> 
>>>d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3c2c81d8a5ea3e242a6407ab5a0d2710fa
>>>1d
>>> 0b73#l144> 
>>> 
>>>+144,7<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;f
>>>=v
>>> 
>>>mware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=e816
>>>65
>>> 
>>>f71b76a3772b13dae5cc0733d26220c64a;hb=e81665f71b76a3772b13dae5cc0733d262
>>>20
>>> c64a#l144> @@ public class VmwareClient {
>>>        ServiceContent serviceContent =
>>> vimPort.retrieveServiceContent(svcInstRef);
>>> 
>>>        // Extract a cookie. See vmware sample program
>>> com.vmware.httpfileaccess.GetVMFiles
>>> +        @SuppressWarnings("unchecked")
>>>        Map<String, List<String>> headers = (Map<String,
>>> 
>>>List<String>>)((BindingProvider)vimPort).getResponseContext().get(Messag
>>>eC
>>> ontext.HTTP_RESPONSE_HEADERS);
>>>        List<String> cookies = headers.get("Set-cookie");
>>>        String cookieValue = cookies.get(0);
>>> @@ 
>>> 
>>>-256,17<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;
>>>f=
>>> 
>>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3c2
>>>c8
>>> 
>>>1d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3c2c81d8a5ea3e242a6407ab5a0d2710f
>>>a1
>>> d0b73#l256> 
>>> 
>>>+257,18<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;
>>>f=
>>> 
>>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=e81
>>>66
>>> 
>>>5f71b76a3772b13dae5cc0733d26220c64a;hb=e81665f71b76a3772b13dae5cc0733d26
>>>22
>>> 0c64a#l257> @@ public class VmwareClient {
>>>     * @throws Exception
>>>     *             in case of error.
>>>     */
>>> -    public Object getDynamicProperty(ManagedObjectReference mor,
>>>String
>>> propertyName) throws Exception {
>>> +    @SuppressWarnings("unchecked")
>>> +    public <T> T getDynamicProperty(ManagedObjectReference mor, String
>>> propertyName) throws Exception {
>>>        List<String> props = new ArrayList<String>();
>>>        props.add(propertyName);
>>>        List<ObjectContent> objContent = retrieveMoRefProperties(mor,
>>> props);
>>> 
>>> 
>>> 
>>> -        Object propertyValue = null;
>>> +        T propertyValue = null;
>>> 
>>> [Kelven] This is a wrong change, since propertyValue is intermediate
>>> variable that could have type that is different than the returning
>>>type.
>>> It will eventually cause getDeclaredMethod() call to fail at runtime
>>> 
>>> 
>>>        if (objContent != null && objContent.size() > 0) {
>>>            List<DynamicProperty> dynamicProperty =
>>> objContent.get(0).getPropSet();
>>>            if (dynamicProperty != null && dynamicProperty.size() >
0) {
>>>                DynamicProperty dp = dynamicProperty.get(0);
>>> -                propertyValue = dp.getVal();
>>> +                propertyValue = (T)dp.getVal();
>>>                /*
>>>                 * If object is ArrayOfXXX object, then get the XXX[] by
>>>                 * invoking getXXX() on the object.
>>> @@ 
>>> 
>>>-274,13<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;
>>>f=
>>> 
>>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3c2
>>>c8
>>> 
>>>1d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3c2c81d8a5ea3e242a6407ab5a0d2710f
>>>a1
>>> d0b73#l274> 
>>> 
>>>+276,13<https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=blob;
>>>f=
>>> 
>>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=e81
>>>66
>>> 
>>>5f71b76a3772b13dae5cc0733d26220c64a;hb=e81665f71b76a3772b13dae5cc0733d26
>>>22
>>> 0c64a#l276> @@ public class VmwareClient {
>>>                 *
>>> ArrayOfManagedObjectReference.getManagedObjectReference()
>>>                 * returns ManagedObjectReference[] array.
>>>                 */
>>> -                Class dpCls = propertyValue.getClass();
>>> +                Class<? extends Object> dpCls =
>>>propertyValue.getClass();
>>>                String dynamicPropertyName = dpCls.getName();
>>>                if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
>>>                    String methodName = "get" +
>>> dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") +
>>> "ArrayOf".length(), dynamicPropertyName.length());
>>> 
>>> -                    Method getMorMethod =
>>> dpCls.getDeclaredMethod(methodName, null);
>>> -                    propertyValue = getMorMethod.invoke(propertyValue,
>>> (Object[])null);
>>> +                    Method getMorMethod =
>>> dpCls.getDeclaredMethod(methodName, (Class<?>)null);
>>> +                    propertyValue =
>>> (T)getMorMethod.invoke(propertyValue, (Object[])null);
>>>                }
>>>            }
>>>        }
>> 
>


Mime
View raw message