Azure / azure-cosmosdb-java

Java Async SDK for SQL API of Azure Cosmos DB
MIT License
54 stars 61 forks source link

NPE in IndexingPolicy.getCompositeIndexes() #195

Closed dconnelly closed 5 years ago

dconnelly commented 5 years ago

Describe the bug

Calling DocumentCollection.getIndexingPolicy().getCompositeIndexes() can NPE if a container has no composite indexes. Problem is at IndexingPolicy.java line 204:

ArrayNode compositeIndexes = (ArrayNode) super.get(Constants.Properties.COMPOSITE_INDEXES);
for (int i = 0; i < compositeIndexes.size(); i ++) {
...

If the property bag does not contain a composite indexes property, the for loop will NPE.

To Reproduce Use readCollection() to read a collection, then call getIndexingPolicy().getCompositeIndexes()

Expected behavior Should return composite indexes list.

Actual behavior Throws NPE

Environment summary SDK Version: 2.4.5 Java JDK version: Java 8 OS Version (e.g. Windows, Linux, MacOSX) MacOSX

Additional context Add any other context about the problem here.

christopheranderson commented 5 years ago

@mbhaskar let's get this in the 2.5.0 train since you already have the other hotfix that needs the stress test before it goes out.

christopheranderson commented 5 years ago

Shipped a fix in 2.5.0. Should be live now. Will be indexed on maven in the next day or so depending on how long maven takes.