Thanks Ziv, committed.

On Mon, Feb 8, 2010 at 7:48 PM, <[email protected]> wrote:

> Reviewers: shindig.remailer_gmail.com, johnfargo,
>
> Description:
>
> Instead of raising an exception handling bad request by defaulting to
> empty list of services.
>
>
> Please review this at http://codereview.appspot.com/206041/show
>
> Affected files:
>
>  
> java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookup.java
>
>  
> java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
>
>
> ### Eclipse Workspace Patch 1.0
> #P shindig-project
> Index:
> java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookup.java
> ===================================================================
> ---
> java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookup.java
>       (revision 907754)
> +++
> java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookup.java
>       (working copy)
> @@ -65,9 +65,10 @@
>    * @return Map of Services, by endpoint for the given container.
>    */
>   public Multimap<String, String> getServicesFor(String container, String
> host) {
> -    Preconditions.checkNotNull(container);
> -    Preconditions.checkArgument(container.length() != 0);
> -    Preconditions.checkNotNull(host);
> +    // Support empty container or host by providing empty services:
> +    if (container == null || container.length() == 0 || host == null) {
> +      return ImmutableMultimap.<String, String>builder().build();
> +    }
>
>     Multimap<String, String> foundServices =
> containerServices.get(container);
>     if (foundServices == null) {
> Index:
> java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
> ===================================================================
> ---
> java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
>   (revision 907754)
> +++
> java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java
>   (working copy)
> @@ -51,11 +51,11 @@
>     assertEquals(0, services.size());
>   }
>
> -  @Test(expected=Exception.class)
> +  @Test
>   public void testGetServicesForContainer_Null() throws Exception {
>     String container = null;
> -    svcLookup.getServicesFor(container, host);
> -    fail("Should have thrown an exception for an invalid container");
> +    Multimap<String, String> services =
> svcLookup.getServicesFor(container, host);
> +    assertEquals(0, services.size());
>   }
>
>   @Test
>
>
>

Reply via email to