Remove ToXContent interface from ChunkedToXContent#90409
Remove ToXContent interface from ChunkedToXContent#90409original-brownbear merged 6 commits intoelastic:mainfrom original-brownbear:remove-to-xcontent-from-chunked
Conversation
Making sure that none of the chunked implementations also implement `toXContent`. Added some utilities for working with chunked xcontent that mirror xcontent utilities to keep the changeset as quiet as possible. No big production code changes here, this mostly affects test code paths.
|
Pinging @elastic/es-distributed (Team:Distributed) |
henningandersen
left a comment
There was a problem hiding this comment.
Thanks for doing this Armin. I hope we can maybe have the most mechanic part of the change done in a separate PR?
| /** | ||
| * Return a {@link String} that is the json representation of the provided {@link ChunkedToXContent}. | ||
| */ | ||
| public static String toString(ChunkedToXContent chunkedToXContent) { |
There was a problem hiding this comment.
Can we avoid this and the following method? Seems like bugs if we invoke them, given that they produce Strings that could be too large to handle?
There was a problem hiding this comment.
I agree, this sucks. But it's not a new issue and IMO this change at least makes the problem areas clear. The toString output is unchanged from what it was. Maybe a good move would be to just deprecate these outright and then fix them in a follow up by changing the toString output. This isn't entirely trivial since we'd have to come up with a new format for each implementation on a case by case basis so I'd rather not have those discussions here I think :)
There was a problem hiding this comment.
That sounds good to me, i.e., deprecate them here and then fix in follow-up(s).
There was a problem hiding this comment.
done added deprecation :)
|
|
||
| import java.io.IOException; | ||
|
|
||
| public abstract class AbstractXContentSerializingTestCase<T extends ToXContent & Writeable> extends AbstractSerializationTestCase<T> { |
There was a problem hiding this comment.
Would it be possible to split out the part of the change that extracts this new class and uses it everywhere? That would make this PR easier to review. I.e., we make that refactor first to use this class everywhere and then we can more easily review this PR.
There was a problem hiding this comment.
Sure thing, it's most of this change I guess :) -> #90707
henningandersen
left a comment
There was a problem hiding this comment.
Looks good, just a couple things I'd like to see changed.
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| public class BroadCastXContentResponse extends BroadcastResponse implements ToXContentObject { |
There was a problem hiding this comment.
I wonder if it was better to rename BroadcastResponse to AbstractBroadcastResponse and thus let this class be called BroadcastResponse, i.e., the normal non chunked case has a name with no extra naming?
Also, notice that it should be lower-case c in Broadcast.
There was a problem hiding this comment.
Good point. I went with BaseBroadcastResponse though since we do use the parent class explicitly in a couple spots at the moment and abstract felt wrong. Makes for less noise overall, though the diff looks less nice now for the class itself.
| /** | ||
| * Return a {@link String} that is the json representation of the provided {@link ChunkedToXContent}. | ||
| */ | ||
| public static String toString(ChunkedToXContent chunkedToXContent) { |
There was a problem hiding this comment.
That sounds good to me, i.e., deprecate them here and then fix in follow-up(s).
| private final DefaultShardOperationFailedException[] shardFailures; | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| protected static <T extends BaseBroadcastResponse> void declareBroadcastFields(ConstructingObjectParser<T, Void> PARSER) { |
There was a problem hiding this comment.
This one nags me, but clearly not caused by your PR.
|
Thanks Henning! |
* main: (150 commits) Remove ToXContent interface from ChunkedToXContent (elastic#90409) Remove extra SearchService constructor (elastic#90733) Update min version for the diagnosis yaml test (elastic#90731) Use the AggTestConfig object in testCase (elastic#90699) [DOCS] Add links to clear trained model deployment cache API (elastic#90727) Assert wildcards are not expanded as specified by request options (elastic#90641) [TEST] Fix exit snapshot restore exit condition (elastic#90696) [TEST] Change to atomic file contents save (elastic#90695) Update forbiddenapis to 3.4 (elastic#90624) [Tests] Don't use concurrent search in scripted field type tests (elastic#90712) [ML] Move scaling is possible check for starting trained model (elastic#90706) Add new base test case for chunked xcontent types (elastic#90707) Fix testRedNoBlockedIndicesAndRedAllRoleNodes (elastic#90671) Fix nullpointer in docs test setup (elastic#90660) Don't produce build logs artifact when in a composite build Fixing a race condition in EnrichCoordinatorProxyAction that can leave an item stuck in its queue (elastic#90688) docs: update fleet/agent pipeline docs (elastic#90659) [HealthAPI] Use plural consistently in resource types (elastic#90682) [Testing] Enable bwc and fix sorting for 500_date_range (elastic#90681) Add profiling and documentation for dfs phase (elastic#90536) ... # Conflicts: # x-pack/plugin/mapper-aggregate-metric/src/test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapperTests.java
Making sure that none of the chunked implementations also implement
toXContent. Added some utilities for working with chunked xcontent that mirror xcontent utilities to keep the changeset as quiet as possible. No big production code changes here except for adding another layer of abstraction to broadcast responses to be able to differentiate between chunked and not chunked.Otherwise, this mostly affects test code paths.