Author: markt Date: Thu Mar 8 22:46:08 2012 New Revision: 1298635 URL: http://svn.apache.org/viewvc?rev=1298635&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52830 Align parseName(Name) with parseName(String) so both have the same behaviour
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/naming/SelectorContext.java tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Mar 8 22:46:08 2012 @@ -1 +1 @@ -/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174975,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187 381,1187753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180,1201235-1201237,1201508,1201521,1201542,1201545-1201546,1201548,1201555-1201556,1201568,1201576,1201608,1201921-1201922,1 201931,1202035,1202039,1202271,1202565,1202578,1202705,1202828,1202860,1203047-1203052,1203078,1203091,1203253,1203278,1204182,1204856,1204867,1204936,1204938,1204982,1205033,1205065,1205082,1205097,1205112,1206200,1207692,1208046,1208073,1208096,1208114,1208145,1208772,1209194,1209277-1209278,1209686-1209731,1210894,1212091,1212095,1212099,1212118,1213469,1213906,1214853,1214855,1214864,1215115,1215118-1215119,1215121,1220293,1220295,1221038,1221842,1222189,1222201,1222276,1222300,1222690,1222850,1222852,1222855,1224607,1224617,1224648-1224652,1224657,1224662-1224663,1224682,1224801,1224910,1225000,1225219,1225343,1225465,1225627,1225629,1225634,1226069,1226158-1226159,1226177,1226196,1226214-1226215,1226385,1226394,1226500,1226537-1226538,1226546,1226551,1226975,1228196,1228360,1228376,1228724,1228908,1228918,1228920,1228922,1228929,1228969,1229307,1229536,1229549,1229724,1229726-1229731,1229997,1230539,1230711,1230729,1230762-1230763,1230765,1230955,1230957,1231285,123129 0,1231308,1231310,1231337,1231460-1231461,1231542-1231543,1231546-1231547,1231620-1231621,1231624-1231625,1231630,1231654-1231655,1231738,1231740,1231762-1231763,1231856,1231886,1231923,1231947,1232345,1232368,1232380,1232447,1232760,1232813,1232842-1232843,1232869,1233413,1233423,1233426,1234143,1234567,1235207,1236906-1236907,1236914,1237146,1237154-1237156,1237332,1237334,1237425,1237427,1237604,1237975,1237981,1237985,1238070,1238073,1239024,1239048,1239050,1239060,1239135,1239483,1239485,1240101,1240106,1240109,1240112,1240114,1240116,1240118,1240121,1240329,1240697,1240795,1240821,1240842,1240857,1241087,1241160,1241908-1241909,1241982,1242099,1242110,1242371,1242434,1242495,1242947,1243034,1243038,1244302,1244511,1244567,1244718-1244719,1244935-1244938,1245274,1245449,1245849,1290875,1292334,1292338,1292345-1292347,1293155,1293831-1293832,1295998,1297014-1297015,1297017,1297158,1297177,1297202,1297209,1297213,1297717,1297722,1297729,1297768,1297778,1297818,1297828,129 7979,1297987,1298121,1298140 +/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174975,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187 381,1187753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180,1201235-1201237,1201508,1201521,1201542,1201545-1201546,1201548,1201555-1201556,1201568,1201576,1201608,1201921-1201922,1 201931,1202035,1202039,1202271,1202565,1202578,1202705,1202828,1202860,1203047-1203052,1203078,1203091,1203253,1203278,1204182,1204856,1204867,1204936,1204938,1204982,1205033,1205065,1205082,1205097,1205112,1206200,1207692,1208046,1208073,1208096,1208114,1208145,1208772,1209194,1209277-1209278,1209686-1209731,1210894,1212091,1212095,1212099,1212118,1213469,1213906,1214853,1214855,1214864,1215115,1215118-1215119,1215121,1220293,1220295,1221038,1221842,1222189,1222201,1222276,1222300,1222690,1222850,1222852,1222855,1224607,1224617,1224648-1224652,1224657,1224662-1224663,1224682,1224801,1224910,1225000,1225219,1225343,1225465,1225627,1225629,1225634,1226069,1226158-1226159,1226177,1226196,1226214-1226215,1226385,1226394,1226500,1226537-1226538,1226546,1226551,1226975,1228196,1228360,1228376,1228724,1228908,1228918,1228920,1228922,1228929,1228969,1229307,1229536,1229549,1229724,1229726-1229731,1229997,1230539,1230711,1230729,1230762-1230763,1230765,1230955,1230957,1231285,123129 0,1231308,1231310,1231337,1231460-1231461,1231542-1231543,1231546-1231547,1231620-1231621,1231624-1231625,1231630,1231654-1231655,1231738,1231740,1231762-1231763,1231856,1231886,1231923,1231947,1232345,1232368,1232380,1232447,1232760,1232813,1232842-1232843,1232869,1233413,1233423,1233426,1234143,1234567,1235207,1236906-1236907,1236914,1237146,1237154-1237156,1237332,1237334,1237425,1237427,1237604,1237975,1237981,1237985,1238070,1238073,1239024,1239048,1239050,1239060,1239135,1239483,1239485,1240101,1240106,1240109,1240112,1240114,1240116,1240118,1240121,1240329,1240697,1240795,1240821,1240842,1240857,1241087,1241160,1241908-1241909,1241982,1242099,1242110,1242371,1242434,1242495,1242947,1243034,1243038,1244302,1244511,1244567,1244718-1244719,1244935-1244938,1245274,1245449,1245849,1290875,1292334,1292338,1292345-1292347,1293155,1293831-1293832,1295998,1297014-1297015,1297017,1297158,1297177,1297202,1297209,1297213,1297717,1297722,1297729,1297768,1297778,1297818,1297828,129 7979,1297987,1298121,1298140,1298628-1298629 Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/SelectorContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/SelectorContext.java?rev=1298635&r1=1298634&r2=1298635&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/SelectorContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/SelectorContext.java Thu Mar 8 22:46:08 2012 @@ -5,15 +5,15 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.apache.naming; @@ -21,6 +21,7 @@ package org.apache.naming; import java.util.Hashtable; import javax.naming.Binding; +import javax.naming.CompositeName; import javax.naming.Context; import javax.naming.Name; import javax.naming.NameClassPair; @@ -111,11 +112,11 @@ public class SelectorContext implements /** - * Retrieves the named object. If name is empty, returns a new instance - * of this context (which represents the same naming context as this - * context, but its environment may be modified independently and it may + * Retrieves the named object. If name is empty, returns a new instance + * of this context (which represents the same naming context as this + * context, but its environment may be modified independently and it may * be accessed concurrently). - * + * * @param name the name of the object to look up * @return the object bound to name * @exception NamingException if a naming exception is encountered @@ -123,7 +124,7 @@ public class SelectorContext implements @Override public Object lookup(Name name) throws NamingException { - + if (log.isDebugEnabled()) { log.debug(sm.getString("selectorContext.methodUsingName", "lookup", name)); @@ -138,7 +139,7 @@ public class SelectorContext implements /** * Retrieves the named object. - * + * * @param name the name of the object to look up * @return the object bound to name * @exception NamingException if a naming exception is encountered @@ -160,10 +161,10 @@ public class SelectorContext implements /** - * Binds a name to an object. All intermediate contexts and the target - * context (that named by all but terminal atomic component of the name) + * Binds a name to an object. All intermediate contexts and the target + * context (that named by all but terminal atomic component of the name) * must already exist. - * + * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @exception javax.naming.NameAlreadyBoundException if name is already @@ -181,7 +182,7 @@ public class SelectorContext implements /** * Binds a name to an object. - * + * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @exception javax.naming.NameAlreadyBoundException if name is already @@ -198,14 +199,14 @@ public class SelectorContext implements /** - * Binds a name to an object, overwriting any existing binding. All - * intermediate contexts and the target context (that named by all but + * Binds a name to an object, overwriting any existing binding. All + * intermediate contexts and the target context (that named by all but * terminal atomic component of the name) must already exist. * <p> - * If the object is a DirContext, any existing attributes associated with - * the name are replaced with those of the object. Otherwise, any + * If the object is a DirContext, any existing attributes associated with + * the name are replaced with those of the object. Otherwise, any * existing attributes associated with the name remain unchanged. - * + * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @exception javax.naming.InvalidAttributesException if object did not @@ -221,7 +222,7 @@ public class SelectorContext implements /** * Binds a name to an object, overwriting any existing binding. - * + * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @exception javax.naming.InvalidAttributesException if object did not @@ -236,14 +237,14 @@ public class SelectorContext implements /** - * Unbinds the named object. Removes the terminal atomic name in name - * from the target context--that named by all but the terminal atomic + * Unbinds the named object. Removes the terminal atomic name in name + * from the target context--that named by all but the terminal atomic * part of name. * <p> - * This method is idempotent. It succeeds even if the terminal atomic - * name is not bound in the target context, but throws - * NameNotFoundException if any of the intermediate contexts do not exist. - * + * This method is idempotent. It succeeds even if the terminal atomic + * name is not bound in the target context, but throws + * NameNotFoundException if any of the intermediate contexts do not exist. + * * @param name the name to bind; may not be empty * @exception javax.naming NameNotFoundException if an intermediate context * does not exist @@ -258,7 +259,7 @@ public class SelectorContext implements /** * Unbinds the named object. - * + * * @param name the name to bind; may not be empty * @exception javax.naming NameNotFoundException if an intermediate context * does not exist @@ -272,11 +273,11 @@ public class SelectorContext implements /** - * Binds a new name to the object bound to an old name, and unbinds the - * old name. Both names are relative to this context. Any attributes - * associated with the old name become associated with the new name. + * Binds a new name to the object bound to an old name, and unbinds the + * old name. Both names are relative to this context. Any attributes + * associated with the old name become associated with the new name. * Intermediate contexts of the old name are not changed. - * + * * @param oldName the name of the existing binding; may not be empty * @param newName the name of the new binding; may not be empty * @exception javax.naming.NameAlreadyBoundException if name is already @@ -291,9 +292,9 @@ public class SelectorContext implements /** - * Binds a new name to the object bound to an old name, and unbinds the + * Binds a new name to the object bound to an old name, and unbinds the * old name. - * + * * @param oldName the name of the existing binding; may not be empty * @param newName the name of the new binding; may not be empty * @exception javax.naming.NameAlreadyBoundException if name is already @@ -308,22 +309,22 @@ public class SelectorContext implements /** - * Enumerates the names bound in the named context, along with the class - * names of objects bound to them. The contents of any subcontexts are + * Enumerates the names bound in the named context, along with the class + * names of objects bound to them. The contents of any subcontexts are * not included. * <p> - * If a binding is added to or removed from this context, its effect on + * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. - * + * * @param name the name of the context to list - * @return an enumeration of the names and class names of the bindings in + * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { - + if (log.isDebugEnabled()) { log.debug(sm.getString("selectorContext.methodUsingName", "list", name)); @@ -334,18 +335,18 @@ public class SelectorContext implements /** - * Enumerates the names bound in the named context, along with the class + * Enumerates the names bound in the named context, along with the class * names of objects bound to them. - * + * * @param name the name of the context to list - * @return an enumeration of the names and class names of the bindings in + * @return an enumeration of the names and class names of the bindings in * this context. Each element of the enumeration is of type NameClassPair. * @exception NamingException if a naming exception is encountered */ @Override public NamingEnumeration<NameClassPair> list(String name) throws NamingException { - + if (log.isDebugEnabled()) { log.debug(sm.getString("selectorContext.methodUsingString", "list", name)); @@ -356,15 +357,15 @@ public class SelectorContext implements /** - * Enumerates the names bound in the named context, along with the - * objects bound to them. The contents of any subcontexts are not + * Enumerates the names bound in the named context, along with the + * objects bound to them. The contents of any subcontexts are not * included. * <p> - * If a binding is added to or removed from this context, its effect on + * If a binding is added to or removed from this context, its effect on * an enumeration previously returned is undefined. - * + * * @param name the name of the context to list - * @return an enumeration of the bindings in this context. + * @return an enumeration of the bindings in this context. * Each element of the enumeration is of type Binding. * @exception NamingException if a naming exception is encountered */ @@ -382,11 +383,11 @@ public class SelectorContext implements /** - * Enumerates the names bound in the named context, along with the + * Enumerates the names bound in the named context, along with the * objects bound to them. - * + * * @param name the name of the context to list - * @return an enumeration of the bindings in this context. + * @return an enumeration of the bindings in this context. * Each element of the enumeration is of type Binding. * @exception NamingException if a naming exception is encountered */ @@ -404,24 +405,24 @@ public class SelectorContext implements /** - * Destroys the named context and removes it from the namespace. Any - * attributes associated with the name are also removed. Intermediate + * Destroys the named context and removes it from the namespace. Any + * attributes associated with the name are also removed. Intermediate * contexts are not destroyed. * <p> - * This method is idempotent. It succeeds even if the terminal atomic - * name is not bound in the target context, but throws - * NameNotFoundException if any of the intermediate contexts do not exist. - * - * In a federated naming system, a context from one naming system may be - * bound to a name in another. One can subsequently look up and perform - * operations on the foreign context using a composite name. However, an - * attempt destroy the context using this composite name will fail with - * NotContextException, because the foreign context is not a "subcontext" - * of the context in which it is bound. Instead, use unbind() to remove - * the binding of the foreign context. Destroying the foreign context - * requires that the destroySubcontext() be performed on a context from + * This method is idempotent. It succeeds even if the terminal atomic + * name is not bound in the target context, but throws + * NameNotFoundException if any of the intermediate contexts do not exist. + * + * In a federated naming system, a context from one naming system may be + * bound to a name in another. One can subsequently look up and perform + * operations on the foreign context using a composite name. However, an + * attempt destroy the context using this composite name will fail with + * NotContextException, because the foreign context is not a "subcontext" + * of the context in which it is bound. Instead, use unbind() to remove + * the binding of the foreign context. Destroying the foreign context + * requires that the destroySubcontext() be performed on a context from * the foreign context's "native" naming system. - * + * * @param name the name of the context to be destroyed; may not be empty * @exception javax.naming NameNotFoundException if an intermediate context * does not exist @@ -437,7 +438,7 @@ public class SelectorContext implements /** * Destroys the named context and removes it from the namespace. - * + * * @param name the name of the context to be destroyed; may not be empty * @exception javax.naming NameNotFoundException if an intermediate context * does not exist @@ -452,11 +453,11 @@ public class SelectorContext implements /** - * Creates and binds a new context. Creates a new context with the given - * name and binds it in the target context (that named by all but - * terminal atomic component of the name). All intermediate contexts and + * Creates and binds a new context. Creates a new context with the given + * name and binds it in the target context (that named by all but + * terminal atomic component of the name). All intermediate contexts and * the target context must already exist. - * + * * @param name the name of the context to create; may not be empty * @return the newly created context * @exception javax.naming.NameAlreadyBoundException if name is already @@ -474,7 +475,7 @@ public class SelectorContext implements /** * Creates and binds a new context. - * + * * @param name the name of the context to create; may not be empty * @return the newly created context * @exception javax.naming.NameAlreadyBoundException if name is already @@ -491,12 +492,12 @@ public class SelectorContext implements /** - * Retrieves the named object, following links except for the terminal - * atomic component of the name. If the object bound to name is not a + * Retrieves the named object, following links except for the terminal + * atomic component of the name. If the object bound to name is not a * link, returns the object itself. - * + * * @param name the name of the object to look up - * @return the object bound to name, not following the terminal link + * @return the object bound to name, not following the terminal link * (if any). * @exception NamingException if a naming exception is encountered */ @@ -514,11 +515,11 @@ public class SelectorContext implements /** - * Retrieves the named object, following links except for the terminal + * Retrieves the named object, following links except for the terminal * atomic component of the name. - * + * * @param name the name of the object to look up - * @return the object bound to name, not following the terminal link + * @return the object bound to name, not following the terminal link * (if any). * @exception NamingException if a naming exception is encountered */ @@ -536,16 +537,16 @@ public class SelectorContext implements /** - * Retrieves the parser associated with the named context. In a - * federation of namespaces, different naming systems will parse names - * differently. This method allows an application to get a parser for - * parsing names into their atomic components using the naming convention - * of a particular naming system. Within any single naming system, - * NameParser objects returned by this method must be equal (using the + * Retrieves the parser associated with the named context. In a + * federation of namespaces, different naming systems will parse names + * differently. This method allows an application to get a parser for + * parsing names into their atomic components using the naming convention + * of a particular naming system. Within any single naming system, + * NameParser objects returned by this method must be equal (using the * equals() test). - * + * * @param name the name of the context from which to get the parser - * @return a name parser that can parse compound names into their atomic + * @return a name parser that can parse compound names into their atomic * components * @exception NamingException if a naming exception is encountered */ @@ -558,9 +559,9 @@ public class SelectorContext implements /** * Retrieves the parser associated with the named context. - * + * * @param name the name of the context from which to get the parser - * @return a name parser that can parse compound names into their atomic + * @return a name parser that can parse compound names into their atomic * components * @exception NamingException if a naming exception is encountered */ @@ -574,13 +575,13 @@ public class SelectorContext implements /** * Composes the name of this context with a name relative to this context. * <p> - * Given a name (name) relative to this context, and the name (prefix) - * of this context relative to one of its ancestors, this method returns - * the composition of the two names using the syntax appropriate for the - * naming system(s) involved. That is, if name names an object relative - * to this context, the result is the name of the same object, but + * Given a name (name) relative to this context, and the name (prefix) + * of this context relative to one of its ancestors, this method returns + * the composition of the two names using the syntax appropriate for the + * naming system(s) involved. That is, if name names an object relative + * to this context, the result is the name of the same object, but * relative to the ancestor context. None of the names may be null. - * + * * @param name a name relative to this context * @param prefix the name of this context relative to one of its ancestors * @return the composition of prefix and name @@ -596,7 +597,7 @@ public class SelectorContext implements /** * Composes the name of this context with a name relative to this context. - * + * * @param name a name relative to this context * @param prefix the name of this context relative to one of its ancestors * @return the composition of prefix and name @@ -610,10 +611,10 @@ public class SelectorContext implements /** - * Adds a new environment property to the environment of this context. If + * Adds a new environment property to the environment of this context. If * the property already exists, its value is overwritten. - * - * @param propName the name of the environment property to add; may not + * + * @param propName the name of the environment property to add; may not * be null * @param propVal the value of the property to add; may not be null * @exception NamingException if a naming exception is encountered @@ -626,9 +627,9 @@ public class SelectorContext implements /** - * Removes an environment property from the environment of this context. - * - * @param propName the name of the environment property to remove; + * Removes an environment property from the environment of this context. + * + * @param propName the name of the environment property to remove; * may not be null * @exception NamingException if a naming exception is encountered */ @@ -640,12 +641,12 @@ public class SelectorContext implements /** - * Retrieves the environment in effect for this context. See class - * description for more details on environment properties. - * The caller should not make any changes to the object returned: their - * effect on the context is undefined. The environment of this context + * Retrieves the environment in effect for this context. See class + * description for more details on environment properties. + * The caller should not make any changes to the object returned: their + * effect on the context is undefined. The environment of this context * may be changed using addToEnvironment() and removeFromEnvironment(). - * + * * @return the environment of this context; never null * @exception NamingException if a naming exception is encountered */ @@ -657,13 +658,13 @@ public class SelectorContext implements /** - * Closes this context. This method releases this context's resources - * immediately, instead of waiting for them to be released automatically + * Closes this context. This method releases this context's resources + * immediately, instead of waiting for them to be released automatically * by the garbage collector. - * This method is idempotent: invoking it on a context that has already - * been closed has no effect. Invoking any other method on a closed + * This method is idempotent: invoking it on a context that has already + * been closed has no effect. Invoking any other method on a closed * context is not allowed, and results in undefined behaviour. - * + * * @exception NamingException if a naming exception is encountered */ @Override @@ -676,15 +677,15 @@ public class SelectorContext implements /** * Retrieves the full name of this context within its own namespace. * <p> - * Many naming services have a notion of a "full name" for objects in - * their respective namespaces. For example, an LDAP entry has a - * distinguished name, and a DNS record has a fully qualified name. This - * method allows the client application to retrieve this name. The string - * returned by this method is not a JNDI composite name and should not be - * passed directly to context methods. In naming systems for which the - * notion of full name does not make sense, + * Many naming services have a notion of a "full name" for objects in + * their respective namespaces. For example, an LDAP entry has a + * distinguished name, and a DNS record has a fully qualified name. This + * method allows the client application to retrieve this name. The string + * returned by this method is not a JNDI composite name and should not be + * passed directly to context methods. In naming systems for which the + * notion of full name does not make sense, * OperationNotSupportedException is thrown. - * + * * @return this context's name in its own namespace; never null * @exception javax.naming.OperationNotSupportedException if the naming * system does not have the notion of a full name @@ -715,7 +716,7 @@ public class SelectorContext implements } Context initialContext = ContextBindings.getContext(ICName); if (initialContext == null) { - // Allocating a new context and binding it to the appropriate + // Allocating a new context and binding it to the appropriate // name initialContext = new NamingContext(env, ICName); ContextBindings.bindContext(ICName, initialContext); @@ -734,14 +735,14 @@ public class SelectorContext implements /** * Strips the URL header. - * + * * @return the parsed name - * @exception NamingException if there is no "java:" header or if no + * @exception NamingException if there is no "java:" header or if no * naming context has been bound to this thread */ - protected String parseName(String name) + protected String parseName(String name) throws NamingException { - + if ((!initialContext) && (name.startsWith(prefix))) { return (name.substring(prefixLength)); } else { @@ -752,29 +753,36 @@ public class SelectorContext implements (sm.getString("selectorContext.noJavaUrl")); } } - + } /** * Strips the URL header. - * + * * @return the parsed name - * @exception NamingException if there is no "java:" header or if no + * @exception NamingException if there is no "java:" header or if no * naming context has been bound to this thread */ - protected Name parseName(Name name) + protected Name parseName(Name name) throws NamingException { - if ((!initialContext) && (!name.isEmpty()) - && (name.get(0).equals(prefix))) { - return (name.getSuffix(1)); + if (!initialContext && !name.isEmpty() && + name.get(0).startsWith(prefix)) { + if (name.get(0).equals(prefix)) { + return name.getSuffix(1); + } else { + Name result = new CompositeName(); + result.add(name.get(0).substring(prefixLength)); + result.addAll(name.getSuffix(1)); + return result; + } } else { if (initialContext) { - return (name); + return name; } else { - throw new NamingException - (sm.getString("selectorContext.noJavaUrl")); + throw new NamingException( + sm.getString("selectorContext.noJavaUrl")); } } Modified: tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java?rev=1298635&r1=1298634&r2=1298635&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/naming/resources/TestNamingContext.java Thu Mar 8 22:46:08 2012 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.PrintWriter; import javax.naming.Binding; +import javax.naming.CompositeName; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingEnumeration; @@ -35,6 +36,7 @@ import static org.junit.Assert.assertTru import org.junit.Test; import org.apache.catalina.core.StandardContext; +import org.apache.catalina.deploy.ContextEnvironment; import org.apache.catalina.deploy.ContextResource; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; @@ -283,4 +285,62 @@ public class TestNamingContext extends T } } } + + @Test + public void testBug52830() throws Exception { + Tomcat tomcat = getTomcatInstance(); + tomcat.enableNaming(); + + // Must have a real docBase - just use temp + StandardContext ctx = (StandardContext) + tomcat.addContext("", System.getProperty("java.io.tmpdir")); + + // Create the resource + ContextEnvironment env = new ContextEnvironment(); + env.setName("boolean"); + env.setType(Boolean.class.getName()); + env.setValue("true"); + ctx.getNamingResources().addEnvironment(env); + + // Map the test Servlet + Bug52830Servlet bug52830Servlet = new Bug52830Servlet(); + Tomcat.addServlet(ctx, "bug52830Servlet", bug52830Servlet); + ctx.addServletMapping("/", "bug52830Servlet"); + + tomcat.start(); + + ByteChunk bc = new ByteChunk(); + int rc = getUrl("http://localhost:" + getPort() + "/", bc, null); + assertEquals(200, rc); + assertTrue(bc.toString().contains("truetrue")); + } + + public static final class Bug52830Servlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + public static final String JNDI_NAME = "java:comp/env/boolean"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + resp.setContentType("text/plain;UTF-8"); + PrintWriter out = resp.getWriter(); + + try { + Context initCtx = new InitialContext(); + + Boolean b1 = (Boolean) initCtx.lookup(JNDI_NAME); + Boolean b2 = (Boolean) initCtx.lookup( + new CompositeName(JNDI_NAME)); + + out.print(b1); + out.print(b2); + + } catch (NamingException ne) { + throw new ServletException(ne); + } + } + } } Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1298635&r1=1298634&r2=1298635&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Mar 8 22:46:08 2012 @@ -86,6 +86,11 @@ found. (markt) </fix> <fix> + <bug>52830</bug>: Correct JNDI lookups when using + <code>javax.naming.Name</code> to identify the resource rather than a + <code>java.lang.String</code>. (markt) + </fix> + <fix> <bug>52846</bug>: Make sure NonLoginAuthenticator registers not MemoryUser but GenericPrincipal into a session when UserDatabaseRealm is used. (kfujino) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org