You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Ethan Adams <et...@gmail.com> on 2006/04/04 02:22:33 UTC

JetspeedObjectID.equals() problem

I am running Jetspeed 2.0 final and have run into a problem where portlets
fail under what seem to be in a random pattern.  I noticed this when adding
many portlets to one page.  After further investigation, it seems that the
failing portlets were using the request of another portlet.  While tracking
it down, it seems to start the JetspeedRequestContext in the
getRequestForWindow:

    public HttpServletRequest getRequestForWindow( PortletWindow window )
    {
        if (!requestsForWindows.containsKey(window.getId()))
        {
            ServletRequestFactory reqFac = (ServletRequestFactory)
Jetspeed.getEngine().getFactory(
                    javax.servlet.http.HttpServletRequest.class);
            HttpServletRequest requestWrapper =
reqFac.getServletRequest(request,
window);
            requestsForWindows.put(window.getId(), requestWrapper);
            return requestWrapper;
        }
        else
        {
            return (HttpServletRequest) requestsForWindows.get(window.getId
());
        }

    }

And after yet more investigation, it appears the JetspeedObjectID was not
working as expected because the createPortletEntityId() method is not
creating a unique oid.  This caused the equals() to return true for non
related ObjectIDs, hence returning a request for one portlet when another is
requesting it.

So, I changed this:

        if (object instanceof JetspeedObjectID)
        {
            result = (oid == ((JetspeedObjectID) object).oid);
        }

To:

        if (object instanceof JetspeedObjectID)
        {
            result = (oid == ((JetspeedObjectID) object).oid) && (
stringOID.equals(((JetspeedObjectID) object).stringOID));
        }


Anyone see any concerns with this change?

I know there is a change to the J2 2.1 JetspeedObjectID that seems to
resolve this issue, but I can't revert to that now b/c I don't have the time
to upgrade.

Any input is appreciated.

Thanks,

Ethan

Re: JetspeedObjectID.equals() problem

Posted by Ethan Adams <et...@gmail.com>.
Yes.  I'm using the DB page manager, so that's probably why I see it more
often.

Thanks for the help.


On 4/4/06, Ate Douma <at...@douma.nu> wrote:
>
> Ethan Adams wrote:
> > I am running Jetspeed 2.0 final and have run into a problem where
> portlets
> > fail under what seem to be in a random pattern.  I noticed this when
> adding
> > many portlets to one page.  After further investigation, it seems that
> the
> > failing portlets were using the request of another portlet.  While
> tracking
> > it down, it seems to start the JetspeedRequestContext in the
> > getRequestForWindow:
> >
> >     public HttpServletRequest getRequestForWindow( PortletWindow window
> )
> >     {
> >         if (!requestsForWindows.containsKey(window.getId()))
> >         {
> >             ServletRequestFactory reqFac = (ServletRequestFactory)
> > Jetspeed.getEngine().getFactory(
> >                     javax.servlet.http.HttpServletRequest.class);
> >             HttpServletRequest requestWrapper =
> > reqFac.getServletRequest(request,
> > window);
> >             requestsForWindows.put(window.getId(), requestWrapper);
> >             return requestWrapper;
> >         }
> >         else
> >         {
> >             return (HttpServletRequest) requestsForWindows.get(
> window.getId
> > ());
> >         }
> >
> >     }
> >
> > And after yet more investigation, it appears the JetspeedObjectID was
> not
> > working as expected because the createPortletEntityId() method is not
> > creating a unique oid.  This caused the equals() to return true for non
> > related ObjectIDs, hence returning a request for one portlet when
> another is
> > requesting it.
> >
> > So, I changed this:
> >
> >         if (object instanceof JetspeedObjectID)
> >         {
> >             result = (oid == ((JetspeedObjectID) object).oid);
> >         }
> >
> > To:
> >
> >         if (object instanceof JetspeedObjectID)
> >         {
> >             result = (oid == ((JetspeedObjectID) object).oid) && (
> > stringOID.equals(((JetspeedObjectID) object).stringOID));
> >         }
> >
> >
> > Anyone see any concerns with this change?
> I rewrote the JetspeedObjectID implementation for 2.1 but didn't back port
> it
> to the 2.0.1 branch because it required api changes.
> Details: http://issues.apache.org/jira/browse/JS2-501.
>
> Your workaround seems ok.
>
> Regards, Ate
>
> Note: The existing implementation usually doesn't result in problems as
> long as
> you use reasonable long string id's for your fragments.
>
> >
> > I know there is a change to the J2 2.1 JetspeedObjectID that seems to
> > resolve this issue, but I can't revert to that now b/c I don't have the
> time
> > to upgrade.
> >
> > Any input is appreciated.
> >
> > Thanks,
> >
> > Ethan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: JetspeedObjectID.equals() problem

Posted by Ate Douma <at...@douma.nu>.
Ethan Adams wrote:
> I am running Jetspeed 2.0 final and have run into a problem where portlets
> fail under what seem to be in a random pattern.  I noticed this when adding
> many portlets to one page.  After further investigation, it seems that the
> failing portlets were using the request of another portlet.  While tracking
> it down, it seems to start the JetspeedRequestContext in the
> getRequestForWindow:
> 
>     public HttpServletRequest getRequestForWindow( PortletWindow window )
>     {
>         if (!requestsForWindows.containsKey(window.getId()))
>         {
>             ServletRequestFactory reqFac = (ServletRequestFactory)
> Jetspeed.getEngine().getFactory(
>                     javax.servlet.http.HttpServletRequest.class);
>             HttpServletRequest requestWrapper =
> reqFac.getServletRequest(request,
> window);
>             requestsForWindows.put(window.getId(), requestWrapper);
>             return requestWrapper;
>         }
>         else
>         {
>             return (HttpServletRequest) requestsForWindows.get(window.getId
> ());
>         }
> 
>     }
> 
> And after yet more investigation, it appears the JetspeedObjectID was not
> working as expected because the createPortletEntityId() method is not
> creating a unique oid.  This caused the equals() to return true for non
> related ObjectIDs, hence returning a request for one portlet when another is
> requesting it.
> 
> So, I changed this:
> 
>         if (object instanceof JetspeedObjectID)
>         {
>             result = (oid == ((JetspeedObjectID) object).oid);
>         }
> 
> To:
> 
>         if (object instanceof JetspeedObjectID)
>         {
>             result = (oid == ((JetspeedObjectID) object).oid) && (
> stringOID.equals(((JetspeedObjectID) object).stringOID));
>         }
> 
> 
> Anyone see any concerns with this change?
I rewrote the JetspeedObjectID implementation for 2.1 but didn't back port it
to the 2.0.1 branch because it required api changes.
Details: http://issues.apache.org/jira/browse/JS2-501.

Your workaround seems ok.

Regards, Ate

Note: The existing implementation usually doesn't result in problems as long as
you use reasonable long string id's for your fragments.

> 
> I know there is a change to the J2 2.1 JetspeedObjectID that seems to
> resolve this issue, but I can't revert to that now b/c I don't have the time
> to upgrade.
> 
> Any input is appreciated.
> 
> Thanks,
> 
> Ethan


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org