alexandru-bagu commented on a change in pull request #4516:
URL: https://github.com/apache/cloudstack/pull/4516#discussion_r540020894



##########
File path: 
plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
##########
@@ -133,7 +133,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
         String providerName = (String)dsInfos.get("providerName");
         HypervisorType hypervisorType = HypervisorType.None;
         if(dsInfos.containsKey("hypervisorType")) {
-            hypervisorType = 
HypervisorType.getType((String)dsInfos.get("hypervisorType"));
+            hypervisorType = 
HypervisorType.getType(dsInfos.get("hypervisorType").toString());

Review comment:
       Unless I am wrong, .toString is implemented by the compiler for enums. 
My aim was to provide a quick fix for this issue and I did a small test to show 
that the code above works. https://github.com/alexandru-bagu/java-enum-test
   
   The point of .toString there is that if the object given is either String or 
HypervisorType then both will provide the same output for .toString unless as 
you have said one overrides the .toString for the enum. In this case it is not 
overriden as such the code will work.
   
   Though I agree, this not the correct way to fix it. I will make it a cast to 
HypervisorType and change the function call that provides the wrong type.




----------------------------------------------------------------
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:
[email protected]


Reply via email to