File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
core/play/src/main/java/play/mvc Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -373,7 +373,10 @@ default Long id() {
373373 * {@link Cell} to store the session cookie, to allow it to be evaluated on-demand.
374374 */
375375 default Session session () {
376- return attrs ().get (RequestAttrKey .Session ().asJava ()).value ().asJava ();
376+ return attrs ()
377+ .getOptional (RequestAttrKey .Session ().asJava ())
378+ .map (cell -> cell .value ().asJava ())
379+ .orElseGet (() -> new Session ());
377380 }
378381
379382 /**
@@ -382,7 +385,10 @@ default Session session() {
382385 * store the flash, to allow it to be evaluated on-demand.
383386 */
384387 default Flash flash () {
385- return attrs ().get (RequestAttrKey .Flash ().asJava ()).value ().asJava ();
388+ return attrs ()
389+ .getOptional (RequestAttrKey .Flash ().asJava ())
390+ .map (cell -> cell .value ().asJava ())
391+ .orElseGet (() -> new Flash ());
386392 }
387393
388394 /**
You can’t perform that action at this time.
0 commit comments