|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -752,7 +752,9 @@ invoker_completeInvokeRequest(jthread thread)
|
752 | 752 | }
|
753 | 753 | id = request->id;
|
754 | 754 | exc = request->exception;
|
| 755 | + request->exception = NULL; |
755 | 756 | returnValue = request->returnValue;
|
| 757 | + request->returnValue.l = NULL; |
756 | 758 |
|
757 | 759 | /* Release return value and exception references, but delay the release
|
758 | 760 | * until after the return packet was sent. */
|
@@ -790,23 +792,20 @@ invoker_completeInvokeRequest(jthread thread)
|
790 | 792 | (void)outStream_writeValue(env, &out, tag, returnValue);
|
791 | 793 | (void)outStream_writeObjectTag(env, &out, exc);
|
792 | 794 | (void)outStream_writeObjectRef(env, &out, exc);
|
| 795 | + /* |
| 796 | + * Delete potentially saved global references for return value |
| 797 | + * and exception. This must be done before sending the reply or |
| 798 | + * these objects will briefly be viewable by the debugger as live |
| 799 | + * when they shouldn't be. |
| 800 | + */ |
| 801 | + if (mustReleaseReturnValue && returnValue.l != NULL) { |
| 802 | + tossGlobalRef(env, &returnValue.l); |
| 803 | + } |
| 804 | + if (exc != NULL) { |
| 805 | + tossGlobalRef(env, &exc); |
| 806 | + } |
793 | 807 | outStream_sendReply(&out);
|
794 | 808 | }
|
795 |
| - |
796 |
| - /* |
797 |
| - * Delete potentially saved global references of return value |
798 |
| - * and exception |
799 |
| - */ |
800 |
| - eventHandler_lock(); // for proper lock order |
801 |
| - debugMonitorEnter(invokerLock); |
802 |
| - if (mustReleaseReturnValue && returnValue.l != NULL) { |
803 |
| - tossGlobalRef(env, &returnValue.l); |
804 |
| - } |
805 |
| - if (exc != NULL) { |
806 |
| - tossGlobalRef(env, &exc); |
807 |
| - } |
808 |
| - debugMonitorExit(invokerLock); |
809 |
| - eventHandler_unlock(); |
810 | 809 | }
|
811 | 810 |
|
812 | 811 | jboolean
|
|
0 commit comments