fix: handle checked JsonProcessingException in serializePayload

writeValueAsString throws checked JsonProcessingException which was
unhandled, causing a compile error. Wrapped in try/catch, rethrowing
as IllegalStateException.
This commit is contained in:
AlexisLeDain
2026-04-09 17:28:56 +02:00
parent e928ceacee
commit 56bbbb3dbe
4 changed files with 20 additions and 8 deletions

View File

@@ -185,8 +185,11 @@ public class EventService {
}
private String serializePayload(Object payload) {
// JSONシリアライゼーション
return objectMapper.writeValueAsString(payload);
try {
return objectMapper.writeValueAsString(payload);
} catch (JsonProcessingException e) {
throw new IllegalStateException("Failed to serialize event payload", e);
}
}
}
```

View File

@@ -185,8 +185,11 @@ public class EventService {
}
private String serializePayload(Object payload) {
// JSON serileştirme
return objectMapper.writeValueAsString(payload);
try {
return objectMapper.writeValueAsString(payload);
} catch (JsonProcessingException e) {
throw new IllegalStateException("Failed to serialize event payload", e);
}
}
}
```

View File

@@ -185,8 +185,11 @@ public class EventService {
}
private String serializePayload(Object payload) {
// JSON序列化
return objectMapper.writeValueAsString(payload);
try {
return objectMapper.writeValueAsString(payload);
} catch (JsonProcessingException e) {
throw new IllegalStateException("Failed to serialize event payload", e);
}
}
}
```

View File

@@ -187,8 +187,11 @@ public class EventService {
}
private String serializePayload(Object payload) {
// JSON serialization
return objectMapper.writeValueAsString(payload);
try {
return objectMapper.writeValueAsString(payload);
} catch (JsonProcessingException e) {
throw new IllegalStateException("Failed to serialize event payload", e);
}
}
}
```