Skip to content

Commit

Permalink
Merge branch 'main' into DOC-4756-sorted-set-async-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-stark-redis authored Feb 14, 2025
2 parents 06d1fe5 + fc7bffb commit a271ce7
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 30 days this issue will be closed.'
stale-pr-message: 'Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.'
days-before-stale: 365
days-before-close: 30
days-before-stale: 30
days-before-close: 14
stale-issue-label: "status: feedback-reminder"
stale-pr-label: "status: feedback-reminder"
operations-per-run: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public ClaimedMessagesOutput(RedisCodec<K, V> codec, K stream, boolean justId) {
@Override
public void set(ByteBuffer bytes) {
if (startId == null) {
startId = decodeAscii(bytes);
startId = decodeString(bytes);
return;
}

if (id == null) {
id = decodeAscii(bytes);
id = decodeString(bytes);
return;
}

Expand Down
15 changes: 4 additions & 11 deletions src/main/java/io/lettuce/core/output/CommandOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.lettuce.core.output;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import io.lettuce.core.codec.RedisCodec;
import io.lettuce.core.internal.LettuceAssert;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void set(boolean value) {
* @param error Error message.
*/
public void setError(ByteBuffer error) {
this.error = decodeAscii(error);
this.error = decodeString(error);
}

/**
Expand Down Expand Up @@ -179,16 +180,8 @@ public void complete(int depth) {
// nothing to do by default
}

protected String decodeAscii(ByteBuffer bytes) {
if (bytes == null) {
return null;
}

char[] chars = new char[bytes.remaining()];
for (int i = 0; i < chars.length; i++) {
chars[i] = (char) bytes.get();
}
return new String(chars);
protected String decodeString(ByteBuffer bytes) {
return bytes == null ? null : StandardCharsets.UTF_8.decode(bytes).toString();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/DoubleListOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DoubleListOutput(RedisCodec<K, V> codec) {

@Override
public void set(ByteBuffer bytes) {
output.add(bytes != null ? parseDouble(decodeAscii(bytes)) : null);
output.add(bytes != null ? parseDouble(decodeString(bytes)) : null);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/DoubleOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public DoubleOutput(RedisCodec<K, V> codec) {

@Override
public void set(ByteBuffer bytes) {
output = (bytes == null) ? null : parseDouble(decodeAscii(bytes));
output = (bytes == null) ? null : parseDouble(decodeString(bytes));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/EnumSetOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void set(ByteBuffer bytes) {
return;
}

E enumConstant = resolve(enumValuePreprocessor.apply(decodeAscii(bytes)));
E enumConstant = resolve(enumValuePreprocessor.apply(decodeString(bytes)));

if (enumConstant == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void set(ByteBuffer bytes) {
return;
}

double value = (bytes == null) ? 0 : parseDouble(decodeAscii(bytes));
double value = (bytes == null) ? 0 : parseDouble(decodeString(bytes));
set(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void set(ByteBuffer bytes) {
return;
}

double value = parseDouble(decodeAscii(bytes));
double value = parseDouble(decodeString(bytes));
set(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void set(ByteBuffer bytes) {
return;
}

double value = (bytes == null) ? 0 : parseDouble(decodeAscii(bytes));
double value = (bytes == null) ? 0 : parseDouble(decodeString(bytes));
set(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void set(ByteBuffer bytes) {
multi(1);
}

output.add(JsonType.fromString(decodeAscii(bytes)));
output.add(JsonType.fromString(decodeString(bytes)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void set(ByteBuffer bytes) {
value = codec.decodeValue(bytes);
return;
}
score = parseDouble(decodeAscii(bytes));
score = parseDouble(decodeString(bytes));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void set(ByteBuffer bytes) {
return;
}

output = KeyValue.just(key, ScoredValue.just(parseDouble(decodeAscii(bytes)), value));
output = KeyValue.just(key, ScoredValue.just(parseDouble(decodeString(bytes)), value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void set(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));

set(score);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/MultiOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void setError(ByteBuffer error) {
}

CommandOutput<K, V, ?> output = queue.isEmpty() ? this : queue.peek().getOutput();
output.setError(decodeAscii(error));
output.setError(decodeString(error));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/NumberListOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void multi(int count) {
private Number parseNumber(ByteBuffer bytes) {
Number result = 0;
try {
result = NumberFormat.getNumberInstance().parse(decodeAscii(bytes));
result = NumberFormat.getNumberInstance().parse(decodeString(bytes));
} catch (ParseException e) {
LOG.warn("Failed to parse " + bytes, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PendingMessageListOutput(RedisCodec<K, V> codec) {
public void set(ByteBuffer bytes) {

if (messageId == null) {
messageId = decodeAscii(bytes);
messageId = decodeString(bytes);
return;
}

Expand All @@ -51,7 +51,7 @@ public void set(ByteBuffer bytes) {
return;
}

set(Long.parseLong(decodeAscii(bytes)));
set(Long.parseLong(decodeString(bytes)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public PendingMessagesOutput(RedisCodec<K, V> codec) {
public void set(ByteBuffer bytes) {

if (messageIdsFrom == null) {
messageIdsFrom = decodeAscii(bytes);
messageIdsFrom = decodeString(bytes);
return;
}

if (messageIdsTo == null) {
messageIdsTo = decodeAscii(bytes);
messageIdsTo = decodeString(bytes);
return;
}

Expand All @@ -54,7 +54,7 @@ public void set(ByteBuffer bytes) {
return;
}

set(Long.parseLong(decodeAscii(bytes)));
set(Long.parseLong(decodeString(bytes)));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/ScanOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ScanOutput(RedisCodec<K, V> codec, T cursor) {
public void set(ByteBuffer bytes) {

if (output.getCursor() == null) {
output.setCursor(decodeAscii(bytes));
output.setCursor(decodeString(bytes));
if (LettuceStrings.isNotEmpty(output.getCursor()) && "0".equals(output.getCursor())) {
output.setFinished(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void set(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));
set(score);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void set(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));
set(score);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void setOutput(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));
set(score);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void setOutput(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));
set(score);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void set(ByteBuffer bytes) {
return;
}

double score = LettuceStrings.toDouble(decodeAscii(bytes));
double score = LettuceStrings.toDouble(decodeString(bytes));
set(score);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/lettuce/core/output/SocketAddressOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public SocketAddressOutput(RedisCodec<K, V> codec) {
public void set(ByteBuffer bytes) {

if (!hasHostname) {
hostname = decodeAscii(bytes);
hostname = decodeString(bytes);
hasHostname = true;
return;
}

int port = Integer.parseInt(decodeAscii(bytes));
int port = Integer.parseInt(decodeString(bytes));
output = InetSocketAddress.createUnresolved(hostname, port);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/StatusOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public StatusOutput(RedisCodec<K, V> codec) {

@Override
public void set(ByteBuffer bytes) {
output = OK.equals(bytes) ? "OK" : decodeAscii(bytes);
output = OK.equals(bytes) ? "OK" : decodeString(bytes);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public StreamMessageListOutput(RedisCodec<K, V> codec, K stream) {
public void set(ByteBuffer bytes) {

if (id == null) {
id = decodeAscii(bytes);
id = decodeString(bytes);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/StreamReadOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void set(ByteBuffer bytes) {
}

if (id == null) {
id = decodeAscii(bytes);
id = decodeString(bytes);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/output/StringListOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void set(ByteBuffer bytes) {
multi(1);
}

subscriber.onNext(output, bytes == null ? null : decodeAscii(bytes));
subscriber.onNext(output, bytes == null ? null : decodeString(bytes));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public StringValueListOutput(RedisCodec<K, V> codec) {

@Override
public void set(ByteBuffer bytes) {
subscriber.onNext(output, bytes == null ? Value.empty() : Value.fromNullable(decodeAscii(bytes)));
subscriber.onNext(output, bytes == null ? Value.empty() : Value.fromNullable(decodeString(bytes)));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/lettuce/core/pubsub/PubSubOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void set(ByteBuffer bytes) {
}

if (type == null) {
type = Type.valueOf(decodeAscii(bytes));
type = Type.valueOf(decodeString(bytes));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void aclLog() {

@Test
void aclList() {
assertThat(redis.aclList()).hasSize(2).first().asString().contains("user default");
assertThat(redis.aclList()).hasSize(1).first().asString().contains("user default");
}

@Test
Expand Down Expand Up @@ -161,7 +161,7 @@ void aclSetuserWithCategories() {

@Test
void aclUsers() {
assertThat(redis.aclUsers()).hasSize(2).first().isEqualTo("default");
assertThat(redis.aclUsers()).hasSize(1).first().isEqualTo("default");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void setup() {
redisCommandFactory = new RedisCommandFactory(new MockStatefulConnection(EmptyRedisChannelWriter.INSTANCE));
regularCommands = redisCommandFactory.getCommands(RegularCommands.class);

asyncCommands = new RedisAsyncCommandsImpl<>(EmptyStatefulRedisConnection.INSTANCE, StringCodec.UTF8, Mono.just(new DefaultJsonParser()));
asyncCommands = new RedisAsyncCommandsImpl<>(EmptyStatefulRedisConnection.INSTANCE, StringCodec.UTF8);
}

@Benchmark
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/log4j2-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

<Loggers>
<Logger name="io.lettuce.core.protocol" level="FATAL"/>
<!-- Remove the line below after we stabilize the test-containers deployment -->
<!-- Uncomment the line below to enable test-containers debug logging -->
<!--
<Logger name="org.testcontainers" level="DEBUG"/>
-->
<Root level="FATAL">
<AppenderRef ref="Console"/>
<AppenderRef ref="File"/>
Expand Down

0 comments on commit a271ce7

Please sign in to comment.