Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(181)

Issue 206041: Handle request with no container or hostname

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 11 months ago by zhoresh
Modified:
15 years, 11 months ago
Reviewers:
johnfargo, shindig.remailer
Base URL:
http://svn.apache.org/repos/asf/shindig/trunk/
Visibility:
Public.

Description

Instead of raising an exception handling bad request by defaulting to empty list of services.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -6 lines) Patch
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookup.java View 1 chunk +4 lines, -3 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/render/DefaultRpcServiceLookupTest.java View 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 2
zhoresh
15 years, 11 months ago (2010-02-09 03:48:28 UTC) #1
johnfargo
15 years, 11 months ago (2010-02-10 03:11:56 UTC) #2
Thanks Ziv, committed.

On Mon, Feb 8, 2010 at 7:48 PM, <zhoresh@gmail.com> 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
>
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b