From dfdf1001694c94b1d982cf245996b0faee1fec1a Mon Sep 17 00:00:00 2001 From: "yadong.zhang" Date: Thu, 28 Oct 2021 20:25:25 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E3=80=90=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=90=AC=E8=BF=90=E5=B7=A5=E3=80=91=E6=8A=93=E5=8F=96?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-core/pom.xml | 30 --------- .../service/impl/RemoverServiceImpl.java | 4 +- .../blog/framework/config/AsyncConfig.java | 67 +------------------ pom.xml | 4 +- 4 files changed, 6 insertions(+), 99 deletions(-) diff --git a/blog-core/pom.xml b/blog-core/pom.xml index 02fb70f..fa523d9 100644 --- a/blog-core/pom.xml +++ b/blog-core/pom.xml @@ -199,36 +199,6 @@ me.zhyd.hunter blog-hunter ${blog-hunter.version} - - - org.hibernate.validator - hibernate-validator - - - com.alibaba - fastjson - - - org.jsoup - jsoup - - - org.slf4j - slf4j-api - - - lombok - org.projectlombok - - - commons-collections - commons-collections - - - commons-io - commons-io - - com.zyd diff --git a/blog-core/src/main/java/com/zyd/blog/business/service/impl/RemoverServiceImpl.java b/blog-core/src/main/java/com/zyd/blog/business/service/impl/RemoverServiceImpl.java index 94ad020..15461d8 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/service/impl/RemoverServiceImpl.java +++ b/blog-core/src/main/java/com/zyd/blog/business/service/impl/RemoverServiceImpl.java @@ -89,7 +89,8 @@ public class RemoverServiceImpl implements RemoverService { private void saveArticles(Long typeId, HunterConfig config, HunterPrintWriter writerUtil, CopyOnWriteArrayList list) { // 获取数据库中的标签列表 - Map originalTags = tagsService.listAll().stream().collect(Collectors.toMap(tag -> tag.getName().toUpperCase(), Tags::getId)); + List tags = tagsService.listAll(); + Map originalTags = tags.stream().collect(Collectors.toMap(tag -> tag.getName().toUpperCase(), Tags::getId)); User user = SessionUtil.getUser(); // 添加文章到数据库 @@ -115,6 +116,7 @@ public class RemoverServiceImpl implements RemoverService { article.setIsMarkdown(false); article.setDescription(virtualArticle.getDescription()); article.setKeywords(virtualArticle.getKeywords()); + article.setEditorType("we"); article = articleService.insert(article); writerUtil.print(String.format("[ save ] Succeed! %s", virtualArticle.getSource(), article.getTitle())); return article; diff --git a/blog-core/src/main/java/com/zyd/blog/framework/config/AsyncConfig.java b/blog-core/src/main/java/com/zyd/blog/framework/config/AsyncConfig.java index 79797b2..936142e 100644 --- a/blog-core/src/main/java/com/zyd/blog/framework/config/AsyncConfig.java +++ b/blog-core/src/main/java/com/zyd/blog/framework/config/AsyncConfig.java @@ -1,20 +1,8 @@ package com.zyd.blog.framework.config; import lombok.extern.slf4j.Slf4j; -import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.util.concurrent.ListenableFuture; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; - -import java.lang.reflect.Method; -import java.util.concurrent.Callable; -import java.util.concurrent.Executor; -import java.util.concurrent.Future; /** * 异步线程配置 @@ -28,58 +16,5 @@ import java.util.concurrent.Future; @Slf4j @Configuration @EnableAsync -public class AsyncConfig implements AsyncConfigurer { - - @Override - @Bean - public Executor getAsyncExecutor() { - return new ContextAwarePoolExecutor(); - } - - @Override - public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { - return new SpringAsyncExceptionHandler(); - } - - class SpringAsyncExceptionHandler implements AsyncUncaughtExceptionHandler { - @Override - public void handleUncaughtException(Throwable throwable, Method method, Object... objects) { - log.error("异步线程发生异常!Method [{}],Error Message [{}]", method.getName(), throwable.getMessage()); - } - } - - public class ContextAwarePoolExecutor extends ThreadPoolTaskExecutor { - @Override - public Future submit(Callable task) { - return super.submit(new ContextAwareCallable(task, RequestContextHolder.currentRequestAttributes())); - } - - @Override - public ListenableFuture submitListenable(Callable task) { - return super.submitListenable(new ContextAwareCallable(task, RequestContextHolder.currentRequestAttributes())); - } - } - - public class ContextAwareCallable implements Callable { - private Callable task; - private RequestAttributes context; - - public ContextAwareCallable(Callable task, RequestAttributes context) { - this.task = task; - this.context = context; - } - - @Override - public T call() throws Exception { - if (context != null) { - RequestContextHolder.setRequestAttributes(context); - } - - try { - return task.call(); - } finally { - RequestContextHolder.resetRequestAttributes(); - } - } - } +public class AsyncConfig { } diff --git a/pom.xml b/pom.xml index a3467b3..b1368e1 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 1.8 true 0.7.3 - 1.14.2 + 1.10.2 2.0.1.Final 7.0.1.Final 2.1.4-Final @@ -48,7 +48,7 @@ 1.21 1.0.0-alpha 5.5.7 - 5.1.4.RELEASE + 5.1.17.RELEASE 2.8.3 1.0.4 1.0.4 -- GitLab