You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Stanton Sievers <ss...@us.ibm.com> on 2011/03/10 18:51:12 UTC

NPE in DefaultIframeUriManager when no default view is provided by the gadget

Hi,

I've run into a NullPointerException in 
org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri in 
the case where the gadget spec document neither defines a Content section 
with no "view" attribute nor a Content section with a "view" attribute 
containing "default".  An example gadget is posted below.

The NPE is thrown because the gadget.getCurrentView() call in 
makeRenderingUri() returns null.  The value returned by 
gadget.getCurrentView() is the same as the value returned by 
org.apache.shindig.gadgets.process.Processor.getView(GadgetContext, 
GadgetSpec).  Looking through the code, it seems that if the "view" param 
defined in the request is not found for the gadget or not defined at all, 
then we try to fall back to the "default" view.  However, if that doesn't 
exist either, then we get this NPE.

I'm wondering what the expected behavior here should be?  I'd rather we 
pick a random view for the rendering url then throw a NPE.

Thanks,
-Stanton


<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="BadViews"
               author="sample.testington@example.com">
  </ModulePrefs>
  <Content type="html" view="profile">
  </Content>
  <Content type="html" view="canvas">
  </Content>
</Module>



Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget

Posted by Ziv Horesh <zh...@gmail.com>.
I think the problem here is that the result iframe url depends on the view.
Both user pref paramaters and token can be either in the fragment or the
query params depend on the view.
I think the right approach here would be for the metadata request to return
an error (not an NPE) if the requested view and default view does not
exists.
Then the container will decide what to do - either show no content or
display the error.
You can still ask for metadata without iframe url which should work fine.
Container normally know what view they want to display, so I don't see a
reason for a container to issue two requests.

I am working on a CL for that.

Ziv


On Thu, Mar 10, 2011 at 2:59 PM, Stanton Sievers <ss...@us.ibm.com>wrote:

> I think following the pattern that iGoogle uses is probably the best route
> for now.  Throwing a NPE is something we should avoid.
>
> The more I think about this problem the more I'm thinking there's a bit of
> a bad pattern that we may run into.  We make a metadata request, providing
> the view as a param, then we get back the iframeurl with that view in it
> as a url param.  All of this happens before we know what views the gadget
> is able to render.  I guess one could perform some substitution on the
> iframeurl for the view that they really want... or perhaps make two
> metadata requests, the first to get the views and the second to get the
> iframeurl, but that's a bit wasteful.
>
> Have others run into this odd situation before?
>
> -Stanton
>
>
>
> From:   Ryan J Baxter/Westford/IBM@Lotus
> To:     dev@shindig.apache.org,
> Cc:     Stanton Sievers/Westford/IBM@Lotus
> Date:   03/10/2011 15:07
> Subject:        Re: NPE in DefaultIframeUriManager when no default view is
> provided by the gadget
>
>
>
> Yeah I took a look at the spec as well and couldn't find anything that
> covers this case.  This document from Google shows how iGoogle handles
> this case though...
> http://code.google.com/apis/gadgets/docs/ui.html
>
> We may way to consider doing what they do, which is displaying nothing.
>
> -Ryan
>
> Email: rjbaxter@us.ibm.com
> Phone: 978-899-3041
> developerWorks Profile
>
>
>
> From:   Paul Lindner <li...@inuus.com>
> To:     dev@shindig.apache.org,
> Cc:     Stanton Sievers/Westford/IBM@Lotus
> Date:   03/10/2011 02:14 PM
> Subject:        Re: NPE in DefaultIframeUriManager when no default view is
>
> provided by the gadget
>
>
>
> The spec doesn't really cover this case..
>
> If there's a view-less content section then it might make sense to add a
> view=default attribute.
>
> For cases where we're requesting a view that the gadget does not define
> then
> we should return some minimal default empty view for the gadget so things
> don't blow up.
>
>
> On Thu, Mar 10, 2011 at 9:51 AM, Stanton Sievers
> <ss...@us.ibm.com>wrote:
>
> > Hi,
> >
> > I've run into a NullPointerException in
> > org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri
> in
> > the case where the gadget spec document neither defines a Content
> section
> > with no "view" attribute nor a Content section with a "view" attribute
> > containing "default".  An example gadget is posted below.
> >
> > The NPE is thrown because the gadget.getCurrentView() call in
> > makeRenderingUri() returns null.  The value returned by
> > gadget.getCurrentView() is the same as the value returned by
> > org.apache.shindig.gadgets.process.Processor.getView(GadgetContext,
> > GadgetSpec).  Looking through the code, it seems that if the "view"
> param
> > defined in the request is not found for the gadget or not defined at
> all,
> > then we try to fall back to the "default" view.  However, if that
> doesn't
> > exist either, then we get this NPE.
> >
> > I'm wondering what the expected behavior here should be?  I'd rather we
> > pick a random view for the rendering url then throw a NPE.
> >
> > Thanks,
> > -Stanton
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <Module>
> >  <ModulePrefs title="BadViews"
> >               author="sample.testington@example.com">
> >  </ModulePrefs>
> >  <Content type="html" view="profile">
> >  </Content>
> >  <Content type="html" view="canvas">
> >  </Content>
> > </Module>
> >
> >
> >
>
>
> --
> Paul Lindner -- lindner@inuus.com -- linkedin.com/in/plindner
>
>
>
>
>
>
>

Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget

Posted by Stanton Sievers <ss...@us.ibm.com>.
I think following the pattern that iGoogle uses is probably the best route 
for now.  Throwing a NPE is something we should avoid.

The more I think about this problem the more I'm thinking there's a bit of 
a bad pattern that we may run into.  We make a metadata request, providing 
the view as a param, then we get back the iframeurl with that view in it 
as a url param.  All of this happens before we know what views the gadget 
is able to render.  I guess one could perform some substitution on the 
iframeurl for the view that they really want... or perhaps make two 
metadata requests, the first to get the views and the second to get the 
iframeurl, but that's a bit wasteful.

Have others run into this odd situation before?

-Stanton



From:   Ryan J Baxter/Westford/IBM@Lotus
To:     dev@shindig.apache.org, 
Cc:     Stanton Sievers/Westford/IBM@Lotus
Date:   03/10/2011 15:07
Subject:        Re: NPE in DefaultIframeUriManager when no default view is 
provided by the gadget



Yeah I took a look at the spec as well and couldn't find anything that 
covers this case.  This document from Google shows how iGoogle handles 
this case though...
http://code.google.com/apis/gadgets/docs/ui.html

We may way to consider doing what they do, which is displaying nothing.

-Ryan

Email: rjbaxter@us.ibm.com
Phone: 978-899-3041
developerWorks Profile



From:   Paul Lindner <li...@inuus.com>
To:     dev@shindig.apache.org, 
Cc:     Stanton Sievers/Westford/IBM@Lotus
Date:   03/10/2011 02:14 PM
Subject:        Re: NPE in DefaultIframeUriManager when no default view is 

provided by the gadget



The spec doesn't really cover this case..

If there's a view-less content section then it might make sense to add a
view=default attribute.

For cases where we're requesting a view that the gadget does not define 
then
we should return some minimal default empty view for the gadget so things
don't blow up.


On Thu, Mar 10, 2011 at 9:51 AM, Stanton Sievers 
<ss...@us.ibm.com>wrote:

> Hi,
>
> I've run into a NullPointerException in
> org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri 
in
> the case where the gadget spec document neither defines a Content 
section
> with no "view" attribute nor a Content section with a "view" attribute
> containing "default".  An example gadget is posted below.
>
> The NPE is thrown because the gadget.getCurrentView() call in
> makeRenderingUri() returns null.  The value returned by
> gadget.getCurrentView() is the same as the value returned by
> org.apache.shindig.gadgets.process.Processor.getView(GadgetContext,
> GadgetSpec).  Looking through the code, it seems that if the "view" 
param
> defined in the request is not found for the gadget or not defined at 
all,
> then we try to fall back to the "default" view.  However, if that 
doesn't
> exist either, then we get this NPE.
>
> I'm wondering what the expected behavior here should be?  I'd rather we
> pick a random view for the rendering url then throw a NPE.
>
> Thanks,
> -Stanton
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
>  <ModulePrefs title="BadViews"
>               author="sample.testington@example.com">
>  </ModulePrefs>
>  <Content type="html" view="profile">
>  </Content>
>  <Content type="html" view="canvas">
>  </Content>
> </Module>
>
>
>


-- 
Paul Lindner -- lindner@inuus.com -- linkedin.com/in/plindner







Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget

Posted by Ryan J Baxter <rj...@us.ibm.com>.
Yeah I took a look at the spec as well and couldn't find anything that 
covers this case.  This document from Google shows how iGoogle handles 
this case though...
http://code.google.com/apis/gadgets/docs/ui.html

We may way to consider doing what they do, which is displaying nothing.

-Ryan

Email: rjbaxter@us.ibm.com
Phone: 978-899-3041
developerWorks Profile



From:   Paul Lindner <li...@inuus.com>
To:     dev@shindig.apache.org, 
Cc:     Stanton Sievers/Westford/IBM@Lotus
Date:   03/10/2011 02:14 PM
Subject:        Re: NPE in DefaultIframeUriManager when no default view is 
provided by the gadget



The spec doesn't really cover this case..

If there's a view-less content section then it might make sense to add a
view=default attribute.

For cases where we're requesting a view that the gadget does not define 
then
we should return some minimal default empty view for the gadget so things
don't blow up.


On Thu, Mar 10, 2011 at 9:51 AM, Stanton Sievers 
<ss...@us.ibm.com>wrote:

> Hi,
>
> I've run into a NullPointerException in
> org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri 
in
> the case where the gadget spec document neither defines a Content 
section
> with no "view" attribute nor a Content section with a "view" attribute
> containing "default".  An example gadget is posted below.
>
> The NPE is thrown because the gadget.getCurrentView() call in
> makeRenderingUri() returns null.  The value returned by
> gadget.getCurrentView() is the same as the value returned by
> org.apache.shindig.gadgets.process.Processor.getView(GadgetContext,
> GadgetSpec).  Looking through the code, it seems that if the "view" 
param
> defined in the request is not found for the gadget or not defined at 
all,
> then we try to fall back to the "default" view.  However, if that 
doesn't
> exist either, then we get this NPE.
>
> I'm wondering what the expected behavior here should be?  I'd rather we
> pick a random view for the rendering url then throw a NPE.
>
> Thanks,
> -Stanton
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
>  <ModulePrefs title="BadViews"
>               author="sample.testington@example.com">
>  </ModulePrefs>
>  <Content type="html" view="profile">
>  </Content>
>  <Content type="html" view="canvas">
>  </Content>
> </Module>
>
>
>


-- 
Paul Lindner -- lindner@inuus.com -- linkedin.com/in/plindner




Re: NPE in DefaultIframeUriManager when no default view is provided by the gadget

Posted by Paul Lindner <li...@inuus.com>.
The spec doesn't really cover this case..

If there's a view-less content section then it might make sense to add a
view=default attribute.

For cases where we're requesting a view that the gadget does not define then
we should return some minimal default empty view for the gadget so things
don't blow up.


On Thu, Mar 10, 2011 at 9:51 AM, Stanton Sievers <ss...@us.ibm.com>wrote:

> Hi,
>
> I've run into a NullPointerException in
> org.apache.shindig.gadgets.uri.DefaultIframeUriManager.makeRenderingUri in
> the case where the gadget spec document neither defines a Content section
> with no "view" attribute nor a Content section with a "view" attribute
> containing "default".  An example gadget is posted below.
>
> The NPE is thrown because the gadget.getCurrentView() call in
> makeRenderingUri() returns null.  The value returned by
> gadget.getCurrentView() is the same as the value returned by
> org.apache.shindig.gadgets.process.Processor.getView(GadgetContext,
> GadgetSpec).  Looking through the code, it seems that if the "view" param
> defined in the request is not found for the gadget or not defined at all,
> then we try to fall back to the "default" view.  However, if that doesn't
> exist either, then we get this NPE.
>
> I'm wondering what the expected behavior here should be?  I'd rather we
> pick a random view for the rendering url then throw a NPE.
>
> Thanks,
> -Stanton
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Module>
>  <ModulePrefs title="BadViews"
>               author="sample.testington@example.com">
>  </ModulePrefs>
>  <Content type="html" view="profile">
>  </Content>
>  <Content type="html" view="canvas">
>  </Content>
> </Module>
>
>
>


-- 
Paul Lindner -- lindner@inuus.com -- linkedin.com/in/plindner