Bug 1500 - Null pointer exception when using mounted resources tab to 07/23807/2
authorJan Hajnar <jhajnar@cisco.com>
Tue, 7 Jul 2015 09:38:33 +0000 (11:38 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 22 Jul 2015 07:42:57 +0000 (07:42 +0000)
see the operations on mount point

* added check for when revision is null in modules comparator

Change-Id: I3bdc4ed798297d31ea25001d25918e298c8124bb
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/BaseYangSwaggerGenerator.java

index c8bf6e6675e1f10278fe218986e54313ba0bb79a..c86b89c004b645aa42e31b86320077278ff23551 100644 (file)
@@ -388,13 +388,15 @@ public class BaseYangSwaggerGenerator {
 
         SortedSet<Module> sortedModules = new TreeSet<>(new Comparator<Module>() {
             @Override
 
         SortedSet<Module> sortedModules = new TreeSet<>(new Comparator<Module>() {
             @Override
-            public int compare(Module o1, Module o2) {
-                int result = o1.getName().compareTo(o2.getName());
+            public int compare(Module module1, Module module2) {
+                int result = module1.getName().compareTo(module2.getName());
                 if (result == 0) {
                 if (result == 0) {
-                    result = o1.getRevision().compareTo(o2.getRevision());
+                    Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0);
+                    Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0);
+                    result = module1Revision.compareTo(module2Revision);
                 }
                 if (result == 0) {
                 }
                 if (result == 0) {
-                    result = o1.getNamespace().compareTo(o2.getNamespace());
+                    result = module1.getNamespace().compareTo(module2.getNamespace());
                 }
                 return result;
             }
                 }
                 return result;
             }