Skip to content

Commit

Permalink
<fix>(halo): Fixed invoke with empty handler list.
Browse files Browse the repository at this point in the history
  • Loading branch information
yizzuide committed Feb 26, 2020
1 parent 6b25473 commit f70474c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Milkomeda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<java.version>1.8</java.version>
<project.release.version>2.5.2-SNAPSHOT</project.release.version>
<project.release.version>2.5.3-SNAPSHOT</project.release.version>
<mybatis.starter.version>2.1.1</mybatis.starter.version>
<jsqlparser.version>3.1</jsqlparser.version>
<jwt.version>0.9.1</jwt.version>
Expand Down Expand Up @@ -63,7 +63,7 @@
<profile>
<id>sonatype-oss-release</id>
<properties>
<project.release.version>2.5.2</project.release.version>
<project.release.version>2.5.3</project.release.version>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.util.CollectionUtils;

import java.lang.reflect.Method;
import java.util.List;
Expand All @@ -21,7 +22,7 @@
*
* @author yizzuide
* @since 2.5.0
* @version 2.5.1
* @version 2.5.3
* Create at 2020/01/30 20:38
*/
@Slf4j
Expand All @@ -33,6 +34,11 @@
public class HaloInterceptor implements Interceptor {
@Override
public Object intercept(Invocation invocation) throws Throwable {
// 如果处理器为空,直接返回
if (CollectionUtils.isEmpty(HaloContext.getTableNameMap())) {
return invocation.proceed();
}

Object[] args = invocation.getArgs();
// 获取第一个参数,MappedStatement
MappedStatement mappedStatement = (MappedStatement) args[0];
Expand Down Expand Up @@ -62,6 +68,9 @@ public Object plugin(Object target) {
}

private void invokeWithTable(String tableName, String matchTableName, MappedStatement mappedStatement, Object param, Object result, HaloType type) {
if (!HaloContext.getTableNameMap().containsKey(matchTableName)) {
return;
}
HaloContext.getTableNameMap().get(matchTableName).stream()
.filter(metaData -> metaData.getAttributes().get(HaloContext.ATTR_TYPE) == type)
.forEach(handlerMetaData -> invokeHandler(tableName, handlerMetaData, mappedStatement, param, result));
Expand Down
2 changes: 1 addition & 1 deletion MilkomedaDemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<milkomeda.version>2.5.2-SNAPSHOT</milkomeda.version>
<milkomeda.version>2.5.3-SNAPSHOT</milkomeda.version>
<mybatis.starter>2.1.1</mybatis.starter>
</properties>

Expand Down

0 comments on commit f70474c

Please sign in to comment.