Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2018-03-14 13:32:30 -0400
committerslewis2018-03-14 13:32:30 -0400
commiteca50a8929df30b12b3dfc826e59a73fbe5f07a2 (patch)
treee9e13cfd7cdb4ae7e5ba07490f41c9f3bc19cd41 /providers/bundles
parent753d3e198879042afa1be6547dee5f557c22b36c (diff)
downloadorg.eclipse.ecf-eca50a8929df30b12b3dfc826e59a73fbe5f07a2.tar.gz
org.eclipse.ecf-eca50a8929df30b12b3dfc826e59a73fbe5f07a2.tar.xz
org.eclipse.ecf-eca50a8929df30b12b3dfc826e59a73fbe5f07a2.zip
Additional fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Change-Id: I0000000000000000000000000000000000000000
Diffstat (limited to 'providers/bundles')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiContainerInstantiator.java4
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java60
3 files changed, 62 insertions, 5 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiContainerInstantiator.java b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiContainerInstantiator.java
index 2727faa05..23a13b6da 100644
--- a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiContainerInstantiator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/R_OSGiContainerInstantiator.java
@@ -46,7 +46,9 @@ public final class R_OSGiContainerInstantiator implements IContainerInstantiator
final boolean useHostname = Boolean.valueOf(System.getProperty("org.eclipse.ecf.provider.r_osgi.useHostName", "true")).booleanValue(); //$NON-NLS-1$ //$NON-NLS-2$
private R_OSGiID createROSGiID(ContainerTypeDescription description, Map properties) throws ContainerCreateException {
- String idStr = (String) properties.get(ID_PROP);
+ String idStr = null;
+ if (properties != null)
+ idStr = (String) properties.get(ID_PROP);
String hostname = null;
if (idStr != null) {
try {
diff --git a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
index 0e05ded28..24ce1cc01 100644
--- a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
@@ -141,8 +141,7 @@ final class RemoteServiceImpl extends AbstractRemoteService {
} catch (OperationCanceledException e) {
throw new ECFException("callSync cancelled", e); //$NON-NLS-1$
} catch (InterruptedException e) {
- // If thread interrupted, then just return null
- return null;
+ throw new ECFException("callSync interrupted ", e); //$NON-NLS-1$
} catch (TimeoutException e) {
throw new ECFException("callSync timed out after " + Long.toString(call.getTimeout()) + "ms", new TimeoutException(call.getTimeout())); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
index 7a4de9b3f..8202abdb6 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
@@ -8,8 +8,12 @@
******************************************************************************/
package org.eclipse.ecf.provider.remoteservice.generic;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.remoteservice.*;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent;
public class RemoteServiceImpl extends AbstractRemoteService {
@@ -39,8 +43,60 @@ public class RemoteServiceImpl extends AbstractRemoteService {
* @since 3.0
* @see org.eclipse.ecf.remoteservice.IRemoteService#callAsync(org.eclipse.ecf.remoteservice.IRemoteCall, org.eclipse.ecf.remoteservice.IRemoteCallListener)
*/
- public void callAsync(IRemoteCall call, IRemoteCallListener listener) {
- sharedObject.sendCallRequestWithListener(registration, call, listener);
+ public void callAsync(final IRemoteCall call, final IRemoteCallListener listener) {
+ getFutureExecutorService(call).submit(new Runnable() {
+ public void run() {
+ final AtomicReference<IRemoteCallEvent> l = new AtomicReference<IRemoteCallEvent>();
+ sharedObject.sendCallRequestWithListener(registration, call, new IRemoteCallListener() {
+ public void handleEvent(IRemoteCallEvent event) {
+ if (event instanceof IRemoteCallCompleteEvent) {
+ synchronized (l) {
+ l.set(event);
+ l.notify();
+ }
+ }
+ }
+ });
+ long timeout = call.getTimeout();
+ Exception exception = null;
+ IRemoteCallEvent rce = null;
+ long sysTimeout = System.currentTimeMillis() + timeout;
+ synchronized (l) {
+ try {
+ while (rce == null && System.currentTimeMillis() < sysTimeout) {
+ l.wait(timeout / 10);
+ rce = l.get();
+ }
+ } catch (InterruptedException e) {
+ exception = e;
+ }
+ }
+ if (rce != null)
+ listener.handleEvent(rce);
+ else {
+ if (exception == null)
+ exception = new TimeoutException("remote call method=" + call.getMethod() + " timed out after " + timeout + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ final Exception except = exception;
+ listener.handleEvent(new IRemoteCallCompleteEvent() {
+ public long getRequestId() {
+ return 0;
+ }
+
+ public Object getResponse() {
+ return null;
+ }
+
+ public boolean hadException() {
+ return true;
+ }
+
+ public Throwable getException() {
+ return except;
+ }
+ });
+ }
+ }
+ });
}
/**

Back to the top