Reviewers: bobv,
Description:
RequestFactoryJarExtractor intermittently throws exceptions when running
on a multi-core build machine. The build infrastructure did not catch
the error and kept going, leaving a corrupt request factory jar file.
This temporarily works around the problem by capping the number of
threads
used to process the jar file at 1.
Please review this at http://gwt-code-reviews.appspot.com/1425805/
Affected files:
M requestfactory/build.xml
M
user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
Index: requestfactory/build.xml
===================================================================
--- requestfactory/build.xml (revision 10021)
+++ requestfactory/build.xml (working copy)
@@ -32,6 +32,7 @@
<pathelement path="${gwt.build.out}/dev/bin-test" />
<pathelement path="${gwt.build.out}/user/bin-test" />
</classpath>
+ <jvmarg value="-ea"/>
<arg value="@{target}"/>
<arg file="${gwt.build.lib}/requestfactory-@{target}.jar"/>
</java>
Index:
user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
===================================================================
---
user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
(revision 10021)
+++
user/src/com/google/web/bindery/requestfactory/server/RequestFactoryJarExtractor.java
(working copy)
@@ -624,6 +624,11 @@
WriteOperation.class, RequestFactorySource.class,
SimpleEventBus.class
};
+ /**
+ * Maximum number of threads to use to run the Extractor.
+ */
+ private static final int MAX_THREADS = 1;
+
static {
List<Class<?>> sharedClasses = Arrays.<Class<?>>
asList(SHARED_CLASSES);
@@ -687,7 +692,7 @@
RequestFactoryJarExtractor extractor = new RequestFactoryJarExtractor(
errorContext, classLoader, jarEmitter, seeds, mode);
extractor.run();
- System.exit(0);
+ System.exit(extractor.isExecutionFailed() ? 1 : 0);
}
/**
@@ -742,6 +747,7 @@
private final Map<Type, Type> seen = new HashMap<Type, Type>();
private final Set<String> sources = new HashSet<String>();
private final ExecutorService writerService;
+ private boolean executionFailed = false;
public RequestFactoryJarExtractor(Logger logger, Loader loader,
Emitter emitter, List<Class<?>> seeds, Mode mode) {
@@ -751,7 +757,9 @@
this.seeds = seeds;
this.mode = mode;
- ex =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
+ // TODO(zundel): Currently fixed at one thread to avoid concurrency
issues.
+ int numThreads = Math.min(MAX_THREADS,
Runtime.getRuntime().availableProcessors());
+ ex = Executors.newFixedThreadPool(numThreads);
writerService = Executors.newSingleThreadExecutor();
}
@@ -770,6 +778,7 @@
} catch (InterruptedException retry) {
} catch (ExecutionException e) {
e.getCause().printStackTrace();
+ executionFailed = true;
}
}
emitter.close();
@@ -780,6 +789,10 @@
*/
private void emit(final State state) {
inProcess.add(writerService.submit(new EmitOneType(state)));
+ }
+
+ private boolean isExecutionFailed() {
+ return executionFailed;
}
/**
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors