Skip to content

Commit

Permalink
ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingExce…
Browse files Browse the repository at this point in the history
…ption (2993) (#2997)

* Load the Jackson-based implementation dynamically to avoid ClassNotFound

* Complete the chanegs to the RELEASE-NOTES.MD

* Extend list of exceptions

* Tweaks to the presentation of the ne JSON guide

* Behavior is the preferred spelling in American English. Behaviour is preferred everywhere else. Extending list of exceptions to include (most) cases of the usage.

* Use the release version for the badge

* Lazy initialize the JsonParser instance to avoid hitting NoClassDefFound error

* Shame (ding) shame (ding) shame (ding)

* Yet more words to add to the wordlist
  • Loading branch information
tishun authored Oct 11, 2024
1 parent 542b6a5 commit d255b1a
Show file tree
Hide file tree
Showing 35 changed files with 206 additions and 136 deletions.
21 changes: 20 additions & 1 deletion .github/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,23 @@ uring
whitespace
xml
RedisJSON
MkDocs
MkDocs
ClientOptions
TimeoutOptions
timeoutOptions
ClusterCommand
completeExceptionally
spublish
BitSet
RedisClusterNode's
allOf
reentrant
jacoco
apache
failsafe
hdrhistogram
bom
ubuntu
behaviour
databind
jackson
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
[![Integration](https://github.com/redis/lettuce/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/redis/lettuce/actions/workflows/integration.yml)
[![codecov](https://codecov.io/gh/redis/lettuce/branch/main/graph/badge.svg?token=pAstxAAjYo)](https://codecov.io/gh/redis/lettuce)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.lettuce/lettuce-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.lettuce/lettuce-core)
[![Maven Central](https://img.shields.io/maven-central/v/io.lettuce/lettuce-core?versionSuffix=RELEASE&logo=redis
)](https://maven-badges.herokuapp.com/maven-central/io.lettuce/lettuce-core)
[![Javadocs](https://www.javadoc.io/badge/io.lettuce/lettuce-core.svg)](https://www.javadoc.io/doc/io.lettuce/lettuce-core)

[![Discord](https://img.shields.io/discord/697882427875393627.svg?style=social&logo=discord)](https://discord.gg/redis)
Expand Down Expand Up @@ -35,17 +36,15 @@ See the [reference documentation](https://redis.github.io/lettuce/) and [API Ref

## How do I Redis?

[Learn for free at Redis University](https://university.redis.com/)
[Learn for free at Redis University](https://university.redis.io/academy)

[Build faster with the Redis Launchpad](https://launchpad.redis.com/)
[Try the Redis Cloud](https://redis.io/try-free/)

[Try the Redis Cloud](https://redis.com/try-free/)
[Dive in developer tutorials](https://redis.io/learn/)

[Dive in developer tutorials](https://developer.redis.com/)
[Join the Redis community](https://redis.io/community/)

[Join the Redis community](https://redis.com/community/)

[Work at Redis](https://redis.com/company/careers/jobs/)
[Work at Redis](https://redis.io/careers/jobs/)

Documentation
---------------
Expand Down
59 changes: 28 additions & 31 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Lettuce 6.4.0 RELEASE NOTES
Lettuce 6.5.0 RELEASE NOTES
==============================

The Redis team is delighted to announce general availability of Lettuce 6.4.
The Redis team is delighted to announce the general availability of Lettuce 6.5.

This Lettuce driver is now going to be shipped under the MIT licensing scheme. The `CLIENT SETINFO`
is now working in a fire-and-forget mode to allow better compatibility with Redis servers that do
not support this command.
Great news, everyone! Lettuce 6.5.0 comes with RedisJSON support enabled.
For more on that, please consult with the [RedisJSON documentation](https://redis.io/docs/latest/develop/data-types/json/) and the [Lettuce guide on RedisJSON](https://redis.github.io/lettuce/user-guide/redis-json/).

Lettuce 6 supports Redis 2.6+ up to Redis 7.x. In terms of Java runtime, Lettuce requires
at least Java 8 and works with Java 21.
Expand All @@ -16,45 +15,43 @@ If you need any support, meet Lettuce at

* GitHub Discussions: https://github.com/lettuce-io/lettuce-core/discussions
* Stack Overflow (Questions): https://stackoverflow.com/questions/tagged/lettuce
* Join the chat at https://discord.gg/redis for general discussion
* GitHub Issues (Bug reports, feature
requests): https://github.com/lettuce-io/lettuce-core/issues
* Documentation: https://lettuce.io/core/6.4.0.RELEASE/reference/
* Javadoc: https://lettuce.io/core/6.4.0.RELEASE/api/
* Join the chat at https://discord.gg/redis and look for the "Help:Tools Lettuce" channel
* GitHub Issues (Bug reports, feature requests): https://github.com/lettuce-io/lettuce-core/issues
* Documentation: https://lettuce.io/core/6.5.0.RELEASE/reference/
* Javadoc: https://lettuce.io/core/6.5.0.RELEASE/api/

Commands
--------

* Add `PUBSUB` shard channel commands `SHARDCHANNELS` #2756, `SHARDNUMSUB` #2776
* Add `PUBSUB` shard channel commands `SPUBLISH` #2757, `SSUBSCRIBE` #2758 and `SUNSUBSCRIBE` #2758
* Add support for `CLIENT KILL [MAXAGE]` #2782
* Hash field expiration commands `HEXPIRE`, `HEXPIREAT`, `HEXPIRETIME` and `HPERSIST` #2836
* Hash field expiration commands `HPEXPIRE`, `HPEXPIREAT`, `HPEXPIRETIME`, `HTTL` and `HPTTL` #2857
* Add `CLUSTER MYSHARDID` in #2920 and `CLUSTER LINKS` in #2986
* Add `CLIENT TRACKINGINFO` in #2862

Enhancements
------------

* Add support for `HSCAN NOVALUES` #2763
* Send the `CLIENT SETINFO` command in a fire-and-forget way #2082
* Change the license to more permissive MIT #2173
* Add a evalReadOnly overload that accepts the script as a String #2868
* `XREAD` support for reading last message from stream #2863
* Mark dnsResolver(DnsResolver) as deprecated #2855
* Remove connection-related methods from commands API #2027
* Move connection-related commands from BaseRedisCommands to RedisConnectionCommands #2031
* Default ClientOptions.timeoutOptions to TimeoutOptions.enabled() (#2927)
* Update completeExceptionally on ClusterCommand using super (#2980)

Fixes
-----
* fix(2971): spublish typo fix (#2972)
* Initialize slots with empty BitSet in RedisClusterNode's constructors (#2341)
* Add defensive copy for Futures allOf() method (#2943)
* fix:deadlock when reentrant exclusive lock (#2961)

* None

Other
-----

* Bump `org.apache.commons:commons-pool2` from 2.11.1 to 2.12.0 #2877
* Bump `org.openjdk.jmh:jmh-generator-annprocess` from 1.21 to 1.37 #2876
* Bump `org.apache.maven.plugins:maven-jar-plugin` from 3.3.0 to 3.4.1 #2875
* Bump `org.codehaus.mojo:flatten-maven-plugin from` 1.5.0 to 1.6.0 #2874
* Bump `org.apache.maven.plugins:maven-javadoc-plugin` from 3.6.3 to 3.7.0 #2873
* Applying code formatter each time we run a Maven build #2841
* Bump `setup-java` to v4 #2807
* Add badges to the README.md file (#2939)
* Convert wiki to markdown docs (#2944)
* Bump org.jacoco:jacoco-maven-plugin from 0.8.9 to 0.8.12 (#2921)
* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.1 (#2922)
* Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.5 to 3.3.1 (#2958)
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0 (#2957)
* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.1 to 3.4.0 (#2968)
* Bump org.hdrhistogram:HdrHistogram from 2.1.12 to 2.2.2 (#2966)
* Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.1 to 3.13.0 (#2978)
* Bump org.apache.logging.log4j:log4j-bom from 2.17.2 to 2.24.0 (#2988)
* Bump io.netty:netty-bom from 4.1.107.Final to 4.1.113.Final (#2990)
* Suspected change in ubuntu causing CI failures (#2949)
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Add these lines to file pom.xml:
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.4.0.RELEASE</version>
<version>6.5.0.RELEASE</version>
</dependency>
```

Expand All @@ -23,7 +23,7 @@ Add these lines to file ivy.xml:
``` xml
<ivy-module>
<dependencies>
<dependency org="io.lettuce" name="lettuce-core" rev="6.4.0.RELEASE"/>
<dependency org="io.lettuce" name="lettuce-core" rev="6.5.0.RELEASE"/>
</dependencies>
</ivy-module>
```
Expand All @@ -34,7 +34,7 @@ Add these lines to file build.gradle:

``` groovy
dependencies {
implementation 'io.lettuce:lettuce-core:6.4.0.RELEASE'
implementation 'io.lettuce:lettuce-core:6.5.0.RELEASE'
}
```

Expand Down
34 changes: 23 additions & 11 deletions docs/user-guide/redis-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ The driver generally allows three distinct ways of working with the RedisJSON mo
* (Advanced mode) - custom JSON parsing using a user-provided JSON parser
* (Power-user mode) - unprocessed JSON documents that have not gone through any process of deserialization or serialization

> [!IMPORTANT]\
> In all the above modes, the driver would refrain from processing the JSON document in the main event loop and instead
delegate this to the user thread. This behaviour is consistent when both receiving and sending JSON documents - when
receiving the parsing is done lazily whenever a method is called that requires the JSON to be parsed; when sending the
JSON is serialized immediately after it is passed to any of the commands, but before dispatching the command to the
event loop.

!!! INFO
In all the above modes, the driver would refrain from processing the JSON document in the main event loop and instead
delegate this to the user thread. This behaviour is consistent when both receiving and sending JSON documents - when
receiving the parsing is done lazily whenever a method is called that requires the JSON to be parsed; when sending the
JSON is serialized immediately after it is passed to any of the commands, but before dispatching the command to the
event loop.

!!! WARNING
Unless you are using a custom JSON parser you would need to add a dependency to the
[jackson-databind](https://github.com/FasterXML/jackson-databind) library in your project. This is because the
default JSON parser uses Jackson to parse JSON documents to and from string representations.

## Default mode
Best for:

* Most typical use-cases where the JSON document is parsed and processed

### Example usage:
### Example usage

```java
RedisURI redisURI = RedisURI.Builder.redis("acme.com").build();
Expand Down Expand Up @@ -52,25 +57,29 @@ try (StatefulRedisConnection<ByteBuffer, ByteBuffer> connect = redisClient.conne

## Advanced mode
Best for:

* Applications that want to handle parsing manually - either by using another library or by implementing their own parser

### Example usage:
### Example usage

```java
RedisURI redisURI = RedisURI.Builder.redis("127.0.0.1").withPort(16379).build();

try (RedisClient client = RedisClient.create(redisURI)) {
client.setOptions(ClientOptions.builder().jsonParser(new CustomParser()).build());
client.setOptions(ClientOptions.builder().jsonParser(Mono.just(new CustomParser())).build());
StatefulRedisConnection<String, String> connection = client.connect(StringCodec.UTF8);
RedisCommands<String, String> redis = connection.sync();
}
```



## Power-user mode
Best for:

* Applications that do little to no processing on the Java layer

### Example usage:
### Example usage

```java
JsonPath myPath = JsonPath.of("$..mountain_bikes");
Expand All @@ -85,3 +94,6 @@ try (RedisClient client = RedisClient.create(redisURI)) {
String result = stage.toCompletableFuture().get().get();
}
```
!!! NOTE
The power-user mode is not exclusive to using a custom parser (Advanced mode), as long as the custom parser follows
the API contract of the `JsonParser`, `JsonValue`, `JsonArray` and `JsonObject` interfaces.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ nav:
- Kotlin API: user-guide/kotlin-api.md
- Publish/Subscribe: user-guide/pubsub.md
- Transactions/Multi: user-guide/transactions-multi.md
- Redis JSON: user-guide/redis-json.md
- Redis programmability:
- LUA Scripting: user-guide/lua-scripting.md
- Redis Functions: user-guide/redis-functions.md
Expand Down
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.4.0.BUILD-SNAPSHOT</version>
<version>6.5.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lettuce</name>
Expand Down Expand Up @@ -546,6 +546,21 @@
<scope>test</scope>
</dependency>

<!-- JMH -->

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.ProtocolKeyword;
import io.lettuce.core.protocol.RedisCommand;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -87,15 +88,15 @@ public abstract class AbstractRedisAsyncCommands<K, V> implements RedisAclAsyncC

private final RedisJsonCommandBuilder<K, V> jsonCommandBuilder;

private final JsonParser parser;
private final Mono<JsonParser> parser;

/**
* Initialize a new instance.
*
* @param connection the connection to operate on
* @param codec the codec for command encoding
*/
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, JsonParser parser) {
public AbstractRedisAsyncCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
this.parser = parser;
this.connection = connection;
this.commandBuilder = new RedisCommandBuilder<>(codec);
Expand Down Expand Up @@ -3380,7 +3381,7 @@ public RedisFuture<List<Map<String, Object>>> clusterLinks() {

@Override
public JsonParser getJsonParser() {
return this.parser;
return this.parser.block();
}

private byte[] encodeFunction(String functionCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public abstract class AbstractRedisReactiveCommands<K, V>

private final RedisJsonCommandBuilder<K, V> jsonCommandBuilder;

private final JsonParser parser;
private final Mono<JsonParser> parser;

private final ClientResources clientResources;

Expand All @@ -112,7 +112,7 @@ public abstract class AbstractRedisReactiveCommands<K, V>
* @param connection the connection to operate on.
* @param codec the codec for command encoding.
*/
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, JsonParser parser) {
public AbstractRedisReactiveCommands(StatefulConnection<K, V> connection, RedisCodec<K, V> codec, Mono<JsonParser> parser) {
this.connection = connection;
this.parser = parser;
this.commandBuilder = new RedisCommandBuilder<>(codec);
Expand All @@ -139,7 +139,7 @@ private EventExecutorGroup getScheduler() {

@Override
public JsonParser getJsonParser() {
return parser;
return parser.block();
}

@Override
Expand Down
Loading

0 comments on commit d255b1a

Please sign in to comment.