diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF index 2466065496e..d5c0f4c0546 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/META-INF/MANIFEST.MF @@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.dsf.gdb, org.eclipse.core.variables, org.mockito, - org.hamcrest + org.hamcrest.library Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ClassPath: . diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java index ca9f8681d9a..981cdf223cc 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java @@ -2945,10 +2945,8 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { IExpressionDMAddress addr = (IExpressionDMAddress) wait.getReturnInfo(); assertTrue("Unable to get address", addr != null); - if (addr != null) { - assertTrue("Received wrong address of " + addr.toString() + " instead of (" + actualAddrStr + ", " - + actualAddrSize + ")", addressesEqual(addr, actualAddrStr, actualAddrSize)); - } + assertTrue("Received wrong address of " + addr.toString() + " instead of (" + actualAddrStr + ", " + + actualAddrSize + ")", addressesEqual(addr, actualAddrStr, actualAddrSize)); } private void doTestChildren(IExpressionDMContext exprDMC) throws Throwable { diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIModifiedServicesTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIModifiedServicesTest.java index 57da9731567..5eed2202d2f 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIModifiedServicesTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIModifiedServicesTest.java @@ -133,42 +133,36 @@ public class MIModifiedServicesTest extends BaseParametrizedTestCase { // that is relative to the working directory. File file = new File(EXEC_PATH + EXEC_NAME); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); + try (FileInputStream fis = new FileInputStream(file);) { + + final String MATCH = "cygwin1.dll"; + final int MATCH_LEN = MATCH.length(); + int i = 0; + int ch = 0; + while (true) { + try { + ch = fis.read(); + } catch (IOException e) { + Assert.fail("Problem inspecting file to see if it's a cygwin executable : " + + e.getLocalizedMessage()); + } + if (ch == -1) { // EOF + break; + } + if (ch == MATCH.charAt(i)) { + if (i == MATCH_LEN - 1) { + break; // found it! + } + i++; + } else { + i = 0; + } + } } catch (FileNotFoundException e) { Assert.fail(e.getLocalizedMessage()); - return; // needed to avoid warning at fis usage below - } - - final String MATCH = "cygwin1.dll"; - final int MATCH_LEN = MATCH.length(); - int i = 0; - int ch = 0; - while (true) { - try { - ch = fis.read(); - } catch (IOException e) { - Assert.fail( - "Problem inspecting file to see if it's a cygwin executable : " + e.getLocalizedMessage()); - } - if (ch == -1) { // EOF - break; - } - if (ch == MATCH.charAt(i)) { - if (i == MATCH_LEN - 1) { - break; // found it! - } - i++; - } else { - i = 0; - } - } - if (fis != null) { - try { - fis.close(); - } catch (IOException e) { - } + return; // needed to avoid warning at fis usage + } catch (IOException e) { + //ignore } } } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java index 3cc2906ead5..776c7376471 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java @@ -152,43 +152,36 @@ public class MIRunControlTest extends BaseParametrizedTestCase { // that is relative to the working directory. File file = new File(EXEC_PATH + EXEC_NAME); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); + try (FileInputStream fis = new FileInputStream(file);) { + final String MATCH = "cygwin1.dll"; + final int MATCH_LEN = MATCH.length(); + int i = 0; + int ch = 0; + while (true) { + try { + ch = fis.read(); + } catch (IOException e) { + Assert.fail("Problem inspecting file to see if it's a cygwin executable : " + + e.getLocalizedMessage()); + } + if (ch == -1) { // EOF + break; + } + if (ch == MATCH.charAt(i)) { + if (i == MATCH_LEN - 1) { + sProgramIsCygwin = true; + break; // found it! + } + i++; + } else { + i = 0; + } + } } catch (FileNotFoundException e) { Assert.fail(e.getLocalizedMessage()); return; // needed to avoid warning at fis usage below - } - - final String MATCH = "cygwin1.dll"; - final int MATCH_LEN = MATCH.length(); - int i = 0; - int ch = 0; - while (true) { - try { - ch = fis.read(); - } catch (IOException e) { - Assert.fail( - "Problem inspecting file to see if it's a cygwin executable : " + e.getLocalizedMessage()); - } - if (ch == -1) { // EOF - break; - } - if (ch == MATCH.charAt(i)) { - if (i == MATCH_LEN - 1) { - sProgramIsCygwin = true; - break; // found it! - } - i++; - } else { - i = 0; - } - } - if (fis != null) { - try { - fis.close(); - } catch (IOException e) { - } + } catch (IOException e1) { + //ignore } } }