From: Tuukka Lehtonen Date: Thu, 10 Sep 2020 21:06:58 +0000 (+0300) Subject: Prevent leakage of OSGI service references X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=e336c755bb084fde3c26d711710b54b02ae423f5;p=simantics%2Fdistrict.git Prevent leakage of OSGI service references gitlab #95 Change-Id: I7dfa5f7f21664e248be73f60927b8e2b6eee294f (cherry picked from commit c3fe71cfddafe8288d9242f9c1eef98cf5c5ecd3) --- diff --git a/org.simantics.district.maps/src/org/simantics/maps/eclipse/EclipseProxyUtil.java b/org.simantics.district.maps/src/org/simantics/maps/eclipse/EclipseProxyUtil.java index 601a82f7..9e58c69d 100644 --- a/org.simantics.district.maps/src/org/simantics/maps/eclipse/EclipseProxyUtil.java +++ b/org.simantics.district.maps/src/org/simantics/maps/eclipse/EclipseProxyUtil.java @@ -42,13 +42,17 @@ public class EclipseProxyUtil implements IProxyUtil { return null; IProxyService service = bc.getService(ref); - if (service != null && service.isProxiesEnabled()) { - IProxyData proxyData = service.getProxyData(IProxyData.HTTP_PROXY_TYPE); - if (proxyData != null && proxyData.getHost() != null) { - return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyData.getHost(), proxyData.getPort())); + try { + if (service != null && service.isProxiesEnabled()) { + IProxyData proxyData = service.getProxyData(IProxyData.HTTP_PROXY_TYPE); + if (proxyData != null && proxyData.getHost() != null) { + return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyData.getHost(), proxyData.getPort())); + } } + return null; + } finally { + bc.ungetService(ref); } - return null; } }