[ 
https://issues.apache.org/jira/browse/PB-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12623259#action_12623259
 ] 

Tim Boudreau commented on PB-84:
--------------------------------

> If you look at the rest of following code within this method, you'll notice 
> the *random* 
> generated Double object put in the session is put in there only for a for a 
> very short time 
> and *replaced* within the same method almost immediately with a String 
> object. 

Okay, now I understand what you're trying to do here - that helps.  I now 
understand what the use of random is about, and
                portletWindowId = value;
is definitely wrong.

But portletWindowId is only reset if two tests are true - 
names.hasMoreElements() 
and 
PortletSessionUtil.decodeAttributeName(name).equals(PORTLET_WINDOW_ID) && 
value.equals(session.getAttribute(name,PortletSession.APPLICATION_SCOPE)

- otherwise the Double remains there, and a subsequent call to the same method 
will trigger a CCE.  From your description, it does not sound like you intend 
to leave the random Double there, but if either of the two tests above fails, 
that is what it will do.  If either of the two tests failing means that the 
environment is completely unusable (I don't know portlets well enough to be 
sure if that's true or not), some kind of failure may be inevitable, but it 
would be better to restore the value and not have the failure look like it is 
in your code.

I don't work on portal software at Sun(well, I spent six hours today inside 
OpenPortal's code, but that wasn't for Sun), so I don't know the history of why 
this is the way it is with JBoss or OpenPortal - I'm just trying to help Jon 
get some work done.

I agree if the spec says it should be a string, then it should be a string;  I 
could also believe that if the server is really putting it as some other type, 
that both companies might have customers who are depending on it being a Double 
(unless this is really just a result of this method being called twice and one 
of the tests failing), and be at risk if they break backward compatibility to 
comply with the spec.  

But my first assumption would be that this code is being called twice, the 
second time after putting a Double into the map and failing one of the tests in 
getPortletWindowId().  

I'll try your patch and post output here.

> CCE in PortletWindowUtils.getPortletWindowId
> --------------------------------------------
>
>                 Key: PB-84
>                 URL: https://issues.apache.org/jira/browse/PB-84
>             Project: Portals Bridges
>          Issue Type: Bug
>          Components: common
>    Affects Versions: 1.0
>         Environment: Mac OS, Wicket Portlets, OpenPortal Portlet Container
>            Reporter: Tim Boudreau
>         Attachments: portals-bridges-common-1.0.4.jar
>
>
> I'm trying to get wicket portlet support working over OpenPortal.  I've 
> hacked together implementations of ServletContextProvider and 
> PortletResourceURLFactory - just required exposing WicketFilter from the 
> Application to get the necessary data.  I can deploy a portlet, but...
> I'm getting this exception. 
> java.lang.ClassCastException: java.lang.Double
>         at 
> org.apache.portals.bridges.util.PortletWindowUtils.getPortletWindowId(PortletWindowUtils.java:45)
> Looking at the code, this seems like a clear bug:  The method casts to String 
> here:
> (String)session.getAttribute(PORTLET_WINDOW_ID);
> and if null fills in the value with an instance of Double.  If it's going to 
> put a Double there, it should probably not expect a String - this exception 
> will occur any time this method is called twice for a PortletSession, it will 
> throw the CCE the second time it is called.
> Since the value is not used, probably simply changing it to 
>         Object portletWindowId = session.getAttribute(PORTLET_WINDOW_ID);
> would fix it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to