Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] A brief and accurate description of PR

### bugfix:
- [[#6090](https://github.com/seata/seata/pull/6090)] fix the TCC aspect exception handling process, do not wrapping the internal call exceptions
- [[#6075](https://github.com/seata/seata/pull/6075)] fix missing table alias for on update column of image SQL
- [[#6086](https://github.com/seata/seata/pull/6086)] fix oracle column alias cannot find
- [[#6085](https://github.com/seata/seata/pull/6085)] fix jdk9+ compile error
Expand Down Expand Up @@ -40,5 +41,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [Bughue](https://github.com/Bughue)
- [wangliang181230](https://github.com/wangliang181230)
- [ggbocoder](https://github.com/ggbocoder)
- [leezongjie](https://github.com/leezongjie)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
2 changes: 2 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 准确简要的PR描述

### bugfix:
- [[#6090](https://github.com/seata/seata/pull/6090)] 修复tcc切面异常处理过程,不对内部调用异常做包装处理,直接向外抛出
- [[#6075](https://github.com/seata/seata/pull/6075)] 修复镜像SQL对于on update列没有添加表别名的问题
- [[#6086](https://github.com/seata/seata/pull/6086)] 修复oracle alias 解析异常
- [[#6085](https://github.com/seata/seata/pull/6085)] 修复jdk9+版本编译后,引入后ByteBuffer#flip NoSuchMethodError的问题
Expand Down Expand Up @@ -39,5 +40,6 @@
- [Bughue](https://github.com/Bughue)
- [wangliang181230](https://github.com/wangliang181230)
- [ggbocoder](https://github.com/ggbocoder)
- [leezongjie](https://github.com/leezongjie)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.seata.integration.tx.api.interceptor;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
Expand Down Expand Up @@ -54,11 +55,15 @@ public Object[] getArguments() {
}

@Override
public Object proceed() {
public Object proceed() throws Throwable {
try {
return method.invoke(delegate, args);
} catch (Throwable t) {
throw new RuntimeException(t);
if (t instanceof InvocationTargetException) {
t = t.getCause();
}
throw t;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface InvocationWrapper {

Object[] getArguments();

Object proceed();
Object proceed() throws Throwable;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.integration.tx.api.interceptor;

import java.lang.reflect.Method;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* @author leezongjie
* @date 2023/11/29
*/
class DefaultInvocationWrapperTest {

@Test
void proceed() throws Throwable {
//given
MyMockMethodInvocation myMockMethodInvocation = new MyMockMethodInvocation();
Method method = MyMockMethodInvocation.class.getDeclaredMethod("proceed", int.class);

//when
DefaultInvocationWrapper invocationWrapper = new DefaultInvocationWrapper(myMockMethodInvocation, myMockMethodInvocation, method, new Object[]{1});
//then
Assertions.assertEquals(1, invocationWrapper.proceed());

//when
DefaultInvocationWrapper invocationWrapperThrowException = new DefaultInvocationWrapper(myMockMethodInvocation, myMockMethodInvocation, method, new Object[]{0});
//then should throw raw exception
Assertions.assertThrows(ArithmeticException.class, () -> invocationWrapperThrowException.proceed());
}


static class MyMockMethodInvocation {
public Object proceed(int divisor) {
return 1 / divisor;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ public Object[] getArguments() {
}

@Override
public Object proceed() {
try {
return invocation.proceed();
} catch (Throwable throwable) {
throw new RuntimeException("try to proceed invocation error", throwable);
}
public Object proceed() throws Throwable {
return invocation.proceed();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.spring.annotation;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import io.seata.integration.tx.api.interceptor.handler.ProxyInvocationHandler;
import io.seata.integration.tx.api.interceptor.parser.DefaultInterfaceParser;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.spring.tcc.NormalTccAction;
import io.seata.spring.tcc.NormalTccActionImpl;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* @author leezongjie
* @date 2023/11/29
*/
class AdapterSpringSeataInterceptorTest {

@Test
void should_throw_raw_exception_when_call_prepareWithException() throws Throwable {
//given
NormalTccActionImpl normalTccAction = new NormalTccActionImpl();
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(normalTccAction, "proxyTccAction");
AdapterSpringSeataInterceptor adapterSpringSeataInterceptor = new AdapterSpringSeataInterceptor(proxyInvocationHandler);
MyMockMethodInvocation myMockMethodInvocation = new MyMockMethodInvocation(NormalTccAction.class.getMethod("prepareWithException", BusinessActionContext.class), () -> normalTccAction.prepareWithException(null));

//when then
Assertions.assertThrows(IllegalArgumentException.class, () -> adapterSpringSeataInterceptor.invoke(myMockMethodInvocation));
}

@Test
void should_success_when_call_prepare_with_ProxyInvocationHandler() throws Throwable {
//given
NormalTccActionImpl normalTccAction = new NormalTccActionImpl();
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(normalTccAction, "proxyTccAction");
AdapterSpringSeataInterceptor adapterSpringSeataInterceptor = new AdapterSpringSeataInterceptor(proxyInvocationHandler);
MyMockMethodInvocation myMockMethodInvocation = new MyMockMethodInvocation(NormalTccAction.class.getMethod("prepare", BusinessActionContext.class), () -> normalTccAction.prepare(null));

//when then
Assertions.assertTrue((Boolean) adapterSpringSeataInterceptor.invoke(myMockMethodInvocation));
}

static class MyMockMethodInvocation implements MethodInvocation {

private Callable callable;
private Method method;

public MyMockMethodInvocation(Method method, Callable callable) {
this.method = method;
this.callable = callable;
}

@Nullable
@Override
public Object proceed() throws Throwable {
return callable.call();
}

@Nonnull
@Override
public Method getMethod() {
return method;
}

@Nonnull
@Override
public Object[] getArguments() {
return new Object[0];
}

@Nullable
@Override
public Object getThis() {
return null;
}

@Nonnull
@Override
public AccessibleObject getStaticPart() {
return null;
}
}
}
35 changes: 35 additions & 0 deletions spring/src/test/java/io/seata/spring/tcc/NormalTccAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.spring.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface NormalTccAction {

@TwoPhaseBusinessAction(name = "tccActionForTestWithException")
boolean prepare(BusinessActionContext actionContext);

@TwoPhaseBusinessAction(name = "tccActionForTestWithException")
boolean prepareWithException(BusinessActionContext actionContext);

boolean commit(BusinessActionContext actionContext);

boolean rollback(BusinessActionContext actionContext);

}
44 changes: 44 additions & 0 deletions spring/src/test/java/io/seata/spring/tcc/NormalTccActionImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.spring.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;

/**
* @author leezongjie
* @date 2023/11/29
*/
public class NormalTccActionImpl implements NormalTccAction {
@Override
public boolean prepare(BusinessActionContext actionContext) {
return true;
}

@Override
public boolean prepareWithException(BusinessActionContext actionContext) {
throw new IllegalArgumentException();
}

@Override
public boolean commit(BusinessActionContext actionContext) {
return false;
}

@Override
public boolean rollback(BusinessActionContext actionContext) {
return false;
}
}
8 changes: 8 additions & 0 deletions tcc/src/test/java/io/seata/rm/tcc/NormalTccAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ boolean commit(BusinessActionContext actionContext,
* @return the boolean
*/
boolean rollback(BusinessActionContext actionContext, @BusinessActionContextParameter("tccParam") TccParam param);


@TwoPhaseBusinessAction(name = "tccActionForTestWithException", commitMethod = "commit", rollbackMethod = "rollback", commitArgsClasses = {BusinessActionContext.class, TccParam.class}, rollbackArgsClasses = {BusinessActionContext.class, TccParam.class})
String prepareWithException(BusinessActionContext actionContext,
@BusinessActionContextParameter("a") int a,
@BusinessActionContextParameter(paramName = "b", index = 0) List b,
@BusinessActionContextParameter(isParamInProperty = true) TccParam tccParam);

}
11 changes: 8 additions & 3 deletions tcc/src/test/java/io/seata/rm/tcc/NormalTccActionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package io.seata.rm.tcc;


import io.seata.rm.tcc.api.BusinessActionContext;

import java.util.List;

import io.seata.rm.tcc.api.BusinessActionContext;

/**
* @author leezongjie
*/
Expand All @@ -40,8 +40,13 @@ public boolean rollback(BusinessActionContext actionContext, TccParam param) {
return false;
}

public boolean otherMethod(){
public boolean otherMethod() {
return true;
}

@Override
public String prepareWithException(BusinessActionContext actionContext, int a, List b, TccParam tccParam) {
throw new IllegalArgumentException();
}

}
Loading