[
http://issues.apache.org/jira/browse/AXIS-2073?page=comments#action_12314171 ]
Aaron Hamid commented on AXIS-2073:
-----------------------------------
Hi guys, can we make the implementation of getAllPropertyNames the default for
getPropertyNames? Is there a reason to not expose all keys in the
MessageContext getPropertyNames (as even they are accessible through
getProperty())?
For example, I have a JAX-RPC style handler like this:
public boolean handleRequest(javax.xml.rpc.handler.MessageContext context) {
Iterator it = context.getPropertyNames();
HashMap map = new HashMap();
while (it.hasNext()) {
String s = (String) it.next();
map.put(s, context.getProperty(s));
}
...
}
and a client which does:
MyApp app = new MyAppLocator().getMyApp();
app._setProperty("foo", "bar");
The result is that any property set on the stub (e.g. "foo") will not be
visible in MessageContext object presented to the handler (even though it will
be accessible through getProperty()). Since javax.xml.rpc.handler.Message
context only exposes getPropertyNames(), I must cast to the Apache
implementation in order to call getAllPropertyNames. Can we just make that
implementation the default?
Here's a from-memory patch:
- /**
- * Returns an <code>Iterator</code> view of the names of the properties in
- * this <code>MessageContext</code>.
- *
- * @return an <code>Iterator</code> over all property names
- */
- public java.util.Iterator getPropertyNames() {
- // fixme: this is potentially unsafe for the caller - changing the
- // properties will kill the iterator. Consider iterating over a copy:
- // return new HashSet(bag.keySet()).iterator();
- return bag.keySet().iterator();
- }
-
/**
* Returns an Iterator view of the names of the properties
* in this MessageContext and any parents of the LockableHashtable
* @return Iterator for the property names
*/
- public java.util.Iterator getAllPropertyNames() {
+ public java.util.Iterator getPropertyNames() {
return bag.getAllKeys().iterator();
}
Note that this (somewhat) resolves the issue in the comment of the old
getPropertyNames() because the implementation of getAllKeys() performs a copy
of the key set. Also note that this patch is not particularly sensitive to
preserving semantics in some backward-compatible way...one may want to preserve
the existing functionality of getPropertyNames under something like
getImmediatePropertyNames, but my hunch is that this has no value).
> MessageContext getPropertyNames is broken
> -----------------------------------------
>
> Key: AXIS-2073
> URL: http://issues.apache.org/jira/browse/AXIS-2073
> Project: Apache Axis
> Type: Bug
> Components: Basic Architecture
> Versions: 1.1
> Environment: Operating System: Other
> Platform: Other
> Reporter: Aaron Hamid
> Assignee: Axis Developers Mailing List
>
> The getPropertyNames() call on the MessageContext object made available to a
> jax-rpc GenericHandler subclass handler in handleRequest() does NOT enumerate
> all the property names. getProperty() calls will return values for
> properties
> which have been set, but are NOT visible through getPropertyNames().
> My hunch is that since the get() call on LockableHashtable inspects the
> parent
> Hashtable, that the keySet() method, which is not overridden, does NOT
> inspect
> the parent Hashtable, and is returning an empty keyset.
> For my test, properties are set using the _setProperty() call on either a
> client Stub object, or Call object.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira