From ac03051d8950affddec11dda40bb84789d3a1601 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 31 Jan 2023 15:23:56 +0100 Subject: [PATCH] Continued: - added checks on addressbookUserOwner field --- .../jaddressbookshare/model/shared/AddressbookShare.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java index e0c903d..351cf82 100644 --- a/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java +++ b/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java @@ -149,6 +149,15 @@ public class AddressbookShare implements ShareableAddressbook { } else if (addressbook.getAddressbookId() < 1) { // Invalid id number throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N + } else if (addressbook.getAddressbookUser() == null) { + // Throw NPE again + throw new NullPointerException("addressbook.addressbookUser is null"); //NOI18N + } else if (addressbook.getAddressbookUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("addressbook.addressbookUser.userId is null"); //NOI18N + } else if (addressbook.getAddressbookUser().getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid.", addressbook.getAddressbookUser().getUserId())); //NOI18N } else if (Objects.equals(addressbook.getAddressbookUser(), sharee)) { // Sharing with yourself! throw new IllegalStateException("User tries to share with himself."); //NOI18N -- 2.39.5