Skip to content

Commit

Permalink
[#noissue] Improve compatibility with thrift 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Nov 1, 2024
1 parent b5dfe65 commit 4854ee9
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ public void before(Object target, Object[] args) {
if (ArrayUtils.getLength(args) != 4) {
return;
}
String methodName = ThriftConstants.UNKNOWN_METHOD_NAME;
if (target instanceof ProcessFunction) {
final ProcessFunction<?, ?> processFunction = (ProcessFunction<?, ?>) target;
methodName = processFunction.getMethodName();
}
final String methodName = getMethodName(target);
final InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
final Object attachment = currentTransaction.getOrCreateAttachment(ThriftClientCallContextAttachmentFactory.INSTANCE);
if (attachment instanceof ThriftClientCallContext) {
Expand All @@ -88,6 +84,17 @@ public void before(Object target, Object[] args) {
}
}

@SuppressWarnings("rawtypes")
private String getMethodName(Object target) {
if (target instanceof ProcessFunction) {
// https://github.com/apache/thrift/blob/v0.21.0/lib/java/src/main/java/org/apache/thrift/ProcessFunction.java
// API changes in 0.21.0
final ProcessFunction processFunction = (ProcessFunction) target;
return processFunction.getMethodName();
}
return ThriftConstants.UNKNOWN_METHOD_NAME;
}

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
Expand Down

0 comments on commit 4854ee9

Please sign in to comment.