twilio/twilio-java — pull request #122 by codylerum (2014-01-09 23:44:09+00:00)
Title: only set the request account sid on ListResource loaded objects if it wasn't previously set

This digs a little deep into the code so a bit of review would be appreciated.

What it looks like was happening was that the AccounList#makeNew is being called when creating Account objects from the response. https://github.com/twilio/twilio-java/blob/master/src/main/java/com/twilio/sdk/resource/list/AccountList.java#L51

That then calls the new Account(client,params) constructor which correctly sets the requestAccountSid to be that of the specific Account instance that as retreived. https://github.com/twilio/twilio-java/blob/master/src/main/java/com/twilio/sdk/resource/instance/Account.java#L68

However the ListResource#extract_object then overwrote that with the requestAccountSid of the AccountList instance which has the requestSid of the TwilioRestClient

By only setting ONLY if NOT already set we handle the case where Account properly sets it and a case where something like CallList#makeNew -> new Call(client,params) doesn't set it to anything.