felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1616445 - in /felix/sandbox/pderop/dependencymanager-prototype: org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
Date Thu, 07 Aug 2014 09:01:08 GMT
Author: pderop
Date: Thu Aug  7 09:01:08 2014
New Revision: 1616445

URL: http://svn.apache.org/r1616445
Log:
FELIX-4602: TemporalServiceDependency does not properly propagate RuntimeExceptions.

Modified:
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java
    felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java?rev=1616445&r1=1616444&r2=1616445&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm.itest/src/org/apache/felix/dm/itest/TemporalServiceDependencyTest.java
Thu Aug  7 09:01:08 2014
@@ -1,5 +1,7 @@
 package org.apache.felix.dm.itest;
 
+import java.util.Hashtable;
+
 import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.ServiceDependency;
@@ -74,6 +76,45 @@ public class TemporalServiceDependencyTe
         m.clear();
     }
 
+    public void testFelix4602_PropagateServiceInvocationException() {
+        DependencyManager m = new DependencyManager(context);
+        final Ensure ensure = new Ensure();
+        Runnable provider = new Runnable() {
+        	public void run() {
+        		throw new UncheckedException();
+        	}
+        };
+        Hashtable props = new Hashtable();
+        props.put("target", getClass().getSimpleName());
+        Component providerComp = m.createComponent()
+        		.setInterface(Runnable.class.getName(), props)
+        		.setImplementation(provider);
+
+        Object consumer = new Object() {
+        	volatile Runnable m_provider;
+        	void start() {
+        		try {
+        			ensure.step(1);
+        			m_provider.run();
+        		} catch (UncheckedException e) {
+        			ensure.step(2);
+        		}
+        	}
+        };
+        Component consumerComp = m.createComponent()
+        		.setImplementation(consumer)
+        		.add(m.createTemporalServiceDependency(5000)
+        				.setService(Runnable.class, "(target=" + getClass().getSimpleName() + ")")
+        				.setRequired(true));
+        m.add(consumerComp);
+        m.add(providerComp);
+        ensure.waitForStep(2, 5000);
+        m.clear();
+    }
+    
+    static class UncheckedException extends RuntimeException {    	
+    }
+
     static interface TemporalServiceInterface {
         public void invoke();
     }

Modified: felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java?rev=1616445&r1=1616444&r2=1616445&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager-prototype/org.apache.felix.dm/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
Thu Aug  7 09:01:08 2014
@@ -19,6 +19,7 @@
 package org.apache.felix.dm.impl;
 
 import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 
@@ -152,11 +153,14 @@ public class TemporalServiceDependencyIm
         }
         
         try {
-            return method.invoke(service, args);
-        }
-        catch (IllegalAccessException iae) {
-            method.setAccessible(true);
-            return method.invoke(service, args);
+			try {
+				return method.invoke(service, args);
+			} catch (IllegalAccessException iae) {
+				method.setAccessible(true);
+				return method.invoke(service, args);
+			}
+        } catch (InvocationTargetException e) {
+        	throw e.getTargetException();
         }
     }
 }



Mime
View raw message