Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-1894

Exception in URL Factory initialization

    XMLWordPrintable

Details

    Description

      When multiple thread are calling the xwiki URL factory service creation it's possible that one thread will throw a NPE:

      java.lang.NullPointerException
      	at com.xpn.xwiki.web.XWikiURLFactoryServiceImpl.createURLFactory(XWikiURLFactoryServiceImpl.java:81)
      	at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:108)
      	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      

      The reason is because the code does the following check:

          public XWikiURLFactoryService getURLFactoryService()
          {
              if (urlFactoryService == null) {
                  synchronized (URLFACTORY_SERVICE_LOCK) {
                      if (urlFactoryService == null) {
      

      but later the init is done is 2 steps: the creation of the object and its initilization:

      
      

      urlFactoryService =
      (XWikiURLFactoryService) Class.forName(urlFactoryServiceClass).newInstance();
      urlFactoryService.init(this);
      code}

      Thus it's possible that urlFactoryService isn't null but still isn't initialized.

      Attachments

        Issue Links

          Activity

            People

              vmassol Vincent Massol
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: