You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/01/13 03:22:03 UTC
svn commit: r611526 - in
/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc:
internal/services/PerThreadServiceCreator.java
internal/services/ThreadCleanupHubImpl.java test/MockTester.java
Author: hlship
Date: Sat Jan 12 18:22:01 2008
New Revision: 611526
URL: http://svn.apache.org/viewvc?rev=611526&view=rev
Log:
TAPESTRY-2037: NullPointerException caused by many rapid page refreshes
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/PerThreadServiceCreator.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/test/MockTester.java
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/PerThreadServiceCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/PerThreadServiceCreator.java?rev=611526&r1=611525&r2=611526&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/PerThreadServiceCreator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/PerThreadServiceCreator.java Sat Jan 12 18:22:01 2008
@@ -1,17 +1,17 @@
-// Copyright 2006 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
+// Copyright 2006, 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
/**
*
*/
@@ -47,13 +47,13 @@
return _delegate.createObject();
}
- public Object createObject()
+ public synchronized Object createObject()
{
// Get (or create) the service.
return get();
}
- public void threadDidCleanup()
+ public synchronized void threadDidCleanup()
{
remove();
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java?rev=611526&r1=611525&r2=611526&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ThreadCleanupHubImpl.java Sat Jan 12 18:22:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -41,16 +41,15 @@
_logger = logger;
}
- public void addThreadCleanupListener(ThreadCleanupListener listener)
+ public synchronized void addThreadCleanupListener(ThreadCleanupListener listener)
{
_holder.get().add(listener);
}
/**
- * Instructs the hub to notify all its listeners (for the current thread). It also discards its
- * list of listeners.
+ * Instructs the hub to notify all its listeners (for the current thread). It also discards its list of listeners.
*/
- public void cleanup()
+ public synchronized void cleanup()
{
List<ThreadCleanupListener> listeners = _holder.get();
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/test/MockTester.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/test/MockTester.java?rev=611526&r1=611525&r2=611526&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/test/MockTester.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/test/MockTester.java Sat Jan 12 18:22:01 2008
@@ -18,10 +18,10 @@
import org.easymock.IMocksControl;
/**
- * Contains core logic used by {@link TestBase}, allowing for mock objects to be used outside of a
- * TestNG-based test suite. A <em>single</em> standard mock control is used for all mock
- * instances. The control does not care about execution order, but will balk at any unexpected
- * method invocations. This class is thread safe (it used a thread local to store the mock control).
+ * Contains core logic used by {@link TestBase}, allowing for mock objects to be used outside of a TestNG-based test
+ * suite. A <em>single</em> standard mock control is used for all mock instances. The control does not care about
+ * execution order, but will balk at any unexpected method invocations. This class is thread safe (it used a thread
+ * local to store the mock control).
*/
public final class MockTester
{
@@ -37,22 +37,21 @@
private final ThreadLocalControl _localControl = new ThreadLocalControl();
/**
- * Invoked after an individual unit test (i.e., a test method invocation) to discard the mock
- * control.
+ * Invoked after an individual unit test (i.e., a test method invocation) to discard the mock control.
*/
- public void cleanup()
+ public synchronized void cleanup()
{
_localControl.remove();
}
- public IMocksControl getMocksControl()
+ public synchronized IMocksControl getMocksControl()
{
return _localControl.get();
}
/**
- * Creates a new mock object of the indicated type. The shared mock control does <strong>not</strong>
- * check order, but does fail on any unexpected method invocations.
+ * Creates a new mock object of the indicated type. The shared mock control does <strong>not</strong> check order,
+ * but does fail on any unexpected method invocations.
*
* @param <T> the type of the mock object
* @param mockClass the class to mock
@@ -64,8 +63,8 @@
}
/**
- * Switches each mock object created by {@link #newMock(Class)} into replay mode (out of the
- * initial training mode).
+ * Switches each mock object created by {@link #newMock(Class)} into replay mode (out of the initial training
+ * mode).
*/
public void replay()
{
@@ -73,8 +72,8 @@
}
/**
- * Verifies that all trained methods have been invoked on all mock objects (created by
- * {@link #newMock(Class)}, then switches each mock object back to training mode.
+ * Verifies that all trained methods have been invoked on all mock objects (created by {@link #newMock(Class)}, then
+ * switches each mock object back to training mode.
*/
public void verify()
{