Skip to content

Commit

Permalink
ISPN-6192 Short-term memory leak caused by RPCs that complete prior t…
Browse files Browse the repository at this point in the history
…o their timeout
  • Loading branch information
pferraro authored and wburns committed Feb 9, 2016
1 parent e1cc715 commit 3f80bd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Expand Up @@ -7,13 +7,9 @@
/**
* @author Galder Zamarreño
*/
public class CachedThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ExecutorService> {
public enum CachedThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ExecutorService> {

private static final CachedThreadPoolExecutorFactory INSTANCE = new CachedThreadPoolExecutorFactory();

private CachedThreadPoolExecutorFactory() {
// singleton
}
INSTANCE;

@Override
public ExecutorService createExecutor(ThreadFactory factory) {
Expand All @@ -28,5 +24,4 @@ public void validate() {
public static CachedThreadPoolExecutorFactory create() {
return INSTANCE;
}

}
@@ -1,23 +1,21 @@
package org.infinispan.commons.executors;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;

/**
* @author Galder Zamarreño
*/
public class ScheduledThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ScheduledExecutorService> {
public enum ScheduledThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ScheduledExecutorService> {

private static final ScheduledThreadPoolExecutorFactory INSTANCE = new ScheduledThreadPoolExecutorFactory();

private ScheduledThreadPoolExecutorFactory() {
// singleton
}
INSTANCE;

@Override
public ScheduledExecutorService createExecutor(ThreadFactory factory) {
return Executors.newSingleThreadScheduledExecutor(factory);
ScheduledThreadPoolExecutor result = new ScheduledThreadPoolExecutor(1, factory);
result.setRemoveOnCancelPolicy(true);
return result;
}

@Override
Expand All @@ -28,5 +26,4 @@ public void validate() {
public static ScheduledThreadPoolExecutorFactory create() {
return INSTANCE;
}

}

0 comments on commit 3f80bd9

Please sign in to comment.