mirror of
https://github.com/google/nomulus.git
synced 2025-07-06 19:23:31 +02:00
Remove Pipeline as a field in pipeline classes (#1119)
In tests we use a TestPipelineExtension which does some static initialization that should not be repeated the same JVM. In our XXXPipeline classes we save the pipeline as a field and usually write lambdas that are pass to the pipeline. Because lambdas are effectively anonymous inner classes they are bound to their enclosing instances. When they get serialized during pipeline execution, their enclosing classes also do. This might result in undefined behavior when multiple lambdas in the same XXXPipeline are used on the same JVM (such as in tests) where the static initialization may be done multiple times if different class loaders are used. This is very unlikely to happen but as a best practice we still remove them as fields.
This commit is contained in:
parent
431710c95b
commit
eb6a1fe1ed
6 changed files with 22 additions and 43 deletions
|
@ -52,7 +52,7 @@ class InitSqlPipelineGraphTest {
|
|||
|
||||
@Test
|
||||
void createPipeline_compareGraph() throws IOException {
|
||||
new InitSqlPipeline(options, testPipeline).setupPipeline();
|
||||
new InitSqlPipeline(options).setupPipeline(testPipeline);
|
||||
String dotString = PipelineDotRenderer.toDotString(testPipeline);
|
||||
URL goldenDotUrl = Resources.getResource(InitSqlPipelineGraphTest.class, GOLDEN_DOT_FILE);
|
||||
File outputFile = new File(new File(goldenDotUrl.getFile()).getParent(), "pipeline_curr.dot");
|
||||
|
|
|
@ -317,8 +317,8 @@ class InitSqlPipelineTest {
|
|||
"--commitLogDir=" + commitLogDir.getAbsolutePath())
|
||||
.withValidation()
|
||||
.as(InitSqlPipelineOptions.class);
|
||||
InitSqlPipeline initSqlPipeline = new InitSqlPipeline(options, testPipeline);
|
||||
initSqlPipeline.run().waitUntilFinish();
|
||||
InitSqlPipeline initSqlPipeline = new InitSqlPipeline(options);
|
||||
initSqlPipeline.run(testPipeline).waitUntilFinish();
|
||||
try (AppEngineEnvironment env = new AppEngineEnvironment("test")) {
|
||||
assertHostResourceEquals(
|
||||
jpaTm().transact(() -> jpaTm().loadByKey(hostResource.createVKey())), hostResource);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue