Darren, I saw you introduced this transaction code. Can you shed a light to the behavior I describe?
On Thu, May 8, 2014 at 1:41 PM, Daan Hoogland <daan.hoogl...@gmail.com> wrote: > Hugo noted that the log of the roll back might actually occur after > the null pointer. That still leaves the fact that the pointer is first > a valid returned object and then causes a npe after that. Any hints as > to how this transaction mech works? > > On Thu, May 8, 2014 at 10:51 AM, Daan Hoogland <daan.hoogl...@gmail.com> > wrote: >> H all, >> >> consider the folowing please >> >> A network is created and used >> >> privateNetwork = >> _networkMgr.createGuestNetwork(ntwkOffFinal.getId(), networkName, >> displayText, gateway, cidr, uriString, null, owner, null, pNtwk, >> pNtwk.getDataCenterId(), >> ACLType.Account, null, vpcId, null, null, true, null); >> s_logger.debug("Created private network " + privateNetwork); >> >> the next line[3987] in the logic is (there is an else block in between): >> PrivateIpVO privateIp = >> _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), >> startIp, vpcId); >> >> the sequence logs as follows: >> >> log succes return of npe >> log the roll back >> log an npe on the object just returned and logged >> >> 2014-04-30 21:38:37,417 DEBUG [c.c.n.NetworkServiceImpl] >> (catalina-exec-17:ctx-d1365378 ctx-664fada1 ctx-e0adfbee) Created >> private network Ntwk[cf4d60e1-9d4a-46de-85bc-910a6ea44024|Guest|5] >> 2014-04-30 21:38:37,433 DEBUG [c.c.u.d.T.Transaction] >> (catalina-exec-17:ctx-d1365378 ctx-664fada1 ctx-e0adfbee) Rolling back >> the transaction: Time = 209 Name = catalina-exec-17; called by >> -TransactionLegacy.rollback:903-TransactionLegacy.removeUpTo:846-TransactionLegacy.close:670-Transaction.execute:41-NetworkServiceImpl.createPrivateNetwork:3964-NativeMethodAccessorImpl.invoke0:-2-NativeMethodAccessorImpl.invoke:-1-DelegatingMethodAccessorImpl.invoke:-1-Method.invoke:-1-AopUtils.invokeJoinpointUsingReflection:317-ReflectiveMethodInvocation.invokeJoinpoint:183-ReflectiveMethodInvocation.proceed:150 >> 2014-04-30 21:38:37,452 ERROR [c.c.a.ApiServer] >> (catalina-exec-17:ctx-d1365378 ctx-664fada1 ctx-e0adfbee) unhandled >> exception executing api command: [Ljava.lang.String;@1925edc3 >> java.lang.NullPointerException >> at >> com.cloud.network.NetworkServiceImpl$11.doInTransaction(NetworkServiceImpl.java:3987) >> ... >> >> it can of course be the _privateIpDao but I am trusting spring and the >> class strucutre here. there is no logic between the two lines. so >> privateNetwork must be the null involved in the npe. It has just been >> logged and *after that* rolled back. >> So in parallel to the network object being successfully returned the >> transaction is being rolled back. What evil genius has been at work >> here??? Or how stupid am I? >> >> I am sure similar issues must have been discussed earlier. any >> pointers? How can/Should I make sure an object returned is indeed >> valid? >> >> thanks, >> -- >> Daan > > > > -- > Daan -- Daan