From 41af535ae87757697d9cc798bb5b5f1e015c19bf Mon Sep 17 00:00:00 2001 From: liningrui Date: Sat, 22 Jun 2019 20:06:36 +0800 Subject: [PATCH] Enhance ExecutorUtil to create ScheduledThreadPool --- pom.xml | 4 ++-- .../com/baidu/hugegraph/rest/RestResult.java | 2 +- .../com/baidu/hugegraph/util/ExecutorUtil.java | 18 ++++++++++++++++++ .../baidu/hugegraph/version/CommonVersion.java | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 13b0cd76d..7f97011a3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidu.hugegraph hugegraph-common - 1.6.5 + 1.6.6 hugegraph-common https://github.com/hugegraph/hugegraph-common @@ -212,7 +212,7 @@ - 1.6.5.0 + 1.6.6.0 diff --git a/src/main/java/com/baidu/hugegraph/rest/RestResult.java b/src/main/java/com/baidu/hugegraph/rest/RestResult.java index 92962eacd..e4908f8b3 100644 --- a/src/main/java/com/baidu/hugegraph/rest/RestResult.java +++ b/src/main/java/com/baidu/hugegraph/rest/RestResult.java @@ -77,7 +77,7 @@ public List readList(String key, Class clazz) { JavaType type = mapper.getTypeFactory() .constructParametrizedType(ArrayList.class, List.class, clazz); - return mapper.readValue(element.toString(), type); + return mapper.convertValue(element, type); } catch (IOException e) { throw new SerializeException( "Failed to deserialize %s", e, this.content); diff --git a/src/main/java/com/baidu/hugegraph/util/ExecutorUtil.java b/src/main/java/com/baidu/hugegraph/util/ExecutorUtil.java index 773ec0d8d..465ec95e3 100644 --- a/src/main/java/com/baidu/hugegraph/util/ExecutorUtil.java +++ b/src/main/java/com/baidu/hugegraph/util/ExecutorUtil.java @@ -21,16 +21,34 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; import org.apache.commons.lang3.concurrent.BasicThreadFactory; public final class ExecutorUtil { + public static ExecutorService newSingleFixedThreadPool(String name) { + return newFixedThreadPool(1, name); + } + public static ExecutorService newFixedThreadPool(int size, String name) { ThreadFactory factory = new BasicThreadFactory.Builder() .namingPattern(name) .build(); return Executors.newFixedThreadPool(size, factory); } + + public static ScheduledExecutorService newSingleScheduledThreadPool( + String name) { + return newScheduledThreadPool(1, name); + } + + public static ScheduledExecutorService newScheduledThreadPool(int size, + String name) { + ThreadFactory factory = new BasicThreadFactory.Builder() + .namingPattern(name) + .build(); + return Executors.newScheduledThreadPool(size, factory); + } } diff --git a/src/main/java/com/baidu/hugegraph/version/CommonVersion.java b/src/main/java/com/baidu/hugegraph/version/CommonVersion.java index 55585ad67..da9b44c59 100644 --- a/src/main/java/com/baidu/hugegraph/version/CommonVersion.java +++ b/src/main/java/com/baidu/hugegraph/version/CommonVersion.java @@ -27,5 +27,5 @@ public class CommonVersion { // The second parameter of Version.of() is for all-in-one JAR public static final Version VERSION = Version.of(CommonVersion.class, - "1.6.5"); + "1.6.6"); }