Skip to content

Commit

Permalink
MONDRIAN: Use trivial executor. I think the test was hanging because the
Browse files Browse the repository at this point in the history
    executor had a non-daemon thread.

[git-p4: depot-paths = "//open/mondrian-release/3.2/": change = 13970]
  • Loading branch information
julianhyde committed Dec 11, 2010
1 parent 216730c commit ec74fd0
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion testsrc/main/mondrian/olap4j/MondrianInprocProxy.java
Expand Up @@ -59,7 +59,7 @@ public MondrianInprocProxy(

// Use single-threaded executor for ease of debugging.
private static final ExecutorService singleThreadExecutor =
Executors.newSingleThreadExecutor();
new InlineExecutorService();

public byte[] get(URL url, String request) throws IOException {
try {
Expand Down Expand Up @@ -90,6 +90,43 @@ public byte[] call() throws Exception {
public String getEncodingCharsetName() {
return "UTF-8";
}

/**
* Trivial executor service that executes all requests using the submitter's
* thread.
*/
private static class InlineExecutorService extends AbstractExecutorService {
private boolean shutdown = false;
private boolean terminated = false;

public void shutdown() {
shutdown = true;
}

public List<Runnable> shutdownNow() {
shutdown = true;
return Collections.emptyList();
}

public boolean isShutdown() {
return shutdown;
}

public boolean isTerminated() {
return terminated;
}

public boolean awaitTermination(long timeout, TimeUnit unit)
throws InterruptedException
{
terminated = true;
return true;
}

public void execute(Runnable command) {
command.run();
}
}
}

// End MondrianInprocProxy.java

0 comments on commit ec74fd0

Please sign in to comment.