diff --git a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
index 8a0dba0797..30e45ae967 100644
--- a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
+++ b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
@@ -184,6 +184,7 @@ public final class AuthenticationHelper
session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user);
// Set the current locale
+ FacesHelper.getFacesContext(req, res, sc);
I18NUtil.setLocale(Application.getLanguage(req.getSession()));
// remove the session invalidated flag
@@ -331,6 +332,7 @@ public final class AuthenticationHelper
}
// Set the current locale
+ FacesHelper.getFacesContext(httpRequest, httpResponse, context);
I18NUtil.setLocale(Application.getLanguage(httpRequest.getSession()));
return AuthenticationStatus.Success;
diff --git a/source/java/org/alfresco/web/forms/XMLUtil.java b/source/java/org/alfresco/web/forms/XMLUtil.java
index e95713fa41..5d9ee6dd84 100644
--- a/source/java/org/alfresco/web/forms/XMLUtil.java
+++ b/source/java/org/alfresco/web/forms/XMLUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2007 Alfresco Software Limited.
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -49,11 +49,8 @@ import org.xml.sax.SAXException;
*/
public class XMLUtil
{
-
private static final Log LOGGER = LogFactory.getLog(XMLUtil.class);
- private static DocumentBuilder documentBuilder;
-
/** utility function for creating a document */
public static Document newDocument()
{
@@ -174,11 +171,7 @@ public class XMLUtil
/** provides a document builder that is namespace aware but not validating by default */
public static DocumentBuilder getDocumentBuilder()
{
- if (XMLUtil.documentBuilder == null)
- {
- XMLUtil.documentBuilder = XMLUtil.getDocumentBuilder(true, false);
- }
- return XMLUtil.documentBuilder;
+ return XMLUtil.getDocumentBuilder(true, false);
}
/**
diff --git a/source/java/org/alfresco/web/forms/XMLUtilTest.java b/source/java/org/alfresco/web/forms/XMLUtilTest.java
new file mode 100644
index 0000000000..8b3b9e6143
--- /dev/null
+++ b/source/java/org/alfresco/web/forms/XMLUtilTest.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.web.forms;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+/**
+ * Simple XMLUtil test
+ */
+public class XMLUtilTest extends TestCase
+{
+ public static final String SOME_XML =
+ " " +
+ " Test model one" +
+ " Alfresco" +
+ " 2008-01-01" +
+ " 1.0" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " Base" +
+ " The Base Type" +
+ " " +
+ " " +
+ " d:text" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " ";
+
+
+ private final static int threadCount = 5;
+
+ private final static int loopCount = 50;
+ private final static int randomNextInt = 100;
+
+ private Map errors = new HashMap();
+
+
+ protected void setUp() throws Exception
+ {
+ }
+
+ // https://issues.alfresco.com/browse/ETWOONE-241
+ public void testConcurrentParse()
+ {
+ ThreadGroup threadGroup = new ThreadGroup(getName());
+ Thread[] threads = new Thread[threadCount];
+
+ for (int i = 0; i < threadCount; i++)
+ {
+ threads[i] = new Thread(threadGroup, new TestRun(""+i), String.format("XMLUtilTest-%02d", i));
+ threads[i].start();
+ }
+
+ // join each thread so that we wait for them all to finish
+ for (int i = 0; i < threads.length; i++)
+ {
+ try
+ {
+ threads[i].join();
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ }
+
+ if (errors.size() != 0)
+ {
+ fail();
+ }
+ }
+
+ class TestRun extends Thread
+ {
+ private String arg;
+
+ public TestRun(String arg)
+ {
+ this.arg = arg;
+ }
+
+ public String getArg()
+ {
+ return arg;
+ }
+
+ public void run()
+ {
+ Random random = new Random(System.currentTimeMillis());
+
+ for (int i = 0; i < loopCount; i++)
+ {
+ try
+ {
+ XMLUtil.parse(SOME_XML); // ignore returned doc
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ errors.put(arg, t);
+ break;
+ }
+
+ // random delay ...
+ if (randomNextInt != 0)
+ {
+ int msecs = random.nextInt(randomNextInt);
+ try {Thread.sleep(msecs);} catch (Exception exception){};
+ }
+ }
+ }
+ }
+}