diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java index 48444774b1..6516e885c9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java @@ -348,7 +348,7 @@ public int getResultCount() { /** * Increment the result count by one. */ - public void incrementResultCount() { + private void incrementResultCount() { this.resultCount++; } } @@ -460,17 +460,20 @@ public static > WmiResult queryWMI(WmiQuery query, int t IWbemServices svc = connectServer(query.getNameSpace()); // Send query - IEnumWbemClassObject enumerator = selectProperties(svc, query); - try { - return enumerateProperties(enumerator, query.getPropertyEnum(), timeout); - } catch (TimeoutException e) { - throw new TimeoutException(e.getMessage()); + IEnumWbemClassObject enumerator = selectProperties(svc, query); + + try { + return enumerateProperties(enumerator, query.getPropertyEnum(), timeout); + } finally { + // Cleanup + enumerator.Release(); + } } finally { // Cleanup - enumerator.Release(); svc.Release(); } + } /* @@ -560,7 +563,6 @@ public static > IEnumWbemClassObject selectProperties(IWbemSer OleAuto.INSTANCE.SysFreeString(queryStr); OleAuto.INSTANCE.SysFreeString(wql); if (COMUtils.FAILED(hres)) { - svc.Release(); throw new COMException(String.format("Query '%s' failed.", sb.toString()), hres); } return new IEnumWbemClassObject(pEnumerator.getValue());