From 58b1ce165cb052401d3d131abaf7ebe60fd688f1 Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Mon, 11 Mar 2024 10:55:12 +0100 Subject: [PATCH] Consider context in raw serialization With this commit we use `writeRawValue` instead of `writeRaw` when serializing raw strings as XContent. The latter method does not consider context (e.g. is the value being written as part of an array and requires a comma separator?) whereas the former does. This ensures that pre-rendered double values as we use them in the flamegraph response are rendered correctly as XContent. Closes #106103 --- .../xcontent/provider/json/JsonXContentGenerator.java | 2 +- .../resources/rest-api-spec/test/profiling/10_basic.yml | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentGenerator.java b/libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentGenerator.java index f22176930da64..09cbdf2d571cd 100644 --- a/libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentGenerator.java +++ b/libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentGenerator.java @@ -500,7 +500,7 @@ public void writeRawValue(InputStream stream, XContentType xContentType) throws public void writeRawValue(String value) throws IOException { try { if (supportsRawWrites()) { - generator.writeRaw(value); + generator.writeRawValue(value); } else { // fallback to a regular string for formats that don't allow writing the value as is generator.writeString(value); diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml index 1e0c260a70e4f..367655ba89388 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml @@ -166,9 +166,6 @@ teardown: --- "Test flamegraph from profiling-events": - - skip: - reason: "https://github.com/elastic/elasticsearch/issues/106103" - version: "all" - do: profiling.flamegraph: body: > @@ -195,9 +192,6 @@ teardown: --- "Test flamegraph from test-events": - - skip: - reason: "https://github.com/elastic/elasticsearch/issues/106103" - version: "all" - do: profiling.flamegraph: body: >