You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Paul Lindner <pl...@hi5.com> on 2008/02/01 16:17:49 UTC

Potential bug in new views code

Just ran through another round of java inspections and noticed some ==
comparisions of strings. (See patch below to fix this)

Can someone commit this while I await access?

===================================================================
--- gadgets/src/main/java/org/apache/shindig/gadgets/GadgetSpecParser.java      (revision 617421)
+++ gadgets/src/main/java/org/apache/shindig/gadgets/GadgetSpecParser.java      (working copy)
@@ -552,7 +547,7 @@
     public String getContentData(String view) {
       Check.is(contentType == ContentType.HTML,
                "getContentData() requires contentType HTML");
-      if (view == null || view == "") {
+      if (view == null || view.length() == 0) {
         view = DEFAULT_VIEW;
       }
       if (!contentData.containsKey(view)) {

===================================================================
--- gadgets/src/main/java/org/apache/shindig/gadgets/http/GadgetRenderingServlet.java   (revision 617421
)
+++ gadgets/src/main/java/org/apache/shindig/gadgets/http/GadgetRenderingServlet.java   (working copy)
@@ -152,7 +152,7 @@
 
     Gadget gadget = null;
     String view = req.getParameter("view");
-    view = (view == null || view == "") ? GadgetSpec.DEFAULT_VIEW : view;
+    view = (view == null || view.length() == 0) ? GadgetSpec.DEFAULT_VIEW : view;
     try {
       gadget = gadgetServer.processGadget(gadgetId,
                                           getPrefsFromRequest(req),

-- 
Paul Lindner
hi5 Architect
plindner@hi5.com

Re: Potential bug in new views code

Posted by John Hjelmstad <fa...@google.com>.
Hi Paul:

Good catch, and a silly oversight on my part. I've just committed the
change.

John

On Fri, Feb 1, 2008 at 7:17 AM, Paul Lindner <pl...@hi5.com> wrote:

> Just ran through another round of java inspections and noticed some ==
> comparisions of strings. (See patch below to fix this)
>
> Can someone commit this while I await access?
>
> ===================================================================
> --- gadgets/src/main/java/org/apache/shindig/gadgets/GadgetSpecParser.java
>      (revision 617421)
> +++ gadgets/src/main/java/org/apache/shindig/gadgets/GadgetSpecParser.java
>      (working copy)
> @@ -552,7 +547,7 @@
>     public String getContentData(String view) {
>       Check.is(contentType == ContentType.HTML,
>                "getContentData() requires contentType HTML");
> -      if (view == null || view == "") {
> +      if (view == null || view.length() == 0) {
>         view = DEFAULT_VIEW;
>       }
>       if (!contentData.containsKey(view)) {
>
> ===================================================================
> ---
> gadgets/src/main/java/org/apache/shindig/gadgets/http/GadgetRenderingServlet.java
>   (revision 617421
> )
> +++
> gadgets/src/main/java/org/apache/shindig/gadgets/http/GadgetRenderingServlet.java
>   (working copy)
> @@ -152,7 +152,7 @@
>
>     Gadget gadget = null;
>     String view = req.getParameter("view");
> -    view = (view == null || view == "") ? GadgetSpec.DEFAULT_VIEW : view;
> +    view = (view == null || view.length() == 0) ? GadgetSpec.DEFAULT_VIEW: view;
>     try {
>       gadget = gadgetServer.processGadget(gadgetId,
>                                           getPrefsFromRequest(req),
>
> --
> Paul Lindner
> hi5 Architect
> plindner@hi5.com
>