Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-20228

Computed field properties are causing NPE in REST calls

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 14.8
    • REST
    • None
    • Unknown

    Description

      Steps to reproduce:
      1. Create a class XWiki.FooClass

      2. Add a property content of Computed Field type

      3. Add an XWiki.FooClass object to a page (Main.WebHome)

      4. Access the object with REST: 127.0.0.1:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome/objects/XWiki.FooClass/0

      Expected result: The object information should be displayed in an XML format like it does for 127.0.0.1:8080/xwiki/rest/wikis/xwiki/spaces/XWiki/pages/Admin/objects/XWiki.XWikiUsers/0
      Actual result:

      Oct 13, 2022 7:15:15 PM org.restlet.engine.application.StatusFilter doHandle
      WARNING: Exception or error caught by status service
      java.lang.NullPointerException
       at org.xwiki.rest.internal.ModelFactory.serializePropertyValue(ModelFactory.java:1047)
       at org.xwiki.rest.internal.ModelFactory.toRestObject(ModelFactory.java:364)
       at org.xwiki.rest.internal.resources.objects.ObjectResourceImpl.getObject(ObjectResourceImpl.java:67)
       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
       at org.restlet.ext.jaxrs.internal.wrappers.AbstractMethodWrapper.internalInvoke(AbstractMethodWrapper.java:162)
       at org.restlet.ext.jaxrs.internal.wrappers.ResourceMethod.invoke(ResourceMethod.java:281)
       at org.restlet.ext.jaxrs.JaxRsRestlet.invokeMethod(JaxRsRestlet.java:997)
       at org.restlet.ext.jaxrs.JaxRsRestlet.handle(JaxRsRestlet.java:746)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Router.doHandle(Router.java:422)
       at org.restlet.routing.Router.handle(Router.java:641)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
       at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:77)
       at org.restlet.Application.handle(Application.java:385)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Router.doHandle(Router.java:422)
       at org.restlet.routing.Router.handle(Router.java:641)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.routing.Router.doHandle(Router.java:422)
       at org.restlet.routing.Router.handle(Router.java:641)
       at org.restlet.routing.Filter.doHandle(Filter.java:150)
       at org.restlet.routing.Filter.handle(Filter.java:197)
       at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
       at org.restlet.Component.handle(Component.java:408)
       at org.restlet.Server.handle(Server.java:507)
       at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
       at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)
       at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1117)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
       at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1419)
       at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
       at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1624)
       at com.xpn.xwiki.web.XWikiContextInitializationFilter.doFilter(XWikiContextInitializationFilter.java:82)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.xwiki.container.servlet.filters.internal.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:208)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.xwiki.container.servlet.filters.internal.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:111)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:132)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:210)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:164)
       at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
       at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
       at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:506)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
       at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
       at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1571)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
       at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1378)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
       at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
       at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1544)
       at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
       at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1300)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
       at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
       at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:51)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
       at org.eclipse.jetty.server.Server.handle(Server.java:562)
       at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:418)
       at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:675)
       at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:410)
       at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
       at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
       at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
       at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
       at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
       at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
       at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
       at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:190)
       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
       at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
       at java.base/java.lang.Thread.run(Thread.java:829)

       Note: https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseCollection.java#L568 is not returning the computed field in the list of properties.

      Attachments

        Activity

          People

            Unassigned Unassigned
            acotiuga Alex Cotiugă
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: