-
Notifications
You must be signed in to change notification settings - Fork 243
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
Jackson version conflict #902
Comments
Hello, the RestClientTransport does not need There's a third implementation which is SimpleJsonpMapper, which does not require any external dependencies because it handles serialization exclusively for Java API client, meaning it will fail if any custom class is used. If data is inserted using formats such as JsonData or BinaryData, there will be no serialization/deserialization involved and it's possible to actually use the client with no external mapper. Here is a full example where the only dependency used is the java client: SimpleJsonpMapper jsonpMapper = new SimpleJsonpMapper();
ElasticsearchTransport transport = new RestClientTransport(restClient, jsonpMapper);
ElasticsearchClient esClient = new ElasticsearchClient(transport);
// indexing a simple document as a json string
esClient.index(i -> i.index("my-binary-test").document(JsonData.fromJson("{\"doc\": \"1\"}")));
SearchResponse<BinaryData> binRes = esClient.search(s -> s.index("my-binary-test"), BinaryData.class);
// just getting the first item of the list for simplicity
BinaryData bin = binRes.hits().hits().get(0).source();
// text will be
//{
// "doc" : "1"
//}
String text = new String(bin.asInputStream().readAllBytes(), StandardCharsets.UTF_8); |
@sysmat I renamed the issue from "RestClientTransport bad design" to "Jackson version conflict" because this is really what it is. If every library that uses JSON had a bad design because they depend on Jackson, then a large part of the Java ecosystem would have a bad design! That being said, |
@swallez thx for replay. |
@sysmat as outlined by @l-trotta the JSON parser is pluggable and Jackson is not a requirement. and you can have the raw data as a string. This can be a workaround to keep using your old version of Jackson, but comes with a performance price as the Java client will serialize the JSON to a string, that I guess you will parse again. |
Description
java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonParser.isExpectedNumberIntToken
The text was updated successfully, but these errors were encountered: