Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-5345

NPE when setting HistoryLevel to "Activity" in SpringProcessEngineConfiguration

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: L3 - Default
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.6.0, 7.5.4, 7.6.0-alpha3, 7.4.10
    • Component/s: engine
    • Labels:
      None

      Description

      In our Spring Application, when creating the ProcessEngineConfiguration, we are setting the HistoryLevel to Activity. Looks like this:

      @Bean
          public SpringProcessEngineConfiguration processEngineConfiguration() {
               ...
              final SpringProcessEngineConfiguration pec = new SpringProcessEngineConfiguration();
               ...
              pec.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_ACTIVITY);
               ...
              return pec;
          }
      

      When we start our application, we're getting this NPE:

      Caused by: java.lang.NullPointerException at org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd.execute(DetermineHistoryLevelCmd.java:30) at org.camunda.bpm.engine.impl.SchemaOperationsProcessEngineBuild.checkHistoryLevel(SchemaOperationsProcessEngineBuild.java:97)
      

      It happens here in DetermineHistoricLevelCmd.java when the loop accesses the historyLevels variable:

      if (databaseHistoryLevel != null) {
            for (final HistoryLevel historyLevel : historyLevels) {
              if (historyLevel.getId() == databaseHistoryLevel) {
                result = historyLevel;
                break;
              }
            }
      

      We think this happens because of this code in ProcessEngineConfigurationImpl.java :

      public void initHistoryLevel() {
      if(historyLevel == null) {
            if(historyLevels == null) {
              historyLevels = new ArrayList<HistoryLevel>();
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_NONE);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_ACTIVITY);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_AUDIT);
              historyLevels.add(HistoryLevel.HISTORY_LEVEL_FULL);
            }
      

      historyLevels is only ever initialized when historyLevel is null - but in our case, historyLevel is already set to Activity, so historyLevels stays null, which causes the NPE. This happens since 7.4.

        Activity

        Hide
        jan.galinski@holisticon.de Jan Galinski added a comment -
        Show
        jan.galinski@holisticon.de Jan Galinski added a comment - I suggested a fix, see https://github.com/camunda/camunda-bpm-platform/pull/235
        Show
        meyer Daniel Meyer added a comment - Tests added by this commit seem to pass if run individually but fail if whole testsuite is run: https://github.com/camunda/camunda-bpm-platform/commit/47da555aa3ac1f400a3e3b7809cf624df42e833e https://hq2.camunda.com/jenkins/ci/job/7.6-engine-UNIT-h2/lastCompletedBuild/testReport/org.camunda.bpm.engine.test.api.cfg/HistoryLevelTest/shouldInitHistoryLevelByObject/

          People

          • Assignee:
            Unassigned
            Reporter:
            dietl@nbsp.de Matthias Dietl
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development