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

JournalArticleLocalServiceUtil#updateArticle causes NullPointerException

    Details

      Description

      In case the journal article's structure contains an 'Image' field, the following method will throw NullPointerException:

      JournalArticleLocalServiceUtil#updateArticle(long userId, long groupId, String articleId, double version, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, String content, String layoutUuid, ServiceContext serviceContext)

      That's, because the
      JournalArticleLocalServiceImpl#updateArticle (which does not have "images" Map<String,byte[]> argument) calls the other

      JournalArticleLocalServiceImpl#updateArticle method with null value as images map.

      This null value is not checked in
      JournalArticleLocalServiceImpl#formatImage (line 3030)
      and throws a NullPointerException.

      I'm affraid this issue is present in version 6.2 too (I had just a quick look and the method call is similar:
      http://docs.huihoo.com/javadoc/liferay/6.2.0/javadocs-all/src-html/com/liferay/portlet/journal/service/impl/JournalArticleLocalServiceImpl.html#line.2024

      http://docs.huihoo.com/javadoc/liferay/6.2.0/javadocs-all/src-html/com/liferay/portlet/journal/service/impl/JournalArticleLocalServiceImpl.html#line.2986

      ).

      Line 3030: byte[] bytes = images.get(elInstanceId + "_" + elName + elLanguage);

      The exception:
      Caused by: java.lang.NullPointerException
      at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.formatImage(JournalArticleLocalServiceImpl.java:3030)
      at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.format(JournalArticleLocalServiceImpl.java:2895)
      at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.format(JournalArticleLocalServiceImpl.java:2947)
      at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.updateArticle(JournalArticleLocalServiceImpl.java:2190)
      at sun.reflect.GeneratedMethodAccessor2118.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        Attachments

        1. reproduced.png
          reproduced.png
          168 kB
        2. fixed.png
          fixed.png
          144 kB

          Issue Links

            Activity

              People

              • Assignee:
                hong.zhao Hong Zhao
                Reporter:
                karbert Norbert Kandó
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 19 weeks, 3 days ago

                  Packages

                  Version Package
                  6.2.X EE
                  7.0.0 M1