Skip to content

Conversation

@liqi19950722
Copy link

@liqi19950722 liqi19950722 commented Mar 17, 2024

实现 #2

新增 dependency org.testcontainers io.smallrye.jandex
microsphere-redis-spring 主要是新增class
microsphere-redis-replicator-spring 接口有变动

RedisCommandReplicatedEventHandler Benchmark 仅供参考
1aaa795edcbdc97857ee79a4cf3a83db
image

add PrimitiveType
add ArrayType
add VoidType
add ParameterizedType
add ClassType
add method getMethodHandleBy
add MethodHandleNotFoundException when not found
add testcontainers in the test scope
add spring-boot-starter-data-redis in the test scope to autoconfigure in test
test RedisCommandReplicatedEvent by use MethodHandleEventHandle way
jandex 3.1.6 -> 3.1.7
add writeCommandMethodHandlesCache
@mercyblitz mercyblitz changed the base branch from main to dev-pr November 25, 2025 02:45
@sonarqubecloud
Copy link

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


@Override
public void handleEvent(Method method, Object redisCommandObject, Object... args) throws Throwable {
int length = args.length;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args can be null for 0-arg commands (e.g., if RedisCommandEvent.getArgs() is null), so args.length will NPE and make METHOD_HANDLE mode fail where REFLECT likely works. Consider defensively handling args == null here.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎


public static MethodHandle getWriteCommandMethodHandle(Method method) {
String id = buildCommandMethodId(method);
return writeCommandMethodHandlesCache.get(id);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getWriteCommandMethodHandle() can return null (e.g., if initWriteCommandMethodHandleCache() logged an error and returned), which will surface later as an unhelpful NPE at the call site. Consider failing fast with a clearer exception or at least logging when the handle is missing.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

.stream()
.filter(eventHandle -> eventHandle.name().equals(eventHandleType))
.findFirst()
.orElseThrow(() -> new IllegalStateException("No eventHandle found"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thrown IllegalStateException("No eventHandle found") doesn’t include CONSUMER_EVENT_HANDLE_PROPERTY_NAME or the configured eventHandleType, which can make misconfiguration harder to diagnose. Consider including those details in the exception message.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant