You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by Pete <pd...@yahoo.com> on 2006/02/06 17:24:18 UTC

WSRPServletRequestWrapperImpl bug

WSRPServletRequestWrapperImpl.getParameter 
https://svn.apache.org/repos/asf/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/WSRPServletRequestWrapperImpl.java

I believe has a bug.  

WSRPServletRequestWrapperImpl extends
ServletRequestImpl which extends
javax.servlet.http.HttpServletRequestWrapper
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequestWrapper.html#getParameter(java.lang.String)

States that 
Returns:
    a String representing the single value of the
parameter

WSRPServletRequestWrapperImpl

	public String getParameter(String name) 
	{
		return (String) this.getParameterMap().get(name);

	}

Does not ensure the value returned from the parameter
map is a String.  It can in fact be an array of
strings.  The code should be enhanced to test for non
String and return only a String.

Something like:
	public String getParameter(String name) 
	{
		String value = null;
		Object o = this.getParameterMap().get(name);
		if (o != null && o instanceof String[]) {
			value = ((String[])o)[0];
		} else {
			value = (String)o;
		}
		return (String) value;

	}


Make sense?  This was causing a
java.lang.ClassCastException without this fix.

NOTE: PortletInvokerImpl creates the WSRPServletRequestWrapperImpl.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: WSRPServletRequestWrapperImpl bug

Posted by Carsten Ziegeler <cz...@apache.org>.
Yes, I think you're right - I just fixed this.

Thanks!!

Carsten

Pete schrieb:
> WSRPServletRequestWrapperImpl.getParameter 
> https://svn.apache.org/repos/asf/portals/wsrp4j/trunk/producer/src/java/org/apache/wsrp4j/producer/provider/pluto/driver/WSRPServletRequestWrapperImpl.java
> 
> I believe has a bug.  
> 
> WSRPServletRequestWrapperImpl extends
> ServletRequestImpl which extends
> javax.servlet.http.HttpServletRequestWrapper
> http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequestWrapper.html#getParameter(java.lang.String)
> 
> States that 
> Returns:
>     a String representing the single value of the
> parameter
> 
> WSRPServletRequestWrapperImpl
> 
> 	public String getParameter(String name) 
> 	{
> 		return (String) this.getParameterMap().get(name);
> 
> 	}
> 
> Does not ensure the value returned from the parameter
> map is a String.  It can in fact be an array of
> strings.  The code should be enhanced to test for non
> String and return only a String.
> 
> Something like:
> 	public String getParameter(String name) 
> 	{
> 		String value = null;
> 		Object o = this.getParameterMap().get(name);
> 		if (o != null && o instanceof String[]) {
> 			value = ((String[])o)[0];
> 		} else {
> 			value = (String)o;
> 		}
> 		return (String) value;
> 
> 	}
> 
> 
> Make sense?  This was causing a
> java.lang.ClassCastException without this fix.
> 
> NOTE: PortletInvokerImpl creates the WSRPServletRequestWrapperImpl.
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/