Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-7493

Analysis can fail if message of issue has multibyte characters (Oracle DB)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 6.6-M1, 6.6
    • Component/s: Database
    • Labels:

      Description

      Description
      An analysis raising an issue with a message that contains multibyte characters can fail if it persists data in an Oracle database. All analysis of this project will fail as long as the rule is activated in the Quality Profile.

      Error message is (full log in failure_log.txt ):

      2016.03.21 14:14:32 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVOZT5YAXTpILx_R_2g6
      org.apache.ibatis.exceptions.PersistenceException: 
      ### Error flushing statements.  Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.issue.IssueMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column
      
      ### Cause: org.apache.ibatis.executor.BatchExecutorException: org.sonar.db.issue.IssueMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column
      

      Details
      Column message in table issues is a varchar(4000). When persisting a new issue, SonarQube trims the issue message to 4000 characters (see this line introduced by this commit ). The thing is that for Oracle, varchar(4000) means 4000 bytes (for postgresql it's 4000 characters for example). So if a message contains multibyte characters, even if it's trimmed to 4000 characters, it can be longer than 4000 bytes and its insertion in an Oracle database will fail with the following error:

      ORA-01461: can bind a LONG value only for insert into a LONG column

      Reproducing

      • Apply long_message.patch to [https://github.com/SonarSource/sonar-examples|sonar-examples]
      • Build plugins/sonar-reference-plugin (or use sonar-reference-plugin-0.1-SNAPSHOT.jar attached)
      • Manually install the sonar-reference-plugin-0.1-SNAPSHOT.jar plugin on your SonarQube
      • Make sure your SonarQube is connected to an Oracle database, start SonarQube
      • In your default Java Quality Profile activate the Stupid Rule (java-example:ExampleRule1)
      • Analyse any Java project (Stupid Rule raises an issue on every Java file)
      • The background task will fail during persistence of data, with the error described above

        Attachments

        1. driver11_stack.txt
          3 kB
        2. driver12_stack.txt
          4 kB
        3. failure_log.txt
          33 kB
        4. length_1333.png
          length_1333.png
          757 kB
        5. long_message.patch
          20 kB
        6. sonar-reference-lts-plugin-0.1-SNAPSHOT.jar.zip
          21 kB
        7. sonar-reference-plugin-0.1-SNAPSHOT.jar
          286 kB

          Issue Links

            Activity

              People

              Assignee:
              simon.brandhof Simon Brandhof (Inactive)
              Reporter:
              nicolas.bontoux Nicolas Bontoux
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: