Github user DaanHoogland commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1530#discussion_r64353084
  
    --- Diff: 
vmware-base/src/com/cloud/hypervisor/vmware/mo/VmdkFileDescriptor.java ---
    @@ -47,25 +49,28 @@ public void parse(byte[] vmdkFileContent) throws 
IOException {
                 while ((line = in.readLine()) != null) {
                     // ignore empty and comment lines
                     line = line.trim();
    -                if (line.isEmpty())
    +                if (line.isEmpty()) {
                         continue;
    -                if (line.charAt(0) == '#')
    +                }
    +                if (line.charAt(0) == '#') {
                         continue;
    +                }
     
    -                String[] tokens = line.split("=");
    +                final String[] tokens = line.split("=");
                     if (tokens.length == 2) {
    -                    String name = tokens[0].trim();
    +                    final String name = tokens[0].trim();
                         String value = tokens[1].trim();
    -                    if (value.charAt(0) == '\"')
    +                    if (value.charAt(0) == '\"') {
                             value = value.substring(1, value.length() - 1);
    +                    }
     
                         _properties.put(name, value);
                     } else {
                         if (line.startsWith("RW")) {
    -                        int startPos = line.indexOf('\"');
    -                        int endPos = line.lastIndexOf('\"');
    -                        assert (startPos > 0);
    -                        assert (endPos > 0);
    +                        final int startPos = line.indexOf('\"');
    +                        final int endPos = line.lastIndexOf('\"');
    +                        assert startPos > 0;
    +                        assert endPos > 0;
    --- End diff --
    
    using checkState
    indexOf and lastIndexOf on the same string will not ever result in endPos < 
startPos by contract, only startPos >0 and endPos != startPos should do. This 
is however searching '\' insted of FileSeparator and other improvements are 
sure to be possible, so I will leave that to a new PR someday as this change is 
old already and should leave my memory.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to