Committed by
Gerrit Code Review
Remove reference to a field of IntentManager from IntentWorker
Change-Id: I094c4019fbe8af342e2dae2a1c5ad780728cf27a
Showing
1 changed file
with
13 additions
and
11 deletions
... | @@ -285,7 +285,8 @@ public class IntentManager | ... | @@ -285,7 +285,8 @@ public class IntentManager |
285 | } | 285 | } |
286 | 286 | ||
287 | private Future<FinalIntentProcessPhase> submitIntentData(IntentData data) { | 287 | private Future<FinalIntentProcessPhase> submitIntentData(IntentData data) { |
288 | - return workerExecutor.submit(new IntentWorker(data)); | 288 | + IntentData current = store.getIntentData(data.key()); |
289 | + return workerExecutor.submit(new IntentWorker(data, current)); | ||
289 | } | 290 | } |
290 | 291 | ||
291 | private class IntentBatchPreprocess implements Runnable { | 292 | private class IntentBatchPreprocess implements Runnable { |
... | @@ -366,14 +367,16 @@ public class IntentManager | ... | @@ -366,14 +367,16 @@ public class IntentManager |
366 | private final class IntentWorker implements Callable<FinalIntentProcessPhase> { | 367 | private final class IntentWorker implements Callable<FinalIntentProcessPhase> { |
367 | 368 | ||
368 | private final IntentData data; | 369 | private final IntentData data; |
370 | + private final IntentData current; | ||
369 | 371 | ||
370 | - private IntentWorker(IntentData data) { | 372 | + private IntentWorker(IntentData data, IntentData current) { |
371 | - this.data = data; | 373 | + this.data = checkNotNull(data); |
374 | + this.current = current; | ||
372 | } | 375 | } |
373 | 376 | ||
374 | @Override | 377 | @Override |
375 | public FinalIntentProcessPhase call() throws Exception { | 378 | public FinalIntentProcessPhase call() throws Exception { |
376 | - IntentProcessPhase update = createIntentUpdate(data); | 379 | + IntentProcessPhase update = createIntentUpdate(); |
377 | Optional<IntentProcessPhase> currentPhase = Optional.of(update); | 380 | Optional<IntentProcessPhase> currentPhase = Optional.of(update); |
378 | IntentProcessPhase previousPhase = update; | 381 | IntentProcessPhase previousPhase = update; |
379 | 382 | ||
... | @@ -384,20 +387,19 @@ public class IntentManager | ... | @@ -384,20 +387,19 @@ public class IntentManager |
384 | return (FinalIntentProcessPhase) previousPhase; | 387 | return (FinalIntentProcessPhase) previousPhase; |
385 | } | 388 | } |
386 | 389 | ||
387 | - private IntentProcessPhase createIntentUpdate(IntentData intentData) { | 390 | + private IntentProcessPhase createIntentUpdate() { |
388 | - IntentData current = store.getIntentData(intentData.key()); | 391 | + switch (data.state()) { |
389 | - switch (intentData.state()) { | ||
390 | case INSTALL_REQ: | 392 | case INSTALL_REQ: |
391 | - return new InstallRequest(processor, intentData, Optional.ofNullable(current)); | 393 | + return new InstallRequest(processor, data, Optional.ofNullable(current)); |
392 | case WITHDRAW_REQ: | 394 | case WITHDRAW_REQ: |
393 | if (current == null || isNullOrEmpty(current.installables())) { | 395 | if (current == null || isNullOrEmpty(current.installables())) { |
394 | - return new Withdrawn(intentData, WITHDRAWN); | 396 | + return new Withdrawn(data, WITHDRAWN); |
395 | } else { | 397 | } else { |
396 | - return new WithdrawRequest(processor, intentData, current); | 398 | + return new WithdrawRequest(processor, data, current); |
397 | } | 399 | } |
398 | default: | 400 | default: |
399 | // illegal state | 401 | // illegal state |
400 | - return new CompilingFailed(intentData); | 402 | + return new CompilingFailed(data); |
401 | } | 403 | } |
402 | } | 404 | } |
403 | } | 405 | } | ... | ... |
-
Please register or login to post a comment