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

DB2 throws a System Exception when calling a SELECT Query on an object while searching for a name greater than the supported length in the DB table

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: Master
    • Fix Version/s: Master
    • Component/s: WCM
    • Labels:
      None

      Description

      Description

      java.lang.Exception: Unexpected exception, expected<com.liferay.asset.kernel.exception.AssetTagException> but was<com.liferay.portal.kernel.exception.SystemException>
      ...
      Caused by: com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.DataException: could not execute query
      	at com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:443)
      	at com.liferay.portlet.asset.service.persistence.impl.AssetTagPersistenceImpl.fetchByG_N(AssetTagPersistenceImpl.java:3226)
      	at com.liferay.portlet.asset.service.persistence.impl.AssetTagPersistenceImpl.fetchByG_N(AssetTagPersistenceImpl.java:3138)
      	at com.liferay.portlet.asset.service.impl.AssetTagLocalServiceImpl.fetchTag(AssetTagLocalServiceImpl.java:272)
      	at com.liferay.portlet.asset.service.impl.AssetTagLocalServiceImpl.hasTag(AssetTagLocalServiceImpl.java:588)
      	at com.liferay.portlet.asset.service.impl.AssetTagLocalServiceImpl.addTag(AssetTagLocalServiceImpl.java:107)
      

      In DB2, unlike other Databases, it will throw a System Exception by denying the query if you try to perform a SELECT statement on an object who has a field who exceeds the DB supported length.

      This affects AssetTagLocalService.addTag(...) because we validate the name AFTER we check for duplicate tags (performs a fetch). We should validate the name first so we don't execute a DB query on a bad name, to improve both performance and stability.

      Steps to Reproduce

      1. Start up Portal with DB2 (or just run ci:test:backend and check axis results after)
      2. Run com.liferay.asset.service.test.AssetTagLocalServiceTest.testIncrementAssetCountWithAssetTagNameGreaterThan75

      Expected Result
      Integration test passes

      Actual Result
      Integration test fails

      Tested on Tomcat 9.0.17 + MySQL 5.7
      Portal master GIT ID: a7ff73bbb703d103da1af3609b56e2693fa2356a

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kyle.miho Kyle Miho
                Reporter:
                kyle.miho Kyle Miho
                Participants of an Issue:
                Recent user:
                Kyle Miho
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 weeks, 1 day ago