You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/08/10 18:50:02 UTC

[GitHub] [cloudstack] RodrigoDLopez opened a new pull request #4256: Fix comparison using nullable objects

RodrigoDLopez opened a new pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256


   ## Description
   <!--- Describe your changes in detail -->
   This PR fix some wrongs comparison using nullable objects. Preventing null pointer exception
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ## Screenshots (if appropriate):
   
   ## How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md) document -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-672916230


   <b>Trillian test result (tid-2377)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 50814 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4256-t2377-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_iso.py
   Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_supported_versions.py
   Intermittent failure detected: /marvin/tests/smoke/test_privategw_acl.py
   Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
   Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
   Smoke tests completed. 81 look OK, 2 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_01_add_delete_kubernetes_supported_version | `Error` | 1807.47 | test_kubernetes_supported_versions.py
   test_04_rvpc_network_garbage_collector_nics | `Error` | 3834.78 | test_vpc_redundant.py
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd merged pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
rhtyd merged pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-671835141


   @rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-672375683


   @blueorangutan test 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] RodrigoDLopez commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
RodrigoDLopez commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-671639621


   @blueorangutan package


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-672376789


   @rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] RodrigoDLopez commented on a change in pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
RodrigoDLopez commented on a change in pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#discussion_r468181783



##########
File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
##########
@@ -2199,7 +2199,7 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) {
         // OfflineVmwareMigration: check storage tags on disk(offering)s in comparison to destination storage pool
         // OfflineVmwareMigration: if no match return a proper error now
         DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
-        if (diskOffering.equals(null)) {
+        if (diskOffering == null) {

Review comment:
       thanks for the hint, I did not know about this other specific use case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] RodrigoDLopez commented on a change in pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
RodrigoDLopez commented on a change in pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#discussion_r468181954



##########
File path: utils/src/test/java/com/cloud/utils/TernaryTest.java
##########
@@ -28,7 +28,7 @@ public void testEquals() {
         Assert.assertEquals(new Ternary<String, String, String>("a", "b", "c"), new Ternary<String, String, String>("a", "b", "c"));
         Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(new Ternary<String, String, String>("a", "b", "d")));
         Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(""));
-        Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(null));

Review comment:
       thanks for the hint, I did not know about this other specific use case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-671654388


   Packaging result: ✔centos7 ✔debian. JID-1702


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-671834662


   @blueorangutan test


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#issuecomment-671639933


   @RodrigoDLopez a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rafaelweingartner commented on a change in pull request #4256: Fix comparison using nullable objects

Posted by GitBox <gi...@apache.org>.
rafaelweingartner commented on a change in pull request #4256:
URL: https://github.com/apache/cloudstack/pull/4256#discussion_r468162010



##########
File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
##########
@@ -2199,7 +2199,7 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) {
         // OfflineVmwareMigration: check storage tags on disk(offering)s in comparison to destination storage pool
         // OfflineVmwareMigration: if no match return a proper error now
         DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
-        if (diskOffering.equals(null)) {
+        if (diskOffering == null) {

Review comment:
       This is the only one that makes sense to change.

##########
File path: utils/src/test/java/com/cloud/utils/TernaryTest.java
##########
@@ -28,7 +28,7 @@ public void testEquals() {
         Assert.assertEquals(new Ternary<String, String, String>("a", "b", "c"), new Ternary<String, String, String>("a", "b", "c"));
         Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(new Ternary<String, String, String>("a", "b", "d")));
         Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(""));
-        Assert.assertFalse(new Ternary<String, String, String>("a", "b", "c").equals(null));

Review comment:
       You do not need to remove the `equals` here. In this very specific use case, there is no null pointer that can happen here.

##########
File path: engine/orchestration/src/test/java/com/cloud/agent/manager/ConnectedAgentAttacheTest.java
##########
@@ -44,7 +44,7 @@ public void testEqualsFalseNull() throws Exception {
 
         ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link, false);
 
-        assertFalse(agentAttache1.equals(null));

Review comment:
       The same here. I do not understand why people coded this check, but it does not cause a null pointer. Moreover, if you change the equals to `==` here, you are changing the test case.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org