diff --git a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java index 3830212254e7..f1efc8458f4a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/jdi/VirtualMachineProxyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -383,14 +383,15 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy { catch (UnsupportedOperationException e) { LOG.info(e); } - - if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { - // Memory leak workaround, see IDEA-163334 - TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); - if (target != null) { - Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); - if (controller != null) { - controller.stop(); + finally { + if (Patches.JDK_BUG_EVENT_CONTROLLER_LEAK) { + // Memory leak workaround, see IDEA-163334 + TargetVM target = ReflectionUtil.getField(myVirtualMachine.getClass(), myVirtualMachine, TargetVM.class, "target"); + if (target != null) { + Thread controller = ReflectionUtil.getField(target.getClass(), target, Thread.class, "eventController"); + if (controller != null) { + controller.stop(); + } } } }