Azure / azure-cosmosdb-java

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

Null pointer when using createContainerIfNotExists() #221

Closed jdubois closed 5 years ago

jdubois commented 5 years ago

Describe the bug I have a null pointer exception when doing database.createContainerIfNotExists(new CosmosContainerProperties(CONTAINER_NAME, "/partition"))

In fact this method calls this line: https://github.com/Azure/azure-cosmosdb-java/blob/v3/sdk/src/main/java/com/azure/data/cosmos/CosmosDatabase.java#L250

Which uses a null value for the class CosmosContainerRequestOptions.

So when this line is called for creating a container: https://github.com/Azure/azure-cosmosdb-java/blob/v3/sdk/src/main/java/com/azure/data/cosmos/CosmosDatabase.java#L177 it does a options.toRequestOptions() which fails as the object is null.

Environment summary SDK Version: 3.0.0 Java JDK version: openjdk version "11.0.3" 2019-04-16 OS Version (e.g. Windows, Linux, MacOSX): MacOSX

jdubois commented 5 years ago

Interestingly, the method createContainerIfNotExists(CosmosContainerProperties containerSettings, int throughput) (which is just the same but with the thoughput added) doesn't have the issue, so just setting the throughput fixes the issue for me.

I'll propose a patch, as this is really simple.

christopheranderson commented 5 years ago

I probably caused this bug when I was fixing up the overloads for some things to not require request options.

christopheranderson commented 5 years ago

@mbhaskar - can you check if this is fixed yet? He has a PR out that fixes it that we can port to the new repo if not. If we have fixed it, please close this issue.

mbhaskar commented 5 years ago

This is fixed.