This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 11.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push: new c448f13ad7 Report name in exception message for naming lookup failures c448f13ad7 is described below commit c448f13ad7710df70bcaf2171686772e239e7e2d Author: remm <r...@apache.org> AuthorDate: Wed Apr 30 09:28:36 2025 +0200 Report name in exception message for naming lookup failures BZ#69662 Based on code submitted by Donald Smith. --- java/org/apache/naming/LocalStrings.properties | 4 ++-- java/org/apache/naming/LocalStrings_cs.properties | 1 - java/org/apache/naming/LocalStrings_de.properties | 2 -- java/org/apache/naming/LocalStrings_es.properties | 2 -- java/org/apache/naming/LocalStrings_fr.properties | 2 -- java/org/apache/naming/LocalStrings_ja.properties | 2 -- java/org/apache/naming/LocalStrings_ko.properties | 2 -- java/org/apache/naming/LocalStrings_ru.properties | 2 -- java/org/apache/naming/LocalStrings_zh_CN.properties | 2 -- java/org/apache/naming/NamingContext.java | 20 ++++++++++---------- webapps/docs/changelog.xml | 4 ++++ 11 files changed, 16 insertions(+), 27 deletions(-) diff --git a/java/org/apache/naming/LocalStrings.properties b/java/org/apache/naming/LocalStrings.properties index ae9c6daf82..2b7489688a 100644 --- a/java/org/apache/naming/LocalStrings.properties +++ b/java/org/apache/naming/LocalStrings.properties @@ -21,8 +21,8 @@ contextBindings.noContextBoundToThread=No naming context bound to this thread contextBindings.unknownContext=Unknown context name : [{0}] namingContext.alreadyBound=Name [{0}] is already bound in this Context -namingContext.contextExpected=Name is not bound to a Context -namingContext.failResolvingReference=Unexpected exception resolving reference +namingContext.contextExpected=Name [{0}] is not bound to a Context +namingContext.failResolvingReference=Unexpected exception resolving reference with name [{0}] namingContext.invalidName=Name is not valid namingContext.nameNotBound=Name [{0}] is not bound in this Context. Unable to find [{1}]. namingContext.noAbsoluteName=Cannot generate an absolute name for this namespace diff --git a/java/org/apache/naming/LocalStrings_cs.properties b/java/org/apache/naming/LocalStrings_cs.properties index ddc953d793..6f9df2351b 100644 --- a/java/org/apache/naming/LocalStrings_cs.properties +++ b/java/org/apache/naming/LocalStrings_cs.properties @@ -16,4 +16,3 @@ # Do not edit this file directly. # To edit translations see: https://tomcat.apache.org/getinvolved.html#Translations -namingContext.contextExpected=Jméno není svázáno s kontextem diff --git a/java/org/apache/naming/LocalStrings_de.properties b/java/org/apache/naming/LocalStrings_de.properties index a4a97fbce9..e588c53489 100644 --- a/java/org/apache/naming/LocalStrings_de.properties +++ b/java/org/apache/naming/LocalStrings_de.properties @@ -18,7 +18,5 @@ contextBindings.unknownContext=Unbekannter Kontext-Name: [{0}] -namingContext.contextExpected=Ein Name ist nicht an den Context gebunden - selectorContext.methodUsingName=Aufruf der Methode [{0}] mit Namen [{1}] selectorContext.noJavaUrl=Auf diesen Kontext muss durch eine java:-URL zugegriffen werden diff --git a/java/org/apache/naming/LocalStrings_es.properties b/java/org/apache/naming/LocalStrings_es.properties index f8c39230f8..52036975d5 100644 --- a/java/org/apache/naming/LocalStrings_es.properties +++ b/java/org/apache/naming/LocalStrings_es.properties @@ -21,8 +21,6 @@ contextBindings.noContextBoundToThread=No hay contexto de nombres asociado a est contextBindings.unknownContext=Contexto [{0}] desconocido namingContext.alreadyBound=El nombre [{0}] este ya asociado en este Contexto -namingContext.contextExpected=El nombre no esta asociado a ningun Contexto -namingContext.failResolvingReference=Excepción inesperada resolviendo referencia namingContext.invalidName=Nombre no valido namingContext.nameNotBound=El nombre [{0}] no este asociado a este contexto namingContext.noAbsoluteName=No se puede generar un nombre absoluto para este espacio de nombres diff --git a/java/org/apache/naming/LocalStrings_fr.properties b/java/org/apache/naming/LocalStrings_fr.properties index 9ef1cf8ecd..45eaf0ae11 100644 --- a/java/org/apache/naming/LocalStrings_fr.properties +++ b/java/org/apache/naming/LocalStrings_fr.properties @@ -21,8 +21,6 @@ contextBindings.noContextBoundToThread=Aucun Contexte de nommage lié à ce thre contextBindings.unknownContext=Nom de Contexte inconnu : [{0}] namingContext.alreadyBound=Le Nom [{0}] est déjà lié à ce Contexte -namingContext.contextExpected=Le Nom n'est pas lié à un Contexte -namingContext.failResolvingReference=Une erreur s est produite durant la résolution de la référence namingContext.invalidName=Le Nom est invalide namingContext.nameNotBound=Le Nom [{0}] n''est pas lié à ce Contexte namingContext.noAbsoluteName=Impossible de générer un nom absolu pour cet espace de nommage (namespace) diff --git a/java/org/apache/naming/LocalStrings_ja.properties b/java/org/apache/naming/LocalStrings_ja.properties index d8e7a609b7..3c1e888411 100644 --- a/java/org/apache/naming/LocalStrings_ja.properties +++ b/java/org/apache/naming/LocalStrings_ja.properties @@ -21,8 +21,6 @@ contextBindings.noContextBoundToThread=名前付きコンテキストはこの contextBindings.unknownContext=未知のコンテキスト名です: [{0}] namingContext.alreadyBound=名前 [{0}] は既にこのコンテキストにバインドされています -namingContext.contextExpected=名前がコンテキストにバインドされていません -namingContext.failResolvingReference=参照の解決中に予測しない例外が発生しました namingContext.invalidName=名前は無効です namingContext.nameNotBound=名前 [{0}] はこのコンテキストにバインドされていません namingContext.noAbsoluteName=この名前空間に絶対名を生成できません diff --git a/java/org/apache/naming/LocalStrings_ko.properties b/java/org/apache/naming/LocalStrings_ko.properties index 075f719ca2..b459f96c87 100644 --- a/java/org/apache/naming/LocalStrings_ko.properties +++ b/java/org/apache/naming/LocalStrings_ko.properties @@ -21,8 +21,6 @@ contextBindings.noContextBoundToThread=이 쓰레드에 Naming 컨텍스트가 contextBindings.unknownContext=알 수 없는 컨텍스트 이름: [{0}] namingContext.alreadyBound=Name [{0}]이(가) 이미 이 컨텍스트에 바인딩 되어 있습니다. -namingContext.contextExpected=Name이 컨텍스트에 바인딩 되지 않았습니다. -namingContext.failResolvingReference=참조를 결정하는 중 예기치 않은 예외 발생 namingContext.invalidName=Name이 유효하지 않습니다. namingContext.nameNotBound=Name [{0}]은(는) 이 컨텍스트에 바인딩되지 않았습니다. [{1}]을(를) 찾을 수 없습니다. namingContext.noAbsoluteName=이 네임스페이스를 위한 절대 이름을 생성할 수 없습니다. diff --git a/java/org/apache/naming/LocalStrings_ru.properties b/java/org/apache/naming/LocalStrings_ru.properties index d4cc37e6e1..61e99164e0 100644 --- a/java/org/apache/naming/LocalStrings_ru.properties +++ b/java/org/apache/naming/LocalStrings_ru.properties @@ -16,7 +16,5 @@ # Do not edit this file directly. # To edit translations see: https://tomcat.apache.org/getinvolved.html#Translations -namingContext.contextExpected=Имя не привязано к контексту - selectorContext.methodUsingName=Вызов метода [{0}] с именем [{1}] selectorContext.methodUsingString=Вызов метода [{0}] для строки [{1}] diff --git a/java/org/apache/naming/LocalStrings_zh_CN.properties b/java/org/apache/naming/LocalStrings_zh_CN.properties index 5e5254698a..0246c46e59 100644 --- a/java/org/apache/naming/LocalStrings_zh_CN.properties +++ b/java/org/apache/naming/LocalStrings_zh_CN.properties @@ -21,8 +21,6 @@ contextBindings.noContextBoundToThread=没有绑定到此线程的命名上下 contextBindings.unknownContext=未知.上下文名:[{0}] namingContext.alreadyBound=名称[{0}]已在此上下文中绑定 -namingContext.contextExpected=上下文Context未绑定名称name -namingContext.failResolvingReference=解析引用时意外异常 namingContext.invalidName=名称无效 namingContext.nameNotBound=名称[{0}]未在此上下文中绑定。找不到[{1}]。 namingContext.noAbsoluteName=无法为此命名空间生成绝对名称 diff --git a/java/org/apache/naming/NamingContext.java b/java/org/apache/naming/NamingContext.java index 9cb5579128..d7b6977e1c 100644 --- a/java/org/apache/naming/NamingContext.java +++ b/java/org/apache/naming/NamingContext.java @@ -202,7 +202,7 @@ public class NamingContext implements Context { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).unbind(name.getSuffix(1)); } else { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } } else { bindings.remove(name.get(0)); @@ -248,7 +248,7 @@ public class NamingContext implements Context { } if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } return ((Context) entry.value).list(name.getSuffix(1)); } @@ -277,7 +277,7 @@ public class NamingContext implements Context { } if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } return ((Context) entry.value).listBindings(name.getSuffix(1)); } @@ -313,14 +313,14 @@ public class NamingContext implements Context { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).destroySubcontext(name.getSuffix(1)); } else { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } } else { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).close(); bindings.remove(name.get(0)); } else { - throw new NotContextException(sm.getString("namingContext.contextExpected")); + throw new NotContextException(sm.getString("namingContext.contextExpected", name.get(0))); } } @@ -381,7 +381,7 @@ public class NamingContext implements Context { if (obj instanceof Context) { return ((Context) obj).getNameParser(name.getSuffix(1)); } else { - throw new NotContextException(sm.getString("namingContext.contextExpected")); + throw new NotContextException(sm.getString("namingContext.contextExpected", name.get(0))); } } @@ -491,7 +491,7 @@ public class NamingContext implements Context { // If the size of the name is greater than 1, then we go through a // number of sub contexts. if (entry.type != NamingEntry.CONTEXT) { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } return ((Context) entry.value).lookup(name.getSuffix(1)); } else { @@ -529,13 +529,13 @@ public class NamingContext implements Context { } } if (obj == null) { - throw new NamingException(sm.getString("namingContext.failResolvingReference")); + throw new NamingException(sm.getString("namingContext.failResolvingReference", name)); } return obj; } catch (NamingException e) { throw e; } catch (Exception e) { - String msg = sm.getString("namingContext.failResolvingReference"); + String msg = sm.getString("namingContext.failResolvingReference", name); log.warn(msg, e); NamingException ne = new NamingException(msg); ne.initCause(e); @@ -587,7 +587,7 @@ public class NamingContext implements Context { ((Context) entry.value).bind(name.getSuffix(1), obj); } } else { - throw new NamingException(sm.getString("namingContext.contextExpected")); + throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); } } else { if ((!rebind) && (entry != null)) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 0b08c61b64..ccb55da941 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -133,6 +133,10 @@ Refactor GCI servlet to access resources via the <code>WebResource</code> API. (markt) </scode> + <fix> + <bug>69662</bug>: Report name in exception message when a naming lookup + failure occurs. Based on code submitted by Donald Smith. (remm) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org