Browse code

BM-13632 Fix: prevent NPE when DirEntry has no mailbox

Thomas Cataldo authored on 10/10/2018 10:42:52
Showing 1 changed files
... ...
@@ -26,7 +26,6 @@ import java.nio.file.Path;
26 26
 import java.nio.file.Paths;
27 27
 import java.nio.file.SimpleFileVisitor;
28 28
 import java.nio.file.attribute.BasicFileAttributes;
29
-import java.util.Collection;
30 29
 import java.util.Collections;
31 30
 import java.util.HashMap;
32 31
 import java.util.List;
... ...
@@ -51,7 +50,6 @@ import com.netflix.hollow.api.producer.fs.HollowFilesystemBlobStorageCleaner;
51 51
 import com.netflix.hollow.api.producer.fs.HollowFilesystemPublisher;
52 52
 
53 53
 import net.bluemind.config.InstallationId;
54
-import net.bluemind.core.api.Email;
55 54
 import net.bluemind.core.container.model.ItemValue;
56 55
 import net.bluemind.core.context.SecurityContext;
57 56
 import net.bluemind.core.rest.ServerSideServiceProvider;
... ...
@@ -192,7 +190,7 @@ public class DirectorySerializer implements DataSerializer {
192 192
 				return location;
193 193
 			});
194 194
 		}
195
-		rec.emails = toEmails(box.value.emails);
195
+		rec.emails = toEmails(box);
196 196
 		rec.name = serializer.get(DirEntrySerializer.Property.DisplayName).toString();
197 197
 		rec.email = serializer.get(DirEntrySerializer.Property.Email).toString();
198 198
 		rec.kind = serializer.get(DirEntrySerializer.Property.Kind).toString();
... ...
@@ -233,11 +231,11 @@ public class DirectorySerializer implements DataSerializer {
233 233
 		return rec;
234 234
 	}
235 235
 
236
-	private List<net.bluemind.directory.hollow.datamodel.Email> toEmails(Collection<Email> emails) {
237
-		if (null == emails) {
236
+	private List<net.bluemind.directory.hollow.datamodel.Email> toEmails(ItemValue<Mailbox> box) {
237
+		if (box == null || box.value.emails == null) {
238 238
 			return Collections.emptyList();
239 239
 		}
240
-		return emails.stream()
240
+		return box.value.emails.stream()
241 241
 				.map(e -> net.bluemind.directory.hollow.datamodel.Email.create(e.address, e.isDefault, e.allAliases))
242 242
 				.collect(Collectors.toList());
243 243
 	}