8299739: HashedPasswordFileTest.java and ExceptionTest.java can fail with java.lang.NullPointerException

Reviewed-by: sspitsyn, amenkov, cjplummer
This commit is contained in:
Kevin Walls 2023-02-09 09:30:44 +00:00
parent 83e2db6ba3
commit 04f30185e9
2 changed files with 18 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -123,10 +123,13 @@ public class ExceptionTest {
} finally {
try {
// Close JMX Connector Client
cc.close();
if (cc != null) {
cc.close();
}
// Stop connertor server
cs.stop();
if (cs != null) {
cs.stop();
}
} catch (Exception e) {
Utils.printThrowable(e, true);
throw new RuntimeException(

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -200,6 +200,12 @@ public class HashedPasswordFileTest {
return cs.getAddress();
}
private void stopServerSide() throws IOException {
if (cs != null) {
cs.stop();
}
}
@Test
public void testClearTextPasswordFile() throws IOException {
Boolean[] bvals = new Boolean[]{true, false};
@ -217,7 +223,7 @@ public class HashedPasswordFileTest {
}
Assert.assertEquals(isPasswordFileHashed(), bval);
} finally {
cs.stop();
stopServerSide();
}
}
}
@ -241,7 +247,7 @@ public class HashedPasswordFileTest {
}
Assert.assertEquals(isPasswordFileHashed(), false);
} finally {
cs.stop();
stopServerSide();
}
}
}
@ -263,7 +269,7 @@ public class HashedPasswordFileTest {
}
}
} finally {
cs.stop();
stopServerSide();
}
}
}
@ -400,7 +406,7 @@ public class HashedPasswordFileTest {
}
}
} finally {
cs.stop();
stopServerSide();
}
}