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

Odd number of quotation marks in search query results in a Portlet is temporarily unavailable error

    Details

      Description

      Description
      If we include an odd number of quotation marks in the search portlet query by mistake, we receive Portlet is temporarily unavailable error.

      While it makes sense that we should not be using odd numbers of quotation marks (i.e. it's not a proper search query), it seems that Liferay should catch the invalid query, and have a more descriptive error message, instead of throwing a portlet unavailable error with a stack trace.

      Possible Use Case violation
      This behavior would effectively break a use case where a single quotation mark would be used to mark a unit of measurement such as " for inches, or ' for feet. E.g. Pants with 32" inseam or 6'8" basketball players

      Steps to Reproduce
      1. Start up a clean DXP SP6 bundle
      2. Search for the following "test"" (note the extra quotation mark)
      3. Press Enter/Return to search

      Actual Result
      We see a UI error Portlet is temporarily unavailable and the following stack trace:

      2017-12-01 07:50:47.187 ERROR [http-nio-8080-exec-9][render_portlet_jsp:131] nullExpected Result
      Swallow the stack trace, and display a friendly UI error indicating that the search contains an odd number of quotation marks.
      Reproduced in
      DXP + DE-32
      Master 7aa68abd5d9d511f98bf286cdf4b6e35bd29deb3
      7.0.x a957bda6e7ee422d947db6ad47d7002636068a4b
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.substring(String.java:1967)
      	at com.liferay.portal.kernel.util.StringUtil.unquote(StringUtil.java:4857)
      	at com.liferay.portal.search.internal.analysis.SubstringFieldQueryBuilder.createQuery(SubstringFieldQueryBuilder.java:56)
      	at com.liferay.portal.search.internal.analysis.SubstringFieldQueryBuilder.build(SubstringFieldQueryBuilder.java:48)
      	at com.liferay.portal.search.internal.query.FieldQueryFactoryImpl.createQuery(FieldQueryFactoryImpl.java:43)
      	at com.liferay.portal.kernel.search.query.FieldQueryFactoryUtil.createQuery(FieldQueryFactoryUtil.java:28)
      	at com.liferay.portal.kernel.search.generic.BooleanQueryImpl.addTerm(BooleanQueryImpl.java:345)
      	at com.liferay.portal.kernel.search.generic.BooleanQueryImpl.addTerm(BooleanQueryImpl.java:328)
      	at com.liferay.portal.kernel.search.BaseIndexer.addSearchTerm(BaseIndexer.java:1215)
      	at com.liferay.portal.kernel.search.BaseIndexer.addSearchLocalizedTerm(BaseIndexer.java:1153)
      	at com.liferay.portal.search.facet.internal.faceted.searcher.FacetedSearcherImpl.addSearchKeywords(FacetedSearcherImpl.java:132)
      	at com.liferay.portal.search.facet.internal.faceted.searcher.FacetedSearcherImpl.createFullQuery(FacetedSearcherImpl.java:163)
      	at com.liferay.portal.search.facet.internal.faceted.searcher.FacetedSearcherImpl.doSearch(FacetedSearcherImpl.java:258)
      	at com.liferay.portal.kernel.search.DefaultSearchResultPermissionFilter.getHits(DefaultSearchResultPermissionFilter.java:119)
      	at com.liferay.portal.kernel.search.BaseSearchResultPermissionFilter.search(BaseSearchResultPermissionFilter.java:94)
      	at com.liferay.portal.kernel.search.BaseIndexer.search(BaseIndexer.java:652)
      	at com.liferay.portal.search.web.internal.search.request.SearchRequestImpl.search(SearchRequestImpl.java:149)
      	at com.liferay.portal.search.web.internal.search.request.SearchRequestImpl.lambda$search$1(SearchRequestImpl.java:165)
      	at java.util.Optional.map(Optional.java:215)
      	at com.liferay.portal.search.web.internal.search.request.SearchRequestImpl.search(SearchRequestImpl.java:160)

      Expected Result
      no exception or warning throw, the letter string will be searched.
      Reproduced in
      DXP + DE-32
      Master 7aa68abd5d9d511f98bf286cdf4b6e35bd29deb3
      7.0.x a957bda6e7ee422d947db6ad47d7002636068a4b

        Attachments

          Activity

            People

            • Assignee:
              hong.zhao Hong Zhao
              Reporter:
              david.zhang David Zhang (Inactive)
              Participants of an Issue:
              Recent user:
              Csaba Turcsan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 47 weeks, 3 days ago

                Packages

                Version Package
                7.0.0 DXP FP34
                7.0.0 DXP SP7
                7.0.5 CE GA6
                7.0.X
                7.1.0 M1
                7.1.X
                Master