>           ip = floatingIpApi.create();
> +         if(ip == null){
> +              throw new InsufficientResourcesException();
> +         }

You’ve got it right on controlling execution flow with exceptions but I opted 
to go this route to keep as much existing code in place (whether for good or 
bad). But yea I think putting the functionality out to a method makes sense. 
Let me see what I can put together …

From: Ignasi Barrera [mailto:notificati...@github.com]
Sent: Tuesday, July 01, 2014 3:20 AM
To: jclouds/jclouds
Cc: Dancy, Chris
Subject: Re: [jclouds] JCLOUDS-607: ComputeService.createNodesInGroup throws 
NPE on FloatingIPA... (#425)


In 
apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java:

>           ip = floatingIpApi.create();

> +         if(ip == null){

> +             throw new InsufficientResourcesException();

> +         }

I wouldn't use exceptions to control the execution flow. I understand it might 
be trivial here, but it is in general a bad practice.

Could the code inside the catch be moved out to a method, call it from the 
catch and when the returned ip is null, and remove that throws?

—
Reply to this email directly or view it on 
GitHub<https://github.com/jclouds/jclouds/pull/425/files#r14391427>.


---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/425/files#r14404173

Reply via email to