This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 4ac4b3a28e1e4166e3e37073985361282848f076
Author: Dan Haywood <[email protected]>
AuthorDate: Fri Nov 4 11:42:53 2022 +0000

    ISIS-3267: fixes compile issue
---
 .../wrapper/WrapperFactoryDefault.java             | 31 +++++++++++++---------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git 
a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/wrapper/WrapperFactoryDefault.java
 
b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/wrapper/WrapperFactoryDefault.java
index c3a01281ed..7e9ec26b4b 100644
--- 
a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/wrapper/WrapperFactoryDefault.java
+++ 
b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/wrapper/WrapperFactoryDefault.java
@@ -30,6 +30,7 @@ import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.function.BiConsumer;
+import java.util.function.Function;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.Priority;
@@ -37,6 +38,7 @@ import javax.inject.Inject;
 import javax.inject.Named;
 import javax.inject.Provider;
 
+import org.apache.causeway.commons.functional.Try;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -641,20 +643,23 @@ implements WrapperFactory, HasMetaModelContext {
         val childCommand = 
interactionProviderProvider.get().currentInteractionElseFail().getCommand();
         
childCommand.updater().setParentInteractionId(asyncCallable.getParentInteractionId());
 
-        val bookmark = commandExecutorServiceProvider.get()
+        val tryBookmark = commandExecutorServiceProvider.get()
                 .executeCommand(asyncCallable.getCommandDto(), 
childCommand.updater());
-        if (bookmark == null) {
-            return null;
-        }
-        val spec = 
getSpecificationLoader().specForBookmark(bookmark).orElse(null);
-        if(spec==null) {
-            return null;
-        }
-        R domainObject = bookmarkServiceProvider.get().lookup(bookmark, 
asyncCallable.getReturnType()).orElse(null);
-        if(spec.isEntity()) {
-            domainObject = 
repositoryServiceProvider.get().detach(domainObject);
-        }
-        return domainObject;
+
+        return tryBookmark.fold(
+                throwable -> null,                  // failure
+                bookmarkIfAny -> bookmarkIfAny.map( // success
+                    bookmark -> {
+                        val spec = 
getSpecificationLoader().specForBookmark(bookmark).orElse(null);
+                        if(spec==null) {
+                            return null;
+                        }
+                        R domainObject = 
bookmarkServiceProvider.get().lookup(bookmark, 
asyncCallable.getReturnType()).orElse(null);
+                        if(spec.isEntity()) {
+                            domainObject = 
repositoryServiceProvider.get().detach(domainObject);
+                        }
+                        return domainObject;
+                    }).orElse(null));
     }
 
 }

Reply via email to