Skip to content

Refactor #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import io.microsphere.lang.function.ThrowableConsumer;
import io.microsphere.lang.function.ThrowableFunction;
import io.microsphere.logging.Logger;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.executor.Executor;
Expand All @@ -38,7 +37,6 @@
import java.util.Properties;
import java.util.function.Function;

import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.util.ArrayUtils.length;
import static io.microsphere.util.Assert.assertNotEmpty;
import static io.microsphere.util.Assert.assertNotNull;
Expand All @@ -53,8 +51,6 @@
*/
public class ExecutorFilterChain {

private static final Logger logger = getLogger(ExecutorFilterChain.class);

private final Executor executor;

@Nullable
Expand Down Expand Up @@ -159,26 +155,16 @@ protected <R> R applySQL(ThrowableFunction<ExecutorFilter, R> filterFunction,
protected <E extends Throwable, R> R process(ThrowableFunction<ExecutorFilter, R> filterFunction,
ThrowableFunction<Executor, R> executorFunction,
Function<Throwable, E> failureHandler) throws E {

if (position < size) {
ExecutorFilter filter = filters[position++];
try {
return filterFunction.apply(filter);
} catch (Throwable e) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to execute ExecutorFilter[ index : {} , instance : {}]", position, filter, e);
}
}
}

R result = null;

final R result;
try {
result = executorFunction.apply(this.executor);
if (position < size) {
result = filterFunction.apply(filters[position++]);
} else {
result = executorFunction.apply(this.executor);
}
} catch (Throwable failure) {
throw failureHandler.apply(failure);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package io.microsphere.mybatis.plugin;

import io.microsphere.mybatis.executor.ThrowingErrorExecutorFilter;
import io.microsphere.mybatis.executor.LogggingExecutorInterceptor;
import io.microsphere.mybatis.executor.LoggingExecutorFilter;
import io.microsphere.mybatis.executor.TestExecutorFilter;
Expand Down Expand Up @@ -45,7 +44,7 @@ protected void customize(Configuration configuration) {

private InterceptingExecutorInterceptor createInterceptingExecutorInterceptor() {
InterceptingExecutorInterceptor interceptor = new InterceptingExecutorInterceptor(
of(new LoggingExecutorFilter(), new TestExecutorFilter(), new ThrowingErrorExecutorFilter()),
of(new LoggingExecutorFilter(), new TestExecutorFilter()),
new LogggingExecutorInterceptor(), new TestInterceptorContextExecutorInterceptor());
Properties properties = new Properties();
properties.setProperty(TEST_PROPERTY_KEY, this.getClass().getName());
Expand Down