Introduce null-safety to Assets import result assembler

XMLWordPrintable

    • Type: Suggestion
    • Resolution: Unresolved
    • None
    • Component/s: Assets - Import
    • 1
    • 12

      Problem Definition

      We're coming across multiple {{NullPointerException}}s in Assets Import process assembler due to the code not being fully null-safe.

      Example:

      • JSDSERVER-15463
        • 2024-03-13 05:21:33,109+0000 insight-InsightThreadGroup-worker-thread-1814 ERROR jiraadmin     [c.r.j.p.i.s.analytics.service.ImportExportAnalyticsServiceImpl] Could not publish import result analytics
          java.lang.NullPointerException
                  at com.riadalabs.jira.plugins.insight.services.analytics.service.ImportExportAnalyticsServiceImpl.publishImportFinishedEvent(ImportExportAnalyticsServiceImpl.java:41)
                  at com.riadalabs.jira.plugins.insight.services.imports.common.DefaultImportService.finishProgress(DefaultImportService.java:1733)
                  at com.riadalabs.jira.plugins.insight.services.imports.common.DefaultImportService.doImportFromSource(DefaultImportService.java:873)
          
      • JSDSERVER-15678:
        • 2024-11-14 06:41:12,176+0000 http-nio-8080-exec-24 url: /jsm/rest/insight/1.0/progress/result/objectschema/2; user: admin ERROR admin 401x759x1 p8bdnl 172.29.187.89,172.50.0.3 /rest/insight/1.0/progress/result/objectschema/2 [c.r.j.p.i.c.w.a.r.exception.mapper.DefaultMapper] Unexpected exception was thrown while processing the request
          java.lang.NullPointerException: Cannot invoke "java.util.Date.toInstant()" because the return value of "com.riadalabs.jira.plugins.insight.services.imports.common.ImportResult.getStarted()" is null
          	at com.riadalabs.jira.plugins.insight.channel.web.api.rest.transformation.RestBeanAssemblerImpl.assembleImportResultEntry(RestBeanAssemblerImpl.java:599)
          	at com.riadalabs.jira.plugins.insight.channel.web.api.rest.services.progress.ProgressAssemblerInJira.assembleResultEntry(ProgressAssemblerInJira.java:42)
          	at com.riadalabs.jira.plugins.insight.channel.web.api.rest.services.progress.ProgressAssemblerBase.assembleProgressResultEntries(ProgressAssemblerBase.java:58)
          	at com.riadalabs.jira.plugins.insight.channel.web.api.rest.services.progress.ProgressResource.getAllProgressResultForObjectSchema(ProgressResource.java:341)
          

      And potentially more to come.

      Suggested Solution

      • Introduce null tests
      • Introduce null-safety to handle such NPEs more gracefully

            Assignee:
            Unassigned
            Reporter:
            Suddha
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: