Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-27347

NPE on FileUtils#getResourcePathFromContext

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 8.10, 9.10, 10.10, 11.1
    • Fix Version/s: None
    • Component/s: Infrastructure

      Description

      We have a NullPointerException during integration testing. When getting the default thumbnail for document, an exception was thrown.

      ======================================================================
      = Component Loading Status: Pending: 0 / Missing: 0 / Unstarted: 0 / Total: 547
      ======================================================================
      2019-05-08T16:15:58,998 ERROR [http-nio-0.0.0.0-8080-exec-2] [org.nuxeo.ecm.webengine.app.WebEngineExceptionMapper] java.lang.NullPointerException
      java.lang.NullPointerException: null
      	at org.nuxeo.common.utils.FileUtils.getFilePathFromUrl(FileUtils.java:159) ~[nuxeo-common-10.10.jar:?]
      	at org.nuxeo.common.utils.FileUtils.getResourcePathFromContext(FileUtils.java:221) ~[nuxeo-common-10.10.jar:?]
      	at org.nuxeo.common.utils.FileUtils.getResourceFileFromContext(FileUtils.java:226) ~[nuxeo-common-10.10.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.factories.ThumbnailDocumentFactory.getDefaultThumbnail(ThumbnailDocumentFactory.java:117) ~[nuxeo-thumbnail-10.10.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.factories.ThumbnailDocumentFactory.getThumbnail(ThumbnailDocumentFactory.java:69) ~[nuxeo-thumbnail-10.10.jar:?]
      	at org.nuxeo.ecm.core.api.thumbnail.ThumbnailServiceImpl.getThumbnail(ThumbnailServiceImpl.java:93) ~[nuxeo-core-api-10.10.jar:?]
      	at org.nuxeo.ecm.platform.thumbnail.rendition.ThumbnailRenditionProvider.render(ThumbnailRenditionProvider.java:45) ~[nuxeo-thumbnail-10.10.jar:?]
      

      I believe this is caused by the side effect of method FileUtils#getResourceFileFromContext(String), because the resource returned by class loader is nullable. This is not considered by method getFilePathFromUrl(URL).

      org.nuxeo.common.utils.FileUtils.java
          /**
           * Retrieves the total path of a resource from the Thread Context.
           *
           * @param resource the resource name to be retrieved.
           * @return the decoded path.
           */
          public static String getResourcePathFromContext(String resource) {
              URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
              return getFilePathFromUrl(url);
          }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mhuang Mincong Huang
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 20 minutes
                20m