From 34fb6acc44c14b6f4f1ed6eacde263148cb83e31 Mon Sep 17 00:00:00 2001 From: Vishwas Babu A J Date: Tue, 4 Nov 2014 12:18:20 +0530 Subject: [PATCH] fixing null pointer exception during client creation --- ...WritePlatformServiceJpaRepositoryImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java index 674405321..8eb501644 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java @@ -581,15 +581,16 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP private void validateParentGroupRulesBeforeClientActivation(Client client) { Integer minNumberOfClients = configurationDomainService.retrieveMinAllowedClientsInGroup(); Integer maxNumberOfClients = configurationDomainService.retrieveMaxAllowedClientsInGroup(); - for (Group group : client.getGroups()) { - /** - * Since this Client has not yet been associated with the group, - * reduce maxNumberOfClients by 1 - **/ - final boolean validationsuccess = group.isGroupsClientCountWithinMaxRange(maxNumberOfClients - 1); - if (!validationsuccess) { throw new GroupMemberCountNotInPermissibleRangeException(group.getId(), minNumberOfClients, - maxNumberOfClients); } + if (client.getGroups() != null) { + for (Group group : client.getGroups()) { + /** + * Since this Client has not yet been associated with the group, + * reduce maxNumberOfClients by 1 + **/ + final boolean validationsuccess = group.isGroupsClientCountWithinMaxRange(maxNumberOfClients - 1); + if (!validationsuccess) { throw new GroupMemberCountNotInPermissibleRangeException(group.getId(), minNumberOfClients, + maxNumberOfClients); } + } } } - } \ No newline at end of file