From 2f9a2c3c320a4413ad843f0c505a75c5792ad249 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Mon, 1 Dec 2014 17:59:39 -0800 Subject: [PATCH] 8035000: clean up ActivationLibrary.DestroyThread Reviewed-by: lancea --- .../checkActivateRef/CheckActivateRef.java | 4 +- .../checkAnnotations/CheckAnnotations.java | 4 +- .../CheckImplClassLoader.java | 4 +- .../CheckRegisterInLog.java | 4 +- .../CreatePrivateActivatable.java | 4 +- .../DownloadParameterClass.java | 4 +- .../ElucidateNoSuchMethod.java | 4 +- .../extLoadedImpl/ExtLoadedImplTest.java | 4 +- .../forceLogSnapshot/ForceLogSnapshot.java | 4 +- .../inactiveGroup/InactiveGroup.java | 4 +- .../LookupActivationSystem.java | 4 +- .../nestedActivate/NestedActivate.java | 4 +- .../NonExistentActivatable.java | 4 +- .../RestartCrashedService.java | 4 +- .../restartLatecomer/RestartLatecomer.java | 4 +- .../restartService/RestartService.java | 4 +- .../UnregisterInactive.java | 4 +- .../activateFails/ActivateFails.java | 4 +- .../DownloadActivationGroup.java | 4 +- .../activeGroup/IdempotentActiveGroup.java | 4 +- .../modifyDescriptor/ModifyDescriptor.java | 4 +- .../StubClassesPermitted.java | 4 +- .../unregisterGroup/UnregisterGroup.java | 4 +- .../CommandEnvironment/SetChildEnv.java | 4 +- .../InheritedChannelNotServerSocket.java | 4 +- .../RmidViaInheritedChannel.java | 4 +- .../AltSecurityManager.java | 7 - .../activatable/UseCustomSocketFactory.java | 4 +- .../rmi/testlibrary/ActivationLibrary.java | 64 ------ jdk/test/java/rmi/testlibrary/RMID.java | 216 +++++++++--------- 30 files changed, 160 insertions(+), 235 deletions(-) diff --git a/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java b/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java index dcd5990db63..f37fdec54dc 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java +++ b/jdk/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -262,7 +262,7 @@ public class CheckActivateRef e.getClass().getName(), e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); obj = null; } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java index d2a0bab342c..126fae1e521 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java +++ b/jdk/test/java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -130,7 +130,7 @@ public class CheckAnnotations myRMI = null; System.err.println("rmid shut down"); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java b/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java index 556e2895ca9..dc54f82459b 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java +++ b/jdk/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, 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 @@ -112,7 +112,7 @@ public class CheckImplClassLoader { myRMI = null; System.err.println("rmid shut down"); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(group); } } diff --git a/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java b/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java index c294a972d36..0d03562346c 100644 --- a/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java +++ b/jdk/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -164,7 +164,7 @@ public class CheckRegisterInLog throw new RuntimeException("CheckRegisterInLog got exception " + e.getMessage()); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java index 2900e80964a..414527dfa4b 100644 --- a/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java +++ b/jdk/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -155,7 +155,7 @@ public class CreatePrivateActivatable e.getClass().getName(), e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); obj = null; } } diff --git a/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java b/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java index 64f11681341..9f236978a4a 100644 --- a/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java +++ b/jdk/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -138,7 +138,7 @@ public class DownloadParameterClass { } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java b/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java index 29482121ffb..0e0efb52cd5 100644 --- a/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java +++ b/jdk/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -135,7 +135,7 @@ public class ElucidateNoSuchMethod } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java index 3fd009b611a..c46baeaf5e7 100644 --- a/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java +++ b/jdk/test/java/rmi/activation/Activatable/extLoadedImpl/ExtLoadedImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 @@ -69,7 +69,7 @@ public class ExtLoadedImplTest { } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java b/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java index abbaadfb9f3..55ff0cfd14e 100644 --- a/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java +++ b/jdk/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -248,7 +248,7 @@ public class ForceLogSnapshot } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); for (int i = 0 ; i < HOW_MANY ; i ++) { TestLibrary.unexport(unicastObjs[i]); } diff --git a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java index ad0b14e421a..145e6109df8 100644 --- a/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java +++ b/jdk/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -176,7 +176,7 @@ public class InactiveGroup } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java b/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java index ce154c4ca99..df778dc8e91 100644 --- a/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java +++ b/jdk/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, 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 @@ -118,7 +118,7 @@ public class LookupActivationSystem implements Remote, Serializable { } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java b/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java index 48e3e2d701e..507912e90b5 100644 --- a/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java +++ b/jdk/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -165,7 +165,7 @@ public class NestedActivate } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java b/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java index 47ddd176ef8..df8ddbef82c 100644 --- a/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java +++ b/jdk/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -139,7 +139,7 @@ public class NonExistentActivatable } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java b/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java index 5700f3d72f2..c3026b02c93 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java +++ b/jdk/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -231,7 +231,7 @@ public class RestartCrashedService } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(unicastObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java b/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java index 747eee68f3a..3bbe8a60c44 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java +++ b/jdk/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 @@ -247,7 +247,7 @@ public class RestartLatecomer } catch (Exception e) { TestLibrary.bomb(e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(callbackObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java b/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java index e1f2eb554ee..468f5b239f1 100644 --- a/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java +++ b/jdk/test/java/rmi/activation/Activatable/restartService/RestartService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -221,7 +221,7 @@ public class RestartService } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); TestLibrary.unexport(unicastObj); } } diff --git a/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java b/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java index 455efd7d7f6..085120b159d 100644 --- a/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java +++ b/jdk/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -125,7 +125,7 @@ public class UnregisterInactive } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java index 6a2eba05864..6d9ccceb141 100644 --- a/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java +++ b/jdk/test/java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -163,7 +163,7 @@ public class ActivateFails } finally { obj1 = obj2 = null; - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java index f9aed42021d..2f025cf25b8 100644 --- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java +++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, 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 @@ -156,7 +156,7 @@ public class DownloadActivationGroup } catch (Exception e) { TestLibrary.bomb(e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java index f6c08178eec..058d3c7e2d9 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, 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 @@ -108,7 +108,7 @@ public class IdempotentActiveGroup { } catch (NoSuchObjectException unexpected) { throw new AssertionError(unexpected); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java index ba376d1a8d9..53ff030e393 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -250,7 +250,7 @@ public class ModifyDescriptor } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java index b7890e0ebe7..f4970da26ad 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -171,7 +171,7 @@ public class StubClassesPermitted } canCreateStubs = null; - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); System.err.println("rmid shut down"); } } diff --git a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java index bc5976b74fe..94976dc0c6f 100644 --- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java +++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -156,7 +156,7 @@ public class UnregisterGroup extends Activatable implements ActivateMe } catch (Exception e) { TestLibrary.bomb("test failed", e); } finally { - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } } diff --git a/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java b/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java index 7b1a9688ad4..69274a0a797 100644 --- a/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java +++ b/jdk/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -203,7 +203,7 @@ public class SetChildEnv actsys.unregisterGroup(gid); Thread.sleep(5000); - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } public static class DebugExecWatcher diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java index 4611a83bda5..d375fc84611 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, 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 @@ -121,7 +121,7 @@ public class InheritedChannelNotServerSocket { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java index 6d81b0f1248..1f3cd6603d5 100644 --- a/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java +++ b/jdk/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, 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 @@ -119,7 +119,7 @@ public class RmidViaInheritedChannel implements Callback { if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid); + rmid.cleanup(); } } diff --git a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java index 351042965de..ebad01300ae 100644 --- a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java +++ b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java @@ -104,13 +104,6 @@ public class AltSecurityManager implements Runnable { utilityToStart + " to die"); if (time >= TIME_OUT) { - - // dont pollute other tests; increase the likelihood - // that rmid will go away if it did not exit already. - if (utility.equals(ACTIVATION)) { - RMID.shutdown(port); - } - TestLibrary.bomb(utilityToStart + " took too long to die..."); } else { diff --git a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java index b300e1083bb..5157f789c75 100644 --- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java +++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -57,7 +57,7 @@ public class UseCustomSocketFactory { RMID rmid = null; try { - rmid = RMID.createRMID(true); + rmid = RMID.createRMID(); rmid.addArguments(new String[] { "-C-Djava.security.policy=" + TestParams.defaultGroupPolicy + diff --git a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java index b33a3035c89..6a7a5b753d8 100644 --- a/jdk/test/java/rmi/testlibrary/ActivationLibrary.java +++ b/jdk/test/java/rmi/testlibrary/ActivationLibrary.java @@ -103,68 +103,4 @@ public class ActivationLibrary { } catch (NoSuchObjectException e) { } } - - /** cleanup after rmid */ - public static void rmidCleanup(RMID rmid) { - if (rmid != null) { - if (!ActivationLibrary.safeDestroy(rmid, SAFE_WAIT_TIME)) { - TestLibrary.bomb("rmid not destroyed in: " + - SAFE_WAIT_TIME + - " milliseconds"); - } - } - RMID.removeLog(); - } - - /** - * Invoke shutdown on rmid in a way that will not cause a test - * to hang. - * - * @return whether or not shutdown completed succesfully in the - * timeAllowed - */ - private static boolean safeDestroy(RMID rmid, long timeAllowed) { - DestroyThread destroyThread = new DestroyThread(rmid); - destroyThread.start(); - - try { - destroyThread.join(timeAllowed); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - - return destroyThread.shutdownSucceeded(); - } - - /** - * Thread class to handle the destruction of rmid - */ - private static class DestroyThread extends Thread { - private final RMID rmid; - private final int port; - private boolean succeeded = false; - - DestroyThread(RMID rmid) { - this.rmid = rmid; - this.port = rmid.getPort(); - this.setDaemon(true); - } - - public void run() { - if (RMID.lookupSystem(port) != null) { - rmid.destroy(); - synchronized (this) { - // flag that the test was able to shutdown rmid - succeeded = true; - } - mesg("finished destroying rmid"); - } else { - mesg("tried to shutdown when rmid was not running"); - } - } - - public synchronized boolean shutdownSucceeded() { - return succeeded; - } - } } diff --git a/jdk/test/java/rmi/testlibrary/RMID.java b/jdk/test/java/rmi/testlibrary/RMID.java index bdd8c829d89..29365e8125f 100644 --- a/jdk/test/java/rmi/testlibrary/RMID.java +++ b/jdk/test/java/rmi/testlibrary/RMID.java @@ -21,14 +21,11 @@ * questions. */ -/** - * - */ - import java.io.*; import java.rmi.*; import java.rmi.activation.*; import java.rmi.registry.*; +import java.util.concurrent.TimeoutException; /** * Utility class that creates an instance of rmid with a policy @@ -39,6 +36,14 @@ import java.rmi.registry.*; */ public class RMID extends JavaVM { + // TODO: adjust these based on the timeout factor + // such as jcov.sleep.multiplier; see start(long) method. + // Also consider the test.timeout.factor property (a float). + private static final long TIMEOUT_SHUTDOWN_MS = 60_000L; + private static final long TIMEOUT_DESTROY_MS = 10_000L; + private static final long STARTTIME_MS = 15_000L; + private static final long POLLTIME_MS = 100L; + private static final String SYSTEM_NAME = ActivationSystem.class.getName(); // "java.rmi.activation.ActivationSystem" @@ -140,15 +145,8 @@ public class RMID extends JavaVM { * policy file. */ public static RMID createRMID() { - return createRMID(System.out, System.err, true); - } - - public static RMID createRMID(boolean debugExec) { - return createRMID(System.out, System.err, debugExec); - } - - public static RMID createRMID(OutputStream out, OutputStream err) { - return createRMID(out, err, true); + return createRMID(System.out, System.err, true, true, + TestLibrary.getUnusedRandomPort()); } public static RMID createRMID(OutputStream out, OutputStream err, @@ -173,24 +171,24 @@ public class RMID extends JavaVM { /** - * Test RMID should be created with the createRMID method. + * Private constructor. RMID instances should be created + * using the static factory methods. */ - protected RMID(String classname, String options, String args, + private RMID(String classname, String options, String args, OutputStream out, OutputStream err, int port) { super(classname, options, args, out, err); this.port = port; } + /** + * Removes rmid's log file directory. + */ public static void removeLog() { - /* - * Remove previous log file directory before - * starting up rmid. - */ File f = new File(LOGDIR, log); if (f.exists()) { - mesg("removing rmid's old log file..."); + mesg("Removing rmid's old log file."); String[] files = f.list(); if (files != null) { @@ -199,8 +197,8 @@ public class RMID extends JavaVM { } } - if (f.delete() != true) { - mesg("\t" + " unable to delete old log file."); + if (! f.delete()) { + mesg("Warning: unable to delete old log file."); } } } @@ -215,14 +213,6 @@ public class RMID extends JavaVM { return TestLibrary.getExtraProperty("rmid.jcov.args",""); } - public void start() throws IOException { - start(10000); - } - - public void slowStart() throws IOException { - start(60000); - } - /** * Looks up the activation system in the registry on the given port, * returning its stub, or null if it's not present. This method differs from @@ -239,12 +229,24 @@ public class RMID extends JavaVM { } } + /** + * Starts rmid and waits up to the default timeout period + * to confirm that it's running. + */ + public void start() throws IOException { + start(STARTTIME_MS); + } + + /** + * Starts rmid and waits up to the given timeout period + * to confirm that it's running. + */ public void start(long waitTime) throws IOException { // if rmid is already running, then the test will fail with // a well recognized exception (port already in use...). - mesg("starting rmid on port #" + port + "..."); + mesg("Starting rmid on port " + port + "."); super.start(); int slopFactor = 1; @@ -254,20 +256,17 @@ public class RMID extends JavaVM { } catch (NumberFormatException ignore) {} waitTime = waitTime * slopFactor; - // We check several times (as many as provides passed waitTime) to - // see if Rmid is currently running. Waiting steps last 100 msecs. - final long rmidStartSleepTime = 100; + // We check several times, for a maximum of waitTime, until we have + // verified that rmid is running. do { - // Sleeping for another rmidStartSleepTime time slice. try { - Thread.sleep(Math.min(waitTime, rmidStartSleepTime)); + Thread.sleep(Math.min(waitTime, POLLTIME_MS)); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); - mesg("Thread interrupted while checking for start of Activation System. Giving up check."); - mesg("Activation System state unknown"); + mesg("Interrupted while starting activation system, giving up."); return; } - waitTime -= rmidStartSleepTime; + waitTime -= POLLTIME_MS; // Checking if rmid is present if (lookupSystem(port) != null) { @@ -279,7 +278,7 @@ public class RMID extends JavaVM { * incorrect value. */ System.setProperty("java.rmi.activation.port", Integer.toString(port)); - mesg("finished starting rmid."); + mesg("Started successfully."); return; } else { if (waitTime > 0) { @@ -287,9 +286,15 @@ public class RMID extends JavaVM { } } } while (waitTime > 0); - TestLibrary.bomb("start rmid failed... giving up", null); + TestLibrary.bomb("Failed to start rmid, giving up.", null); } + /** + * Destroys rmid and restarts it. Note that this does NOT clean up + * the log file, because it stores information about restartable + * and activatable objects that must be carried over to the new + * rmid instance. + */ public void restart() throws IOException { destroy(); start(); @@ -298,30 +303,35 @@ public class RMID extends JavaVM { /** * Ask rmid to shutdown gracefully using a remote method call. * catch any errors that might occur from rmid not being present - * at time of shutdown invocation. - * - * Shutdown does not nullify possible references to the rmid - * process object (destroy does though). + * at time of shutdown invocation. If the remote call is + * successful, wait for the process to terminate. Return true + * if the process terminated, otherwise return false. */ - public static void shutdown(int port) { + private boolean shutdown() throws InterruptedException { + mesg("shutdown()"); + ActivationSystem system = lookupSystem(port); + if (system == null) { + mesg("lookupSystem() returned null"); + return false; + } try { - ActivationSystem system = lookupSystem(port); - - if (system == null) { - TestLibrary.bomb("reference to the activation system was null"); - } - + mesg("ActivationSystem.shutdown()"); system.shutdown(); - } catch (RemoteException re) { - mesg("shutting down the activation daemon failed"); } catch (Exception e) { - mesg("caught exception trying to shutdown rmid"); - mesg(e.getMessage()); + mesg("Caught exception from ActivationSystem.shutdown():"); e.printStackTrace(); } - mesg("testlibrary finished shutting down rmid"); + try { + waitFor(TIMEOUT_SHUTDOWN_MS); + mesg("Shutdown successful."); + return true; + } catch (TimeoutException ex) { + mesg("Shutdown timed out:"); + ex.printStackTrace(); + return false; + } } /** @@ -330,60 +340,46 @@ public class RMID extends JavaVM { * if rmid is a child process of the current VM. */ public void destroy() { - // attempt graceful shutdown of the activation system - shutdown(port); - - if (vm != null) { - try { - /* Waiting for distant RMID process to shutdown. - * Waiting is bounded at a hardcoded max of 60 secs (1 min). - * Waiting by steps of 200 msecs, thus at most 300 such attempts - * for termination of distant RMID process. If process is not - * known to be terminated properly after that time, - * we give up for a gracefull termination, and thus go for - * forcibly destroying the process. - */ - boolean vmEnded = false; - int waitingTrials = 0; - final int maxTrials = 300; - final long vmProcessEndWaitInterval = 200; - int vmExitValue; - do { - try { - Thread.sleep(vmProcessEndWaitInterval); - waitingTrials++; - vmExitValue = vm.exitValue(); - mesg("rmid exited on shutdown request"); - vmEnded = true; - } catch (IllegalThreadStateException illegal) { - mesg("RMID's process still not terminated after more than " + - (waitingTrials * vmProcessEndWaitInterval) + " milliseconds"); - } - } - while (!vmEnded && - (waitingTrials < maxTrials)); - - if (waitingTrials >= maxTrials) { - mesg("RMID's process still not terminated after more than " + - (waitingTrials * vmProcessEndWaitInterval) + " milliseconds." + - "Givinp up gracefull termination..."); - mesg("destroying RMID's process using Process.destroy()"); - super.destroy(); - } - - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - mesg("Thread interrupted while checking for termination of distant rmid vm. Giving up check."); - } catch (Exception e) { - mesg("caught unexpected exception trying to destroy rmid: " + - e.getMessage()); - e.printStackTrace(); - } - - // rmid will not restart if its process is not null - vm = null; + if (vm == null) { + throw new IllegalStateException("can't wait for RMID that isn't running"); } + + // First, attempt graceful shutdown of the activation system. + try { + if (! shutdown()) { + // Graceful shutdown failed, use Process.destroy(). + mesg("Destroying RMID process."); + vm.destroy(); + try { + waitFor(TIMEOUT_DESTROY_MS); + mesg("Destroy successful."); + } catch (TimeoutException ex) { + mesg("Destroy timed out, giving up."); + ex.printStackTrace(); + } + } + } catch (InterruptedException ie) { + mesg("Shutdown/destroy interrupted, giving up."); + ie.printStackTrace(); + Thread.currentThread().interrupt(); + return; + } + + vm = null; } - public int getPort() {return port;} + /** + * Shuts down rmid and then removes its log file. + */ + public void cleanup() { + destroy(); + RMID.removeLog(); + } + + /** + * Gets the port on which this rmid is listening. + */ + public int getPort() { + return port; + } }