Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-59967

javax.portlet.BaseURL.setParameter with null value throws IllegalArgumentException instead of removing the parameter

    Details

      Description

      According to the javadoc for javax.portlet.BaseURL.setParameter(String name, String value):

      https://portals.apache.org/pluto/portlet-2.0-apidocs/javax/portlet/BaseURL.html

      A parameter value of null indicates that this parameter should be removed

      However, Liferay's implementation in PortletURLImpl, throws a NullPointerException:

      https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portlet/PortletURLImpl.java#L517

      @Override
      public void setParameter(String name, String value) {
      	setParameter(name, value, PropsValues.PORTLET_URL_APPEND_PARAMETERS);
      }
      
      @Override
      public void setParameter(String name, String value, boolean append) {
      	if ((name == null) || (value == null)) {
      		throw new IllegalArgumentException();
      	}
      
      	setParameter(name, new String[] {value}, append);
      }
      

      This issue has been previously reported (LPS-47554) but is not yet fixed.

      Steps to reproduce:

      1. Deploy the test-jsf-portlet.war in a clean bundle.
      2. Create a new page and add the test-jsf-menu portlet.
      3. Add the test-jsf-portlet to the page.
      4. Observe the IllegalArgumentException under the first '+' menu in the portlet:

      java.lang.IllegalArgumentException
      	at com.liferay.portlet.PortletURLImpl.setParameter(PortletURLImpl.java:550)
      	at com.liferay.portlet.PortletURLImpl.setParameter(PortletURLImpl.java:544)
      	at org.mitre.caasd.portlet.controller.Viz.buildUrl(Viz.java:43)
      	at org.mitre.caasd.portlet.controller.Viz.getExclusiveUrl(Viz.java:49)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
      	at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      	at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      	at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
      	at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
      	at com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:217)
      	at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:89)
      	at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
      	at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
      	at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
      	at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:847)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1819)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1822)
      	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1822)
      	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:447)
      	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
      	at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
      	at com.liferay.faces.bridge.application.internal.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:51)
      	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
      	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      	at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:257)
      	at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:98)
      	at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:135)
      	at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:258)
      	at org.mitre.caasd.portlet.faces.WindowStateRestoringGenericFacesPortlet.doView(WindowStateRestoringGenericFacesPortlet.java:110)
      	at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:359)
      	at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:207)
      	at javax.portlet.GenericPortlet.render(GenericPortlet.java:262)
      	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
      	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
      	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
      	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
      	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
      	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
      	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
      	at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:588)
      	at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:662)
      	at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:369)
      	at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1239)
      	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
      	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
      	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
      	at com.liferay.portlet.PortletContainerImpl._doRender(PortletContainerImpl.java:638)
      	at com.liferay.portlet.PortletContainerImpl.render(PortletContainerImpl.java:135)
      	at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:141)
      	at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:126)
      	at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:156)
      	at com.liferay.portal.action.RenderPortletAction.execute(RenderPortletAction.java:94)
      	at com.liferay.portal.action.UpdateLayoutAction.addPortlet(UpdateLayoutAction.java:318)
      	at com.liferay.portal.action.UpdateLayoutAction.getJSON(UpdateLayoutAction.java:270)
      	at com.liferay.portal.struts.JSONAction.execute(JSONAction.java:79)
      	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      	at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:168)
      	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      	at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:557)
      	at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:534)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:361)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:308)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:133)
      	at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:226)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
      	at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:57)
      	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
      	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)

      Expected Result:
      The test portlet should function without errors.

      Actual Result:
      The test portlet displays an IllegalArgumentException because com.liferay.portlet.PortletURLImpl.setParameter (String name, String value) is being called with value as null.

        Attachments

        1. fixed.png
          fixed.png
          10 kB
        2. reproduced.png
          reproduced.png
          13 kB
        3. test-jsf-portlet.war
          3.90 MB

          Issue Links

            Activity

              People

              Assignee:
              hong.zhao Hong Zhao
              Reporter:
              dustin.ryerson Dustin Ryerson (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 46 weeks ago

                  Packages

                  Version Package
                  6.1.X EE
                  6.2.X EE
                  7.0.0 Alpha 3