From 5fd9f9ca64e6efa7af69b3d8e7c8ef708436cce0 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Fri, 11 Sep 2020 00:06:58 +0300 Subject: [PATCH] Prevent leakage of OSGI service references gitlab #95 Change-Id: I7dfa5f7f21664e248be73f60927b8e2b6eee294f (cherry picked from commit c3fe71cfddafe8288d9242f9c1eef98cf5c5ecd3) --- .../simantics/maps/eclipse/EclipseProxyUtil.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; } } -- 2.47.1