This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 0323ca7c58 Refactor locking to address identified issues
0323ca7c58 is described below
commit 0323ca7c58a8c493f821bc80c71ec08b58e608a7
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Jun 19 15:19:53 2026 +0100
Refactor locking to address identified issues
---
java/org/apache/naming/NamingContext.java | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/java/org/apache/naming/NamingContext.java
b/java/org/apache/naming/NamingContext.java
index 212dd0831f..3d60c2a5f2 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -519,24 +519,21 @@ public class NamingContext implements Context {
try {
Object obj = null;
boolean singleton = false;
- if (entry.value instanceof ResourceRef) {
- // Only create singleton instances inside the sync
- synchronized (entry) {
- if (entry.value instanceof ResourceRef) {
- singleton = Boolean.parseBoolean(
- (String) ((ResourceRef)
entry.value).get(ResourceRef.SINGLETON).getContent());
- if (singleton) {
- obj = getObjectInstance(name, entry);
- // If reference resolution fails, don't
cache failed result.
- if (obj != null) {
- entry.value = obj;
- entry.type = NamingEntry.ENTRY;
- }
+ synchronized (entry) {
+ if (entry.type == NamingEntry.ENTRY) {
+ // Other thread has already created the singleton
+ singleton = true;
+ obj = entry.value;
+ } else if (entry.value instanceof ResourceRef
resourceRef) {
+ singleton =
+ Boolean.parseBoolean((String)
resourceRef.get(ResourceRef.SINGLETON).getContent());
+ if (singleton) {
+ obj = getObjectInstance(name, entry);
+ // If reference resolution fails, don't cache
failed result.
+ if (obj != null) {
+ entry.value = obj;
+ entry.type = NamingEntry.ENTRY;
}
- } else {
- // Another thread has created the singleton
- singleton = true;
- obj = entry.value;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]