NullPointerException when using UserManagementClient
Hi there, I’m having some trouble when calling the rxjava UserManagementClient like this:
ledgerClient.getUserManagementClient.createUser(
new CreateUserRequest(
new User(myUser),
new User.Right.CanActAs(myParty1),
new User.Right.CanActAs(myParty2)
)
).blockingGet();
It’s giving me a NullPointerException. There is no issue when using the other CreateUserRequest constructor – see below:
ledgerClient.getUserManagementClient().createUser(new CreateUserRequest(myUser, myParty)).blockingGet();
Note - my rxjava bindings version is 2.6.0
Can you share the full stack trace you get?
Here it is:
java.lang.NullPointerException: null
at com.daml.ledger.api.v1.admin.UserManagementServiceOuterClass$User$Builder.setPrimaryParty(UserManagementServiceOuterClass.java:1028)
at com.daml.ledger.javaapi.data.User.toProto(User.java:29)
at com.daml.ledger.javaapi.data.CreateUserRequest.toProto(CreateUserRequest.java:40)
at com.daml.ledger.rxjava.grpc.UserManagementClientImpl.createUser(UserManagementClientImpl.java:30)
at com.daml.ledger.rxjava.grpc.UserManagementClientImpl.createUser(UserManagementClientImpl.java:36)
...
It looks like there is probably a bug when trying to create a user without a primary party. Are you deliberately not setting one? Could you try new User(myUser, myParty1)?
No, I didn’t do it deliberately. I can set the primary party if needed. Is the primary party required?
It definitely shouldn’t be but I suspect it works around the bug here.
My workaround is to set the primary party as shown below. Must be some bug related to not having a primary party.
ledgerClient.getUserManagementClient.createUser(
new CreateUserRequest(
new User(myUser, myParty1),
new User.Right.CanActAs(myParty1),
new User.Right.CanActAs(myParty2)
)
).blockingGet();
Thanks, I’ve reported it to the responsible team.