Skip to content

Commit

Permalink
Merge pull request #535 from Onlineberatung/VIC-1886-fix-npe-on-user-…
Browse files Browse the repository at this point in the history
…registration

fix: fix NPE on user registration without topics
  • Loading branch information
tkuzynow authored Oct 25, 2022
2 parents cff640e + fe67584 commit 96e5e64
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.collect.Lists;
import de.caritas.cob.userservice.api.adapters.web.dto.serialization.EncodeUsernameJsonDeserializer;
import de.caritas.cob.userservice.api.adapters.web.dto.serialization.UrlDecodePasswordJsonDeserializer;
import de.caritas.cob.userservice.api.adapters.web.dto.validation.ValidAge;
Expand Down Expand Up @@ -117,7 +118,7 @@ public class UserDTO implements UserRegistrationDTO {

@ApiModelProperty(required = false, example = "\"[1,5]\"")
@JsonProperty("topicIds")
private Collection<Integer> topicIds;
private Collection<Integer> topicIds = Lists.newArrayList();

@ApiModelProperty(required = false, example = "\"RELATIVE_COUNSELLING\"")
@JsonProperty("counsellingRelation")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.caritas.cob.userservice.api.service.consultingtype;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import de.caritas.cob.userservice.api.config.CacheManagerConfig;
import de.caritas.cob.userservice.api.config.apiclient.TopicServiceApiControllerFactory;
Expand Down Expand Up @@ -67,7 +68,13 @@ private Map<Long, TopicDTO> getAllTopicsMap(List<TopicDTO> allTopics) {
}

public List<String> findTopicsInternalAttributes(Collection<Integer> topicsList) {
return topicsList.stream().map(this::findTopicInternalIdentifier).collect(Collectors.toList());
if (topicsList == null) {
return Lists.newArrayList();
} else {
return topicsList.stream()
.map(this::findTopicInternalIdentifier)
.collect(Collectors.toList());
}
}

public String findTopicInternalIdentifier(Integer topicId) {
Expand Down

0 comments on commit 96e5e64

Please sign in to comment.