mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-21 21:25:38 +00:00
avoid NPEs when MarkProperties have null as their tags collection
This commit is contained in:
+3
-1
@@ -48,7 +48,9 @@ public class CourseTemplateJsonSerializer implements JsonSerializer<CourseTempla
|
||||
result.put(FIELD_OPTIONAL_IMAGE_URL, courseTemplate.getOptionalImageURL());
|
||||
result.put(FIELD_DEFAULT_NUMBER_OF_LAPS, courseTemplate.getDefaultNumberOfLaps());
|
||||
final JSONArray tags = new JSONArray();
|
||||
courseTemplate.getTags().forEach(tags::add);
|
||||
if (courseTemplate.getTags() != null) {
|
||||
courseTemplate.getTags().forEach(tags::add);
|
||||
}
|
||||
result.put(FIELD_TAGS, tags);
|
||||
final JSONArray allMarkRoles = new JSONArray();
|
||||
courseTemplate.getMarkRoles().forEach(markRole -> {
|
||||
|
||||
+4
-2
@@ -20,8 +20,10 @@ public class FreestyleMarkPropertiesJsonSerializer implements JsonSerializer<Fre
|
||||
public JSONObject serialize(FreestyleMarkProperties commonMarkProperties) {
|
||||
JSONObject result = commonMarkPropertiesJsonSerializer.serialize(commonMarkProperties);
|
||||
JSONArray jsonTags = new JSONArray();
|
||||
for (String tag : commonMarkProperties.getTags()) {
|
||||
jsonTags.add(tag);
|
||||
if (commonMarkProperties.getTags() != null) {
|
||||
for (String tag : commonMarkProperties.getTags()) {
|
||||
jsonTags.add(tag);
|
||||
}
|
||||
}
|
||||
result.put(FIELD_TAGS, jsonTags);
|
||||
return result;
|
||||
|
||||
-3
@@ -1,6 +1,5 @@
|
||||
package com.sap.sailing.server.gateway.serialization.impl;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.coursetemplate.MarkProperties;
|
||||
@@ -22,8 +21,6 @@ public class MarkPropertiesJsonSerializer implements JsonSerializer<MarkProperti
|
||||
public JSONObject serialize(MarkProperties markProperties) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put(FIELD_ID, markProperties.getId().toString());
|
||||
final JSONArray tags = new JSONArray();
|
||||
markProperties.getTags().forEach(tags::add);
|
||||
result.putAll(commonMarkPropertiesWithTagsJsonSerializer.serialize(markProperties));
|
||||
result.put(FIELD_POSITIONING, markProperties.getPositioningInformation() == null ? null :
|
||||
positioningJsonSerializer.serialize(markProperties.getPositioningInformation()));
|
||||
|
||||
Reference in New Issue
Block a user