Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4492

NPE when no label is specified on <f:selectItem/>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.15, 2.3.10, 2.3-next-M7, 3.0.2, 4.0.0-RC2
    • 2.3.11, 3.0.3, 2.3-next-M8, 2.2.16, 4.0.0-RC3
    • General
    • None

    Description

      TCK Test failure information:

      faces23/uiinput:

      Background: https://github.com/eclipse-ee4j/mojarra/issues/4734

      App: https://github.com/jakartaee/faces/blob/4.0.1/tck/faces23/uiinput/src/main/webapp/issue4734.xhtml

      Test: https://github.com/jakartaee/faces/blob/4.0.1/tck/faces23/uiinput/src/test/java/ee/jakarta/tck/faces/test/javaee8/uiinput/Issue4734IT.java#L38

      The above test fails on MyFaces with the following Exception:

       

      jakarta.servlet.ServletException: label is null.
          at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:255)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1258)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:746)
          at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:193)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:98)
          at com.ibm.ws.security.jaspi.JaspiServletFilter.doFilter(JaspiServletFilter.java:56)
          at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:201)
          at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:1002)
          at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1140)
          at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5058)
          at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:316)
          at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
          at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:281)
          at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1239)
          at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:468)
          at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:427)
          at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:566)
          at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:500)
          at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:360)
          at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:327)
          at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:167)
          at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:75)
          at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:514)
          at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:584)
          at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:968)
          at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1057)
          at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:245)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:866)
      Caused by: java.lang.NullPointerException: label is null.
          at org.apache.myfaces.core.api.shared.lang.Assert.notNull(Assert.java:35)
          at jakarta.faces.model.SelectItem.setLabel(SelectItem.java:145)
          at org.apache.myfaces.core.api.shared.SelectItemsUtil.createSelectItem(SelectItemsUtil.java:61)
          at org.apache.myfaces.core.api.shared.SelectItemsIterator.hasNext(SelectItemsIterator.java:108)
          at org.apache.myfaces.renderkit.html.util.SelectItemsUtils.getSelectItemInfoList(SelectItemsUtils.java:59)
          at org.apache.myfaces.renderkit.html.base.HtmlSelectableRendererBase.internalRenderSelect(HtmlSelectableRendererBase.java:70)
          at org.apache.myfaces.renderkit.html.base.HtmlMenuRendererBase.renderMenu(HtmlMenuRendererBase.java:86)
          at org.apache.myfaces.renderkit.html.base.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:74)
          at jakarta.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:634)
          at jakarta.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:523)
          at jakarta.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:519)
          at jakarta.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:519)
          at jakarta.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:519)
          at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1779)
          at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:316)
          at jakarta.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:74)
          at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:122)
          at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
          at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
          ... 31 more
      
      

       

      The API does not allow an NPE  to be thrown when there is no label: https://jakarta.ee/specifications/faces/4.0/apidocs/jakarta/faces/model/selectitem#setLabel(java.lang.String)

      I think the best solution here is to just write out an empty String if the label is null rather than throwing an NPE when setting the label.

      This behavior has been like this for a long time, so I'm hesitant to apply it to earlier releases, but we need it for Faces 4.0 to pass the latest TCK.

      Thoughts on changing this in earlier releases? volosied tandraschko melloware 

      Attachments

        Activity

          People

            paul.nicolucci Paul Nicolucci
            paul.nicolucci Paul Nicolucci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: