Skip to content

Commit

Permalink
Enhance ExecutorUtil to create ScheduledThreadPool
Browse files Browse the repository at this point in the history
  • Loading branch information
Linary committed Jun 22, 2019
1 parent 2f453c0 commit 41af535
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>

<name>hugegraph-common</name>
<url>https://github.com/hugegraph/hugegraph-common</url>
Expand Down Expand Up @@ -212,7 +212,7 @@
<manifestEntries>
<!-- Must be on one line, otherwise the automatic
upgrade script cannot replace the version number -->
<Implementation-Version>1.6.5.0</Implementation-Version>
<Implementation-Version>1.6.6.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/baidu/hugegraph/rest/RestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public <T> List<T> readList(String key, Class<T> 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);
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/baidu/hugegraph/util/ExecutorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit 41af535

Please sign in to comment.