Skip to content

Commit

Permalink
Fix cannot publish when subscribed with RESP3 #2594
Browse files Browse the repository at this point in the history
Original pull request: #2778
  • Loading branch information
dengliming authored and mp911de committed Mar 13, 2024
1 parent c4c6994 commit a470433
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/io/lettuce/core/protocol/DefaultEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ protected String logPrefix() {
return logPrefix = buffer;
}

protected ProtocolVersion getProtocolVersion() {
return clientOptions.getProtocolVersion();
}

@Override
public String getId() {
return cachedEndpointId;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/lettuce/core/pubsub/PubSubEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.lettuce.core.RedisException;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.DefaultEndpoint;
import io.lettuce.core.protocol.ProtocolVersion;
import io.lettuce.core.protocol.RedisCommand;
import io.lettuce.core.resource.ClientResources;
import io.netty.channel.Channel;
Expand Down Expand Up @@ -193,8 +194,8 @@ protected boolean containsViolatingCommands(Collection<? extends RedisCommand<?,
return false;
}

private static boolean isAllowed(RedisCommand<?, ?, ?> command) {
return ALLOWED_COMMANDS_SUBSCRIBED.contains(command.getType().name());
private boolean isAllowed(RedisCommand<?, ?, ?> command) {
return getProtocolVersion() == ProtocolVersion.RESP3 || ALLOWED_COMMANDS_SUBSCRIBED.contains(command.getType().name());
}

public boolean isSubscribed() {
Expand Down

0 comments on commit a470433

Please sign in to comment.