Added error handling to the creation of LinkedLists
authorJani <jani@asema.com>
Tue, 27 Aug 2019 18:42:29 +0000 (21:42 +0300)
committerJani <jani@asema.com>
Tue, 27 Aug 2019 18:42:29 +0000 (21:42 +0300)
Common/Java/SmartAPI/src/smartapi/rdf/LinkedList.java

index 4160c1d1a33ec2ba03396ec57a937458fc6ca960..4c982cf6639dcf396707e6d9d1d53a50c0d21a46 100644 (file)
@@ -39,9 +39,14 @@ public class LinkedList extends List {
                        }
                }
                // add statements from the List to this LinkedList
-               Resource linkedListResource = model.createList(items);
-               // add rdf list into smart api linked list resource
-               resource.addProperty( model.createProperty( PROPERTY.getUri(PROPERTY.ENTRIES)), linkedListResource );
+               try {
+                       Resource linkedListResource = model.createList(items);
+                       // add rdf list into smart api linked list resource
+                       resource.addProperty( model.createProperty( PROPERTY.getUri(PROPERTY.ENTRIES)), linkedListResource );
+               } catch (java.lang.NullPointerException npe) {
+                       System.err.println("Failed to add items into LinkedList, some were null.");
+                       npe.printStackTrace();
+               }
                return resource;
        }