-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix AnalyzeAction response serialization #44284
Conversation
Currently we loose information about whether a token list in an AnalyzeAction response is null or an empty list, because we write a 0 value to the stream in both cases and deserialize to a null value on the receiving side. This change fixes this so we write an additional flag indicating whether the value is null or not, followed by the size of the list and its content. Closes elastic#44078
Pinging @elastic/es-search |
tokens = new ArrayList<>(size); | ||
for (int i = 0; i < size; i++) { | ||
tokens.add(new AnalyzeToken(in)); | ||
if (in.getVersion().onOrAfter(Version.V_8_0_0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to backport this to 7_3_0 at least if possible. Not sure of its feasible to 7_2_1, might complicate the whole backport story a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, a couple of nits but no need for another go round
server/src/test/java/org/elasticsearch/indices/analyze/AnalyzeActionIT.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/test/java/org/elasticsearch/client/indices/AnalyzeResponseTests.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/test/java/org/elasticsearch/client/indices/AnalyzeResponseTests.java
Outdated
Show resolved
Hide resolved
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class AnalyzeResponseTests extends ESTestCase { | ||
public class AnalyzeResponseTests extends AbstractWireSerializingTestCase<AnalyzeAction.Response> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Currently we loose information about whether a token list in an AnalyzeAction response is null or an empty list, because we write a 0 value to the stream in both cases and deserialize to a null value on the receiving side. This change fixes this so we write an additional flag indicating whether the value is null or not, followed by the size of the list and its content. Closes #44078
Currently we loose information about whether a token list in an AnalyzeAction response is null or an empty list, because we write a 0 value to the stream in both cases and deserialize to a null value on the receiving side. This change fixes this so we write an additional flag indicating whether the value is null or not, followed by the size of the list and its content. Closes #44078
Change AnalyzeAction response serialization version condition after #44284 has been backported
Currently we loose information about whether a token list in an AnalyzeAction response is null or an empty list, because we write a 0 value to the stream in both cases and deserialize to a null value on the receiving side. This was fixed in elastic#44284 by a change in the serialization protocol starting in 7.3. However this PR fixes the symptoms without changing the wire protocol which we cannot to easily on 6.8 because we already released incompatible versions in the 7.x line. This change adds special handling on xcontent output and if getToken() is callled on either AnalyzeResponse or DetailedAnalyzeResponse to always return empty lists instead of null values. Relates to elastic#44078
Currently we loose information about whether a token list in an AnalyzeAction response is null or an empty list, because we write a 0 value to the stream in both cases and deserialize to a null value on the receiving side. This was fixed in #44284 by a change in the serialization protocol starting in 7.3. However this PR fixes the symptoms without changing the wire protocol which we cannot to easily on 6.8 because we already released incompatible versions in the 7.x line. This change adds special handling on xcontent output and if getToken() is callled on either AnalyzeResponse or DetailedAnalyzeResponse to always return empty lists instead of null values. Relates to #44078
Currently we loose information about whether a token list in an AnalyzeAction
response is null or an empty list, because we write a 0 value to the stream in
both cases and deserialize to a null value on the receiving side. This change
fixes this so we write an additional flag indicating whether the value is null
or not, followed by the size of the list and its content.
Closes #44078