You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2019/01/04 09:35:00 UTC
[jira] [Commented] (ISIS-2066) Invoking an action that returns null
results in an NPE ... eg HelloWorldObject#delete().
[ https://issues.apache.org/jira/browse/ISIS-2066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16733974#comment-16733974 ]
ASF subversion and git services commented on ISIS-2066:
-------------------------------------------------------
Commit 51f9408a54f79df5986631106ce89d0c203eed0c in isis's branch refs/heads/v2 from danhaywood
[ https://gitbox.apache.org/repos/asf?p=isis.git;h=51f9408 ]
ISIS-2066: fixes NPE occurring when invoke an action that returns null
fix as per the idiom described here: https://stackoverflow.com/a/32476601/56880
> Invoking an action that returns null results in an NPE ... eg HelloWorldObject#delete().
> ----------------------------------------------------------------------------------------
>
> Key: ISIS-2066
> URL: https://issues.apache.org/jira/browse/ISIS-2066
> Project: Isis
> Issue Type: Bug
> Reporter: Dan Haywood
> Assignee: Dan Haywood
> Priority: Major
> Fix For: 2.0.0-M2
>
>
> this stackt trace:
> {code:java}
> Stack trace:
> java.lang.NullPointerException
> java.util.Objects#requireNonNull(Objects.java:203)
> java.util.Optional#<init>(Optional.java:96)
> java.util.Optional#of(Optional.java:108)
> java.util.stream.FindOps$FindSink$OfRef#get(FindOps.java:193)
> java.util.stream.FindOps$FindSink$OfRef#get(FindOps.java:190)
> java.util.stream.FindOps$FindOp#evaluateSequential(FindOps.java:152)
> java.util.stream.AbstractPipeline#evaluate(AbstractPipeline.java:234)
> java.util.stream.ReferencePipeline#findFirst(ReferencePipeline.java:464)
> org.apache.isis.viewer.wicket.model.models.ActionModel#executeAction(ActionModel.java:474){code}
>
> which results from this code:
> {code:java}
> return routingServices
> .filter(routingService->routingService.canRoute(result))
> .map(routingService->{
> final Object routeTo = routingService.route(result);
> return routeTo != null? getPersistenceSession().adapterFor(routeTo): null;
> })
> .findFirst()
> .orElse(resultAdapter);
> {code}
>
> This isn't quite equivalent to the code in 1.16.x:
> {code:java}
> final Object result = resultAdapter != null ? resultAdapter.getObject() : null;
> for (RoutingService routingService : routingServices) {
> final boolean canRoute = routingService.canRoute(result);
> if(canRoute) {
> final Object routeTo = routingService.route(result);
> return routeTo != null? getPersistenceSession().adapterFor(routeTo): null;
> }
> }
> return resultAdapter;
> {code}
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)