|
1 | 1 | package io.elastic.jdbc.actions;
|
2 | 2 |
|
3 | 3 | import io.elastic.api.ExecutionParameters;
|
| 4 | +import io.elastic.api.JSON; |
4 | 5 | import io.elastic.api.Message;
|
5 | 6 | import io.elastic.api.Module;
|
6 | 7 | import io.elastic.jdbc.Engines;
|
|
12 | 13 | import java.util.Map;
|
13 | 14 | import javax.json.Json;
|
14 | 15 | import javax.json.JsonObject;
|
| 16 | +import javax.json.JsonObjectBuilder; |
15 | 17 | import javax.json.JsonString;
|
16 | 18 | import javax.json.JsonValue;
|
17 | 19 | import org.slf4j.Logger;
|
@@ -91,10 +93,11 @@ public void execute(ExecutionParameters parameters) {
|
91 | 93 | parameters.getEventEmitter().emitData(new Message.Builder().body(row).build());
|
92 | 94 | }
|
93 | 95 | if (row.size() == 0 && nullableResult) {
|
94 |
| - row.put("empty dataset", null); |
| 96 | + JsonObjectBuilder emptyResBuilder = Json.createObjectBuilder(); |
| 97 | + emptyResBuilder.add("empty dataset", JsonValue.NULL); |
95 | 98 | LOGGER.info("Emitting data");
|
96 |
| - LOGGER.info(row.toString()); |
97 |
| - parameters.getEventEmitter().emitData(new Message.Builder().body(row).build()); |
| 99 | + LOGGER.info(JSON.stringify(emptyResBuilder.build())); |
| 100 | + parameters.getEventEmitter().emitData(new Message.Builder().body(emptyResBuilder.build()).build()); |
98 | 101 | } else if (row.size() == 0 && !nullableResult) {
|
99 | 102 | LOGGER.info("Empty response. Error message will be returned");
|
100 | 103 | throw new RuntimeException("Empty response");
|
|
0 commit comments