From 3f40ab9b7f3e0718622fc8a3bd8f66afe421a3cc Mon Sep 17 00:00:00 2001 From: Radovan Synek Date: Sun, 23 Jun 2019 21:53:41 +0200 Subject: [PATCH] PLANNER-1540 Check if solver got lost from http session --- .../webexamples/cloudbalancing/CloudBalancingWebAction.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/optaplanner-webexamples/src/main/java/org/optaplanner/webexamples/cloudbalancing/CloudBalancingWebAction.java b/optaplanner-webexamples/src/main/java/org/optaplanner/webexamples/cloudbalancing/CloudBalancingWebAction.java index 69409af540..ab28d4006c 100644 --- a/optaplanner-webexamples/src/main/java/org/optaplanner/webexamples/cloudbalancing/CloudBalancingWebAction.java +++ b/optaplanner-webexamples/src/main/java/org/optaplanner/webexamples/cloudbalancing/CloudBalancingWebAction.java @@ -46,6 +46,11 @@ public void setup(HttpSession session) { public void solve(final HttpSession session) { final Solver solver = (Solver) session.getAttribute(CloudBalancingSessionAttributeName.SOLVER); + if (solver == null) { + throw new IllegalStateException("Solver (" + solver + ") cannot be null. As the Solver is not serializable, " + + "it might have got lost during a passivation."); + } + final CloudBalance unsolvedSolution = (CloudBalance) session.getAttribute(CloudBalancingSessionAttributeName.SHOWN_SOLUTION); solver.addEventListener(new SolverEventListener() {