Bugs item #663283, was opened at 2003-01-06 19:33
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=663283&group_id=22866
Category: None
Group: v4.0
Status: Open
Resolution: None
Priority: 5
Submitted By: Rod Burgett (rodburgett)
Assigned to: Nobody/Anonymous (nobody)
Summary: NamingContext.lookup(Name) changes Name parameter
Initial Comment:
OS: Win2K, v5.0
JDK: Sun 1.3.1_04
Category: JBossNS
1) The 'Object lookup(javax.naming.Name name)'
method in the org.jnp.interfaces.NamingContext class
has a side effect of changing the state of the input Name
instance when the input Name includes a scheme prefix
such as "java:". For example, using a Name instance
created from "java:comp/env", display name.toString()
before and after calling ctx.lookup(name). The displayed
strings are different.
2) The org.jnp.client.Main tester for this class does not
currently check for this side effect.
Proposed fix 2):
Applying the following 'diff' to org.jnp.client.Main.java will
expose bug 1) above.
diff -r1.7 Main.java
141,143c141,156
< server = ctx.lookup"jnp://localhost/test/server2");
< System.out.println("jnp://localhost/test/server2
lookup:"+server);
<
---
> //...updated 03-jan-2003, rodB, to check lookup using
Name and side effects
> String
svr2NameString "jnp://localhost/test/server2";
> server = ctx.lookup(svr2NameString);
> System.out.println
(svr2NameString+"lookup:"+server);
> Name svr2Name = ctx.getNameParser
(svr2NameString).parse(svr2NameString);
> Name svr2NameClone = (Name) svr2Name.clone
();
> server = ctx.lookup(svr2Name);
> System.out.println(svr2NameString+" lookup,
using Name:"+server);
> if ( ! svr2Name.equals( svr2NameClone) )
> {
> System.out.println("Oops! ctx.lookup()
changed state of Name " +
> "parameter
from "+svr2NameClone.toString() +
> ") to ("+svr2Name.toString()+")");
> }
> //...end of 03-jan-2003 changes, rodB
>
Proposed fix 1):
Applying the following 'diff' to
org.jnp.interfaces.NamingContext.java will correct bug 1)
above.
diff -r1.23 NamingContext.java
357a358,359
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
404a407,408
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
452a457,458
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
624a631,632
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
667a676,677
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
697a708,709
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
798a811,812
> //...one line below added 03-jan-2003, rodB, to avoid
side effects on name
> name = (Name) name.clone ();
Why so many identical new lines? Many of the
javax.naming.Context interface methods, e.g. bind,
rebind, list, unbind, use a Name instance for input. In
this implementation, many follow a similar pattern to
ensure common handling of the input Name.
Why not fix it in just one place? The common handling
pattern includes calling getEnv(), a private method,
which in turn calls parseNameForScheme(), a static
method with package visibility. It is
parseNameForScheme that updates it's input Name, but
lookup, list, bind, etc. make subsequent calls to
getAbsoluteName(), which will operate properly only on
a Name exhibiting this side effect.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=663283&group_id=22866
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development