Skip to content

Conversation

@RaRe2604
Copy link
Contributor

@RaRe2604 RaRe2604 commented Dec 3, 2020

Null check on resourceType

Null check on resourceType
@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Dec 3, 2020
@ghost
Copy link

ghost commented Dec 3, 2020

Thank you for your contribution RaRe2604! We will review the pull request and get back to you soon.

@ghost
Copy link

ghost commented Dec 3, 2020

CLA assistant check
All CLA requirements met.

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Dec 4, 2020

Hi @RaRe2604
Thanks for your contribution.

If the resource type is null, does it mean that the source resource ID/URI is not correctly provided?

Note that checkstyle requires 4 space indention.

[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:37: 'if' child has incorrect indentation level 15, expected level should be 16. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:40: 'if' child has incorrect indentation level 15, expected level should be 16. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:41: 'if' has incorrect indentation level 15, expected level should be 16. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:42: 'if' child has incorrect indentation level 18, expected level should be 20. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:43: 'if rcurly' has incorrect indentation level 15, expected level should be 16. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:44: 'if' has incorrect indentation level 15, expected level should be 16. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:45: 'if' child has incorrect indentation level 18, expected level should be 20. [Indentation]
[ERROR] /home/vsts/work/1/s/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/CreationSource.java:46: 'if rcurly' has incorrect indentation level 15, expected level should be 16. [Indentation]

@RaRe2604
Copy link
Contributor Author

RaRe2604 commented Dec 4, 2020

Hi @weidongxu-microsoft Thanks I'll take care of the style.

Yes, resourceType is not checked for null and can throw NullPointerException.
We must use String literals first (if we have one) to avoid NPE.

Example:
In the below code if we pass null to heyInfo, it will throw NPE

String heyInfo = "Hey";
heyInfo.equalsIgnoreCase("Hello World");

A simple tweak to avoid NPE

String heyInfo = "Hey";
"Hello World".equalsIgnoreCase(heyInfo);

@weidongxu-microsoft
Copy link
Member

@RaRe2604
Sure. I asked to check that if you encountered the NPE, whether it helps more to continue the flow, or to throw an IllegalArgumentException. If you didn't encountered the NPE, it is fine.

As long as the checkstyle passes, we can merge the fix.

modified respective to Style check
Modified for Style check
@RaRe2604
Copy link
Contributor Author

RaRe2604 commented Dec 4, 2020

@weidongxu-microsoft It will continue the flow.

@weidongxu-microsoft weidongxu-microsoft merged commit eac5664 into Azure:master Dec 4, 2020
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-java that referenced this pull request Apr 24, 2022
[Hub Generated] Review request for Microsoft.Devices to add version stable/2022-02-05 (Azure#17948)

* Adds base for updating Microsoft.Devices from version stable/2021-10-15 to version 2022-02-05

* Updates readme

* Updates API version in new specs and examples

* definition changes

* example changes

* no comments

* swagger modelval fix #1

* general validation fix #1

* revert readonly change (breaking change)

* added locatio pvtEp example

* misplaced location param

* location in PvtEConn response

* header addition

* headers #2

* example change with location sans spec

* header nesting change

* header under headers

* header example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants