Skip to content

Commit

Permalink
Remove custom serialisation support
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <[email protected]>
  • Loading branch information
andy-k-improving committed Nov 27, 2024
1 parent 384764f commit 11d7876
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
@AllArgsConstructor
public class IpEnrichmentRequest extends ActionRequest {

private static final String VERSION = "2.18.0.0";

private String ipString;

private String datasourceName;
Expand Down Expand Up @@ -89,12 +87,7 @@ public static IpEnrichmentRequest fromActionRequest(ActionRequest actionRequest)
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos)) {
actionRequest.writeTo(osso);
try (StreamInput input = new InputStreamStreamInput(new ByteArrayInputStream(baos.toByteArray()))) {
String objectVersion = input.readString();
if (VERSION.equals(objectVersion)) {
return new IpEnrichmentRequest(input);
} else {
throw new IllegalArgumentException("Fail to serialise IpEnrichmentRequest due to version mismatch");
}
return new IpEnrichmentRequest(input);
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to parse ActionRequest into IpEnrichmentRequest", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
@EqualsAndHashCode(callSuper = false)
public class IpEnrichmentResponse extends ActionResponse {

private static final String VERSION = "2.18.0.0";

private Map<String, Object> geoLocationData;

/**
Expand Down Expand Up @@ -74,15 +72,8 @@ public static IpEnrichmentResponse fromActionResponse(ActionResponse actionRespo
// Or else convert it
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos)) {
actionResponse.writeTo(osso);


try (StreamInput input = new InputStreamStreamInput(new ByteArrayInputStream(baos.toByteArray()))) {
String objectVersion = input.readString();
if (VERSION.equals(objectVersion)) {
return new IpEnrichmentResponse(input);
} else {
throw new IllegalArgumentException("Fail to serialise IpEnrichmentResponse due to version mismatch");
}
return new IpEnrichmentResponse(input);
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to parse ActionResponse into IpEnrichmentResponse", e);
Expand Down

0 comments on commit 11d7876

Please sign in to comment.