tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r749710 - in /tapestry/tapestry5/trunk/tapestry-ioc/src: main/java/org/apache/tapestry5/ioc/internal/services/ test/java/org/apache/tapestry5/ioc/internal/services/
Date Tue, 03 Mar 2009 19:38:10 GMT
Author: hlship
Date: Tue Mar  3 19:38:10 2009
New Revision: 749710

URL: http://svn.apache.org/viewvc?rev=749710&view=rev
Log:
On second thought, methods that throw checked exceptions are not elligable to be lazy, since
the checked exception needs to occur when the method is initially invoked, not when the returned
thunk is used.

Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImplTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyService.java

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java?rev=749710&r1=749709&r2=749710&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImpl.java
Tue Mar  3 19:38:10 2009
@@ -86,6 +86,11 @@
 
         if (!method.getReturnType().isInterface()) return false;
 
+        for (Class extype : method.getExceptionTypes())
+        {
+            if (!RuntimeException.class.isAssignableFrom(extype)) return false;
+        }
+
         return true;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImplTest.java?rev=749710&r1=749709&r2=749710&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyAdvisorImplTest.java
Tue Mar  3 19:38:10 2009
@@ -113,6 +113,25 @@
     }
 
     @Test
+    public void checked_exception_prevents_lazy() throws Exception
+    {
+        LazyService service = mockLazyService();
+        Greeter greeter = newMock(Greeter.class);
+
+        expect(service.notLazyCreateGreeter()).andReturn(greeter);
+
+        replay();
+
+        LazyService advised = advise(service);
+
+        Greeter actual = advised.notLazyCreateGreeter();
+
+        assertSame(actual, greeter);
+
+        verify();
+    }
+
+    @Test
     public void notlazy_annotation()
     {
         LazyService service = mockLazyService();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyService.java?rev=749710&r1=749709&r2=749710&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyService.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/LazyService.java
Tue Mar  3 19:38:10 2009
@@ -17,6 +17,8 @@
 import org.apache.tapestry5.ioc.Greeter;
 import org.apache.tapestry5.ioc.annotations.NotLazy;
 
+import java.sql.SQLException;
+
 /**
  * Used to test {@link org.apache.tapestry5.ioc.services.LazyAdvisor}, as it has a mix of
lazy and not lazy methods.
  */
@@ -35,4 +37,6 @@
 
     @NotLazy
     Greeter notLazyFromAnnotationGreeter();
+
+    Greeter notLazyCreateGreeter() throws SQLException;
 }



Mime
View raw message