[NO ISSUE][TYPE] Avoid 'null' collection types

- user model changes: no
- storage format changes: no
- interface changes: no

Change-Id: Id7ab2a20e776152ecf35d5bd01b1eded7e987e26
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3247
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
index 9edfddb..bb620b0 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
@@ -48,6 +48,8 @@
 import org.apache.asterix.om.types.TypeSignature;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 
+import static org.apache.asterix.om.types.BuiltinType.ANY;
+
 public class TypeTranslator {
 
     private TypeTranslator() {
@@ -200,7 +202,7 @@
             throws AlgebricksException {
         TypeExpression tExpr = oltd.getItemTypeExpression();
         String typeName = typeSignature != null ? typeSignature.getName() : null;
-        AOrderedListType aolt = new AOrderedListType(null, typeName);
+        AOrderedListType aolt = new AOrderedListType(ANY, typeName);
         setCollectionItemType(tExpr, typeMap, incompleteItemTypes, incompleteFieldTypes, aolt, defaultDataverse);
         return aolt;
     }
@@ -212,7 +214,7 @@
             throws AlgebricksException {
         TypeExpression tExpr = ultd.getItemTypeExpression();
         String typeName = typeSignature != null ? typeSignature.getName() : null;
-        AUnorderedListType ault = new AUnorderedListType(null, typeName);
+        AUnorderedListType ault = new AUnorderedListType(ANY, typeName);
         setCollectionItemType(tExpr, typeMap, incompleteItemTypes, incompleteFieldTypes, ault, defaulDataverse);
         return ault;
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
index 9defce0..711b2f3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
@@ -31,8 +31,7 @@
 
     private static final long serialVersionUID = 1L;
 
-    // TODO: why is the item type "null"? why not ANY?
-    public static final AUnorderedListType FULLY_OPEN_UNORDEREDLIST_TYPE = new AUnorderedListType(null, "");
+    public static final AUnorderedListType FULLY_OPEN_UNORDEREDLIST_TYPE = new AUnorderedListType(BuiltinType.ANY, "");
 
     /**
      * @param itemType
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AbstractCollectionType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AbstractCollectionType.java
index 1b2b8fe..4b748a9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AbstractCollectionType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AbstractCollectionType.java
@@ -18,6 +18,8 @@
  */
 package org.apache.asterix.om.types;
 
+import java.util.Objects;
+
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.io.IJsonSerializable;
 import org.apache.hyracks.api.io.IPersistedResourceRegistry;
@@ -33,7 +35,7 @@
 
     AbstractCollectionType(IAType itemType, String typeName) {
         super(typeName);
-        this.itemType = itemType;
+        this.itemType = Objects.requireNonNull(itemType);
     }
 
     public boolean isTyped() {