Skip to content

Commit 3637e62

Browse files
committed
Fixed NPE in case of media images
1 parent bdb9630 commit 3637e62

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/de/votesapp/client/GroupMessage.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package de.votesapp.client;
22

33
import javax.annotation.Nullable;
4+
import javax.validation.constraints.NotNull;
45

56
import lombok.AllArgsConstructor;
67
import lombok.Data;
78
import lombok.NoArgsConstructor;
89

10+
import org.apache.commons.lang3.StringUtils;
11+
912
import com.fasterxml.jackson.annotation.JsonCreator;
1013
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1114
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -22,7 +25,7 @@
2225
@NoArgsConstructor
2326
public class GroupMessage {
2427

25-
public static GroupMessage of(final String groupId, final String text) {
28+
public static GroupMessage of(final String groupId, @NotNull final String text) {
2629
return new GroupMessage(null, escapeDot(groupId), null, null, text);
2730
}
2831

@@ -33,9 +36,9 @@ public static GroupMessage of( //
3336
@JsonProperty("_from") final String groupId, //
3437
@JsonProperty("participant") final String senderPhone, //
3538
@JsonProperty(value = "notify", required = false) final String senderName, //
36-
@JsonProperty("body") final String text) {
39+
@JsonProperty(value = "body", required = false) final String text) {
3740

38-
return new GroupMessage(escapeDot(id), escapeDot(groupId), escapeDot(senderPhone), senderName, text);
41+
return new GroupMessage(escapeDot(id), escapeDot(groupId), escapeDot(senderPhone), senderName, text == null ? "" : text);
3942
}
4043

4144
private static String escapeDot(final String txt) {
@@ -50,7 +53,7 @@ private static String escapeDot(final String txt) {
5053
// return mappingMongoConverter;
5154
// }
5255
// But then we need to have one. Now it's autoconfigured
53-
return txt.replaceAll("\\.", "_");
56+
return StringUtils.replace(txt, ".", "_");
5457
}
5558

5659
/**

0 commit comments

Comments
 (0)