Hi Will,

I tested this against a local KVM-based 4.9.2.0 environment and I could not 
reproduce the error. I see this in api logs:


==> apilog.log <==
2017-04-13 18:16:30,340 INFO  [a.c.c.a.ApiServer] (catalina-exec-5:ctx-2b0966b8 
ctx-2760e856) (logid:7439bdc4) (userId=2 accountId=2 
sessionId=6183303731812D5EC32B1B37445AEC60) 192.168.1.58 -- GET 
signatureversion=3&sessionkey=H6E-LUsWpVY6WT_mJzz7qjGAdxg&command=listPublicIpAddresses&projectid=-1&expires=2017-04-13T16%3A26%3A30%2B0000&response=json&listall=true
 200 {"listpublicipaddressesresponse":{}}

I think proper way to fix this would be to check that project object is not 
null before calling any methods on it.


Regards.

________________________________
From: Will Stevens <sw...@apache.org>
Sent: 13 April 2017 21:38:34
To: dev@cloudstack.apache.org
Subject: Null Pointer listing public ips for a project

Hey All,
Looking for the best way to resolve this issue.

My line numbers in the stack trace will not match the line numbers I
reference because I am running 4.7 and I am linking the master files.  From
what I can tell by reviewing the code, this has not been fixed in master.
So here goes.

When making a call to listPublicIpAddresses [1] with 'listall=true' and
'projectid=-1', I get the following stacktrace.

java.lang.NullPointerException
at
com.cloud.api.ApiResponseHelper.populateOwner(ApiResponseHelper.java:2258)
at
com.cloud.api.ApiResponseHelper.createIPAddressResponse(ApiResponseHelper.java:718)
at
org.apache.cloudstack.api.command.admin.address.ListPublicIpAddressesCmdByAdmin.execute(ListPublicIpAddressesCmdByAdmin.java:44)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:150)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:698)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:529)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:297)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:127)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:124)
at com.cloud.api.ApiServlet.doGet(ApiServlet.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:299)
at
org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:889)
at
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:732)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2274)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)


The stack trace comes from this code [2]:
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getUuid());  // <-- Null Pointer
response.setProjectName(project.getName());

In this case, the flow is coming from [3], which comes from [4].

What would be the right way to fix this issue?

Thanks...

[1]
https://cloudstack.apache.org/api/apidocs-4.7/root_admin/listPublicIpAddresses.html
[2]
https://github.com/apache/cloudstack/blob/master/server/src/com/cloud/api/ApiResponseHelper.java#L2303
[3]
https://github.com/apache/cloudstack/blob/master/server/src/com/cloud/api/ApiResponseHelper.java#L761
[4]
https://github.com/apache/cloudstack/blob/master/api/src/org/apache/cloudstack/api/command/admin/address/ListPublicIpAddressesCmdByAdmin.java#L44

*Will Stevens*

rohit.ya...@shapeblue.comĀ 
www.shapeblue.com
53 Chandos Place, Covent Garden, London  WC2N 4HSUK
@shapeblue
  
 

Reply via email to