Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ABFBE1019D for ; Thu, 23 Jan 2014 17:17:37 +0000 (UTC) Received: (qmail 87935 invoked by uid 500); 23 Jan 2014 17:17:31 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 87893 invoked by uid 500); 23 Jan 2014 17:17:31 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 87876 invoked by uid 99); 23 Jan 2014 17:17:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jan 2014 17:17:31 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of min.chen@citrix.com designates 66.165.176.89 as permitted sender) Received: from [66.165.176.89] (HELO SMTP.CITRIX.COM) (66.165.176.89) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jan 2014 17:17:23 +0000 X-IronPort-AV: E=Sophos;i="4.95,706,1384300800"; d="scan'208";a="95832993" Received: from sjcpex01cl02.citrite.net ([10.216.14.144]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/AES128-SHA; 23 Jan 2014 17:16:40 +0000 Received: from SJCPEX01CL01.citrite.net ([169.254.1.22]) by SJCPEX01CL02.citrite.net ([10.216.14.144]) with mapi id 14.02.0342.004; Thu, 23 Jan 2014 09:16:39 -0800 From: Min Chen To: "dev@cloudstack.apache.org" Subject: Re: [ISSUES] Master VMware is broken Thread-Topic: [ISSUES] Master VMware is broken Thread-Index: AQHPF9xzuZgrRf2C/UaSRwzKhwp0UJqRjkkAgADXhYCAACg3gA== Date: Thu, 23 Jan 2014 17:16:39 +0000 Message-ID: In-Reply-To: <60E91F1C-2CF3-4695-B4AD-66020395D467@GMAIL.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.3.6.130613 x-originating-ip: [10.215.3.2] Content-Type: text/plain; charset="iso-8859-1" Content-ID: <06779E70E9024F45B645B7D44985F721@citrix.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org 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" wrote: >Sorry about that :-( Thanks for finding and fixing it. > >Where did you encounter the error? I wonder why i didn=B9t catch it with m= y >tests against vmware. > >Cheers, > >Hugo > >On 23 jan. 2014, at 03:01, Min Chen wrote: > >> FYI, I checked in a fix 206c35c620a8e7a707f371e5a9e5dfd795912f5b for >>this >> to unblock my testing. >>=20 >> Thanks >> -min >>=20 >> On 1/22/14 5:43 PM, "Kelven Yang" wrote: >>=20 >>> Master VMware was broken by this commit >>>=20 >>> author Hugo=20 >>>=20 >>>Trippaers>>rc >>>=20 >>>h;h=3Db20add810e5751f53946f695b6223a8016f104a5;s=3DHugo+Trippaers;st=3Da= uthor> >>>=20 >>>>>p=3D >>>=20 >>>cloudstack.git;a=3Dsearch;h=3Db20add810e5751f53946f695b6223a8016f104a5;s= =3Dhtr >>>ip >>> paers@schubergphilis.com;st=3Dauthor> >>> Wed, 22 Jan 2014 08:34:46 +0000 (09:34 +0100) >>> committer Hugo >>>=20 >>>Trippaers>>rc >>>=20 >>>h;h=3Db20add810e5751f53946f695b6223a8016f104a5;s=3DHugo+Trippaers;st=3Dc= ommitt >>>er >>>>=20 >>>>=20 >>>>>>>?p >>>>=20 >>>>=3Dcloudstack.git;a=3Dsearch;h=3Db20add810e5751f53946f695b6223a8016f104= a5;s=3Dh >>>>tr >>>> ippaers@schubergphilis.com;st=3Dcommitter> >>> Wed, 22 Jan 2014 08:37:34 +0000 (09:37 +0100) >>> commit b20add810e5751f53946f695b6223a8016f104a5 >>> tree =20 >>>=20 >>>89e7e66704b09959bc5d77e4e20562e6dcc05306>>ep >>>=20 >>>os/asf?p=3Dcloudstack.git;a=3Dtree;h=3D89e7e66704b09959bc5d77e4e20562e6d= cc0530 >>>6; >>> hb=3Db20add810e5751f53946f695b6223a8016f104a5> >>>=20 >>>tree>>9e >>>=20 >>>7e66704b09959bc5d77e4e20562e6dcc05306;hb=3Db20add810e5751f53946f695b6223= a8 >>>01 >>> 6f104a5> |=20 >>>=20 >>>snapshot>>sh >>> ot;h=3Db20add810e5751f53946f695b6223a8016f104a5;sf=3Dtgz> >>> parent =20 >>>=20 >>>86124138a1a9129dedaf0f73fcd570156bfe53f6>>ep >>>=20 >>>os/asf?p=3Dcloudstack.git;a=3Dcommit;h=3D86124138a1a9129dedaf0f73fcd5701= 56bfe5 >>>3f >>> 6> =20 >>>=20 >>>commit>>;h >>> =3D86124138a1a9129dedaf0f73fcd570156bfe53f6> | >>>=20 >>>diff>>ff >>>=20 >>>;h=3Db20add810e5751f53946f695b6223a8016f104a5;hp=3D86124138a1a9129dedaf0= f73f >>>cd >>> 570156bfe53f6> >>> Get rid of compiler warnings in vmware-base >>>=20 >>> 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 >>>=20 >>> One of the problem comes from following code, please checkout my >>>comments >>> below. >>>=20 >>> -Kelven >>>=20 >>>=20 >>> import org.apache.log4j.Logger; >>>=20 >>> @@=20 >>>=20 >>>-144,6>>=3Dv >>>=20 >>>mware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3D3c= 2c >>>81 >>>=20 >>>d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3D3c2c81d8a5ea3e242a6407ab5a0d2710= fa >>>1d >>> 0b73#l144>=20 >>>=20 >>>+144,7>>=3Dv >>>=20 >>>mware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3De8= 16 >>>65 >>>=20 >>>f71b76a3772b13dae5cc0733d26220c64a;hb=3De81665f71b76a3772b13dae5cc0733d2= 62 >>>20 >>> c64a#l144> @@ public class VmwareClient { >>> ServiceContent serviceContent =3D >>> vimPort.retrieveServiceContent(svcInstRef); >>>=20 >>> // Extract a cookie. See vmware sample program >>> com.vmware.httpfileaccess.GetVMFiles >>> + @SuppressWarnings("unchecked") >>> Map> headers =3D (Map>>=20 >>>List>)((BindingProvider)vimPort).getResponseContext().get(Messag >>>eC >>> ontext.HTTP_RESPONSE_HEADERS); >>> List cookies =3D headers.get("Set-cookie"); >>> String cookieValue =3D cookies.get(0); >>> @@=20 >>>=20 >>>-256,17>>f=3D >>>=20 >>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3D3= c2 >>>c8 >>>=20 >>>1d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3D3c2c81d8a5ea3e242a6407ab5a0d271= 0f >>>a1 >>> d0b73#l256>=20 >>>=20 >>>+257,18>>f=3D >>>=20 >>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3De= 81 >>>66 >>>=20 >>>5f71b76a3772b13dae5cc0733d26220c64a;hb=3De81665f71b76a3772b13dae5cc0733d= 26 >>>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 getDynamicProperty(ManagedObjectReference mor, String >>> propertyName) throws Exception { >>> List props =3D new ArrayList(); >>> props.add(propertyName); >>> List objContent =3D retrieveMoRefProperties(mor, >>> props); >>>=20 >>>=20 >>>=20 >>> - Object propertyValue =3D null; >>> + T propertyValue =3D null; >>>=20 >>> [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 >>>=20 >>>=20 >>> if (objContent !=3D null && objContent.size() > 0) { >>> List dynamicProperty =3D >>> objContent.get(0).getPropSet(); >>> if (dynamicProperty !=3D null && dynamicProperty.size() > 0)= { >>> DynamicProperty dp =3D dynamicProperty.get(0); >>> - propertyValue =3D dp.getVal(); >>> + propertyValue =3D (T)dp.getVal(); >>> /* >>> * If object is ArrayOfXXX object, then get the XXX[] by >>> * invoking getXXX() on the object. >>> @@=20 >>>=20 >>>-274,13>>f=3D >>>=20 >>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3D3= c2 >>>c8 >>>=20 >>>1d8a5ea3e242a6407ab5a0d2710fa1d0b73;hb=3D3c2c81d8a5ea3e242a6407ab5a0d271= 0f >>>a1 >>> d0b73#l274>=20 >>>=20 >>>+276,13>>f=3D >>>=20 >>>vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java;h=3De= 81 >>>66 >>>=20 >>>5f71b76a3772b13dae5cc0733d26220c64a;hb=3De81665f71b76a3772b13dae5cc0733d= 26 >>>22 >>> 0c64a#l276> @@ public class VmwareClient { >>> * >>> ArrayOfManagedObjectReference.getManagedObjectReference() >>> * returns ManagedObjectReference[] array. >>> */ >>> - Class dpCls =3D propertyValue.getClass(); >>> + Class dpCls =3D >>>propertyValue.getClass(); >>> String dynamicPropertyName =3D dpCls.getName(); >>> if (dynamicPropertyName.indexOf("ArrayOf") !=3D -1) { >>> String methodName =3D "get" + >>> dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") + >>> "ArrayOf".length(), dynamicPropertyName.length()); >>>=20 >>> - Method getMorMethod =3D >>> dpCls.getDeclaredMethod(methodName, null); >>> - propertyValue =3D getMorMethod.invoke(propertyValu= e, >>> (Object[])null); >>> + Method getMorMethod =3D >>> dpCls.getDeclaredMethod(methodName, (Class)null); >>> + propertyValue =3D >>> (T)getMorMethod.invoke(propertyValue, (Object[])null); >>> } >>> } >>> } >>=20 >