|
10 | 10 |
|
11 | 11 | import org.apache.logging.log4j.LogManager; |
12 | 12 | import org.apache.logging.log4j.Logger; |
13 | | -import org.opensearch.common.Nullable; |
14 | 13 | import org.opensearch.common.io.stream.StreamInput; |
15 | 14 | import org.opensearch.common.io.stream.StreamOutput; |
16 | 15 | import org.opensearch.transport.TransportRequest; |
|
27 | 26 | public class ExtensionRequest extends TransportRequest { |
28 | 27 | private static final Logger logger = LogManager.getLogger(ExtensionRequest.class); |
29 | 28 | private final ExtensionsManager.RequestType requestType; |
30 | | - private final String uniqueId; |
| 29 | + private final Optional<String> uniqueId; |
| 30 | + private String id; |
31 | 31 |
|
32 | 32 | public ExtensionRequest(ExtensionsManager.RequestType requestType) { |
33 | 33 | this(requestType, null); |
34 | 34 | } |
35 | 35 |
|
36 | | - public ExtensionRequest(ExtensionsManager.RequestType requestType, String uniqueId) { |
| 36 | + public ExtensionRequest(ExtensionsManager.RequestType requestType, Optional<String> uniqueId) { |
37 | 37 | this.requestType = requestType; |
38 | 38 | this.uniqueId = uniqueId; |
39 | 39 | } |
40 | 40 |
|
41 | 41 | public ExtensionRequest(StreamInput in) throws IOException { |
42 | 42 | this.requestType = in.readEnum(ExtensionsManager.RequestType.class); |
43 | | - this.uniqueId = in.readString(); |
| 43 | + this.uniqueId = id == null ? Optional.empty() : Optional.of(id); |
| 44 | + id = in.readOptionalString(); |
44 | 45 | } |
45 | 46 |
|
46 | 47 | @Override |
47 | 48 | public void writeTo(StreamOutput out) throws IOException { |
48 | 49 | super.writeTo(out); |
49 | 50 | out.writeEnum(requestType); |
50 | | - out.writeString(uniqueId); |
| 51 | + out.writeOptionalString(id); |
51 | 52 | } |
52 | 53 |
|
53 | 54 | public ExtensionsManager.RequestType getRequestType() { |
54 | 55 | return this.requestType; |
55 | 56 | } |
56 | 57 |
|
57 | 58 | public Optional<String> getUniqueId() { |
58 | | - return uniqueId == null ? Optional.empty() : Optional.of(uniqueId); |
| 59 | + return uniqueId == null ? Optional.empty() : uniqueId; |
59 | 60 | } |
60 | 61 |
|
61 | 62 | public String toString() { |
|
0 commit comments