Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return null on GET 404 #1206

Merged
merged 1 commit into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public PagedList<BatchAccount> listByGroup(String resourceGroupName) {

@Override
protected BatchAccountImpl wrapModel(BatchAccountInner inner) {
if (inner == null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be simpler/cleaner to just say:
return (inner == null) ? inner : new .... ;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be simpler/cleaner to just say:
return (inner == null) ? null : new .... ;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually find inline conditionals hard to read, particularly in this case the line gets too long with the inline constructor call. Inline conditionals are forbidden in Sun's original checkstyle rules: http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals but we are not reinforcing it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

return null;
}
return new BatchAccountImpl(
inner.name(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ protected AvailabilitySetImpl wrapModel(String name) {

@Override
protected AvailabilitySetImpl wrapModel(AvailabilitySetInner availabilitySetInner) {
if (availabilitySetInner == null) {
return null;
}
return new AvailabilitySetImpl(availabilitySetInner.name(),
availabilitySetInner,
this.innerCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public PagedList<VirtualMachineExtensionImageType> list() {

@Override
protected VirtualMachineExtensionImageTypeImpl wrapModel(VirtualMachineExtensionImageInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineExtensionImageTypeImpl(this.client, this.publisher, inner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public PagedList<VirtualMachineExtensionImageVersion> list() {

@Override
protected VirtualMachineExtensionImageVersionImpl wrapModel(VirtualMachineExtensionImageInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineExtensionImageVersionImpl(this.client, this.type, inner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class VirtualMachineOffersImpl

@Override
protected VirtualMachineOfferImpl wrapModel(VirtualMachineImageResourceInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineOfferImpl(this.publisher, inner.name(), this.innerCollection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public PagedList<VirtualMachinePublisher> listByRegion(Region region) {

@Override
protected VirtualMachinePublisherImpl wrapModel(VirtualMachineImageResourceInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachinePublisherImpl(Region.fromName(inner.location()),
inner.name(),
this.imagesInnerCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ protected VirtualMachineScaleSetImpl wrapModel(String name) {

@Override
protected VirtualMachineScaleSetImpl wrapModel(VirtualMachineScaleSetInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineScaleSetImpl(inner.name(),
inner,
this.innerCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public PagedList<VirtualMachineSize> listByRegion(Region region) {

@Override
protected VirtualMachineSizeImpl wrapModel(VirtualMachineSizeInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineSizeImpl(inner);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public PagedList<VirtualMachineSku> list() {

@Override
protected VirtualMachineSkuImpl wrapModel(VirtualMachineImageResourceInner inner) {
if (inner == null) {
return null;
}
return new VirtualMachineSkuImpl(this.offer, inner.name(), innerCollection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ protected VirtualMachineImpl wrapModel(String name) {

@Override
protected VirtualMachineImpl wrapModel(VirtualMachineInner virtualMachineInner) {
if (virtualMachineInner == null) {
return null;
}
return new VirtualMachineImpl(virtualMachineInner.name(),
virtualMachineInner,
this.innerCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ protected ServicePrincipalImpl wrapModel(String appId) {

@Override
protected ServicePrincipalImpl wrapModel(ServicePrincipalInner servicePrincipalInner) {
if (servicePrincipalInner == null) {
return null;
}
return new ServicePrincipalImpl(servicePrincipalInner, this.innerCollection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ protected UserImpl wrapModel(String userPrincipalName) {

@Override
protected UserImpl wrapModel(UserInner userInner) {
if (userInner == null) {
return null;
}
return new UserImpl(userInner, this.innerCollection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ protected VaultImpl wrapModel(String name) {

@Override
protected VaultImpl wrapModel(VaultInner vaultInner) {
if (vaultInner == null) {
return null;
}
return new VaultImpl(
vaultInner.name(),
vaultInner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected LoadBalancerImpl wrapModel(String name) {

@Override
protected LoadBalancerImpl wrapModel(LoadBalancerInner inner) {
if (inner == null) {
return null;
}
return new LoadBalancerImpl(
inner.name(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ protected NetworkInterfaceImpl wrapModel(String name) {

@Override
protected NetworkInterfaceImpl wrapModel(NetworkInterfaceInner inner) {
if (inner == null) {
return null;
}
return new NetworkInterfaceImpl(inner.name(),
inner,
this.innerCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected NetworkSecurityGroupImpl wrapModel(String name) {

@Override
protected NetworkSecurityGroupImpl wrapModel(NetworkSecurityGroupInner inner) {
if (inner == null) {
return null;
}
return new NetworkSecurityGroupImpl(
inner.name(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ protected NetworkImpl wrapModel(String name) {

@Override
protected NetworkImpl wrapModel(VirtualNetworkInner inner) {
if (inner == null) {
return null;
}
return new NetworkImpl(
inner.name(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ protected PublicIpAddressImpl wrapModel(String name) {

@Override
protected PublicIpAddressImpl wrapModel(PublicIPAddressInner inner) {
if (inner == null) {
return null;
}
return new PublicIpAddressImpl(
inner.id(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ protected RedisCacheImpl wrapModel(String name) {

@Override
protected RedisCacheImpl wrapModel(RedisResourceInner redisResourceInner) {
if (redisResourceInner == null) {
return null;
}
return new RedisCacheImpl(
redisResourceInner.name(),
redisResourceInner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public abstract class PagedListConverter<U, V> {
* @return the converted list
*/
public PagedList<V> convert(final PagedList<U> uList) {
if (uList == null || uList.isEmpty()) {
return new PagedList<V>() {
@Override
public Page<V> nextPage(String s) throws RestException, IOException {
return null;
}
};
}
Page<U> uPage = uList.currentPage();
PageImpl<V> vPage = new PageImpl<>();
vPage.setNextPageLink(uPage.getNextPageLink());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public DeploymentOperation getById(String operationId) {

@Override
protected DeploymentOperationImpl wrapModel(DeploymentOperationInner inner) {
if (inner == null) {
return null;
}
return new DeploymentOperationImpl(inner, this.client);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public Feature register(String resourceProviderName, String featureName) {

@Override
protected FeatureImpl wrapModel(FeatureResultInner inner) {
if (inner == null) {
return null;
}
return new FeatureImpl(inner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package com.microsoft.azure.management.resources.implementation;

import com.microsoft.azure.CloudException;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.resources.GenericResource;
import com.microsoft.azure.management.resources.GenericResources;
Expand Down Expand Up @@ -86,7 +85,7 @@ public GenericResource get(
return resource;
}
}
throw new CloudException("Generic resource not found.");
return null;
}

@Override
Expand Down Expand Up @@ -153,6 +152,9 @@ protected GenericResourceImpl wrapModel(String id) {

@Override
protected GenericResourceImpl wrapModel(GenericResourceInner inner) {
if (inner == null) {
return null;
}
return new GenericResourceImpl(
inner.id(),
inner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public Provider getByName(String resourceProviderNamespace) {

@Override
protected ProviderImpl wrapModel(ProviderInner inner) {
if (inner == null) {
return null;
}
return new ProviderImpl(inner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ protected ResourceGroupImpl wrapModel(String name) {

@Override
protected ResourceGroupImpl wrapModel(ResourceGroupInner inner) {
if (inner == null) {
return null;
}
return new ResourceGroupImpl(inner, serviceClient);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public Subscription typeConvert(SubscriptionInner subscriptionInner) {
// Gets a specific resource group
public SubscriptionImpl getByName(String name) {
SubscriptionInner subscription = client.get(name);
if (subscription == null) {
return null;
}
return new SubscriptionImpl(subscription, client);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ protected StorageAccountImpl wrapModel(String name) {

@Override
protected StorageAccountImpl wrapModel(StorageAccountInner storageAccountInner) {
if (storageAccountInner == null) {
return null;
}
return new StorageAccountImpl(
storageAccountInner.name(),
storageAccountInner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public PagedList<StorageUsage> list() {

@Override
protected UsageImpl wrapModel(UsageInner usageInner) {
if (usageInner == null) {
return null;
}
return new UsageImpl(usageInner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ protected AppServicePlanImpl wrapModel(String name) {

@Override
protected AppServicePlanImpl wrapModel(AppServicePlanInner inner) {
if (inner == null) {
return null;
}
return new AppServicePlanImpl(inner.name(), inner, innerCollection, myManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ protected CertificateOrderImpl wrapModel(String name) {

@Override
protected CertificateOrderImpl wrapModel(AppServiceCertificateOrderInner inner) {
if (inner == null) {
return null;
}
return new CertificateOrderImpl(inner.name(), inner, innerCollection, myManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ protected CertificateImpl wrapModel(String name) {

@Override
protected CertificateImpl wrapModel(CertificateInner inner) {
if (inner == null) {
return null;
}
return new CertificateImpl(inner.name(), inner, innerCollection, myManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ protected WebAppImpl wrapModel(String name) {

@Override
protected WebAppImpl wrapModel(SiteInner inner) {
if (inner == null) {
return null;
}
return new WebAppImpl(inner.name(), inner, innerCollection, super.myManager);
}

Expand Down