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

Issue 32111: Proxied image resizing (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
16 years, 10 months ago by fmil
Modified:
16 years, 5 months ago
Reviewers:
shindig.remailer, louiscryan, etnu00
Base URL:
http://svn.apache.org/repos/asf/incubator/shindig/trunk/
Visibility:
Public.

Description

There are two patches squashed into one. Since the second removes some extra work, it's ok to present them together. --- The code and cleanup to support proxied image resizing. Based on the initial work of Paul Lindner of Hi5. His work in turn is based on further contributions, but I don't know at present which ones. New contributions are Copyright (c) 2009 Google. Rest by Paul Lindner. o Reorganized the image rewriter implementation from Paul, and corrected a few bugs in the image dimensions computation. o A few readability changes. o Verified new behavior and added the tests to guard against accidental further behavior changes. o Modified the caching policy to take into account the resizing URL arguments required for resizing to work. o Factored the cache key building into a builder class that ensures backward compatibility of the generated cache keys, and makes building cache keys easier in general. o Added the tests to guard against accidental behavior changes in the cache key builder. o Fitted all the pieces back together again. --- Removed the text fixture that depends on the used JVM. The checksum-based tests turned out not to be portable across JVMs, so I had to exclude them, until I get a better idea on how to test the resize, without duplicating the actual resizing code. Changes Copyright (c) 2009 Google

Patch Set 1 #

Patch Set 2 : This time with the new file CacheKeyBuilder.java and tests #

Total comments: 16

Patch Set 3 : Updated after review comments. #

Patch Set 4 : Reinforces the image resizing tests #

Patch Set 5 : Removed stale comment #

Patch Set 6 : Intermittent commit increased the diff size, resending. #

Patch Set 7 : Readding new files #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+943 lines, -391 lines) Patch
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/AbstractHttpCache.java View 1 2 3 4 5 9 chunks +36 lines, -36 lines 2 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/CacheKeyBuilder.java View 2 1 chunk +166 lines, -0 lines 2 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpRequest.java View 1 2 3 4 5 5 chunks +22 lines, -0 lines 6 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java View 1 2 3 4 5 3 chunks +233 lines, -65 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/ImageRewriter.java View 1 2 3 4 5 2 chunks +11 lines, -12 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/ImageUtils.java View 1 2 3 4 5 3 chunks +78 lines, -1 line 2 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/NoOpImageRewriter.java View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyBase.java View 1 2 3 4 5 4 chunks +11 lines, -3 lines 4 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyHandler.java View 1 2 3 4 5 4 chunks +31 lines, -13 lines 2 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyServlet.java View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/http/AbstractHttpCacheTest.java View 1 2 3 4 5 3 chunks +71 lines, -187 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/http/CacheKeyBuilderTest.java View 2 1 chunk +106 lines, -0 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/image/ImageRewriterTest.java View 1 2 3 4 5 1 chunk +150 lines, -68 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/servlet/ProxyHandlerTest.java View 1 2 3 4 5 3 chunks +24 lines, -2 lines 0 comments Download
java/gadgets/src/test/resources/org/apache/shindig/gadgets/rewrite/image/dog.gif View 0 chunks +-1 lines, --1 lines 0 comments Download

Messages

Total messages: 11
fmil
16 years, 10 months ago (2009-04-02 18:28:51 UTC) #1
fmil
This time with the new file CacheKeyBuilder.java and tests
16 years, 10 months ago (2009-04-02 18:44:20 UTC) #2
louiscryan
Looks good, a few functional points. http://codereview.appspot.com/32111/diff/19/1009 File java/gadgets/src/main/java/org/apache/shindig/gadgets/http/AbstractHttpCache.java (right): http://codereview.appspot.com/32111/diff/19/1009#newcode116 Line 116: * - ...
16 years, 10 months ago (2009-04-02 23:09:19 UTC) #3
fmil
I handled most of the issues you raised. The patch update will follow soon. http://codereview.appspot.com/32111/diff/19/1009 ...
16 years, 10 months ago (2009-04-03 21:57:42 UTC) #4
fmil
Updated after review comments.
16 years, 10 months ago (2009-04-07 02:53:59 UTC) #5
fmil
Reinforces the image resizing tests
16 years, 10 months ago (2009-04-07 17:48:02 UTC) #6
fmil
Removed stale comment
16 years, 10 months ago (2009-04-07 17:55:05 UTC) #7
fmil
Intermittent commit increased the diff size, resending.
16 years, 10 months ago (2009-04-07 17:57:49 UTC) #8
fmil
Readding new files
16 years, 10 months ago (2009-04-07 17:59:39 UTC) #9
etnu00
http://codereview.appspot.com/32111/diff/1061/1069 File java/gadgets/src/main/java/org/apache/shindig/gadgets/http/AbstractHttpCache.java (right): http://codereview.appspot.com/32111/diff/1061/1069#newcode144 Line 144: .setResizeQuality(request.getParamAsInteger(PARAM_RESIZE_QUALITY)); The cache having explicit knowledge of image ...
16 years, 10 months ago (2009-04-08 04:41:31 UTC) #10
fmil
16 years, 10 months ago (2009-04-09 00:40:42 UTC) #11
Here's the answer to your comments.  

Can you please continue the review at:
http://codereview.appspot.com/32150

Thanks,
f

http://codereview.appspot.com/32111/diff/1061/1069
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/AbstractHttpCache.java
(right):

http://codereview.appspot.com/32111/diff/1061/1069#newcode144
Line 144: .setResizeQuality(request.getParamAsInteger(PARAM_RESIZE_QUALITY));
On 2009/04/08 04:41:31, etnu00 wrote:
> The cache having explicit knowledge of image manipulation is really not
> appropriate.
> It would be a lot better to simply take all of those extra params that
getParam*
> are returning and append those.

Done.

> The cache key can then become a set of key / value pairs (a map), without any
> explicit knowledge of image processing.

I understand that it is not possible to convert the cache key to a (sorted) map
in one go, as this would invalidate persistent caches.  

The current cache key builder takes care that the keys don't change for the URLs
that don't use the extra parameters.

http://codereview.appspot.com/32111/diff/1061/1068
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/CacheKeyBuilder.java
(right):

http://codereview.appspot.com/32111/diff/1061/1068#newcode33
Line 33: public class CacheKeyBuilder {
On 2009/04/08 04:41:31, etnu00 wrote:
> The strongly typed nature of this class is really overkill, and it creates a
> situation where one class (this one) has to have explicit knowledge of many
> parts of the system.
> 
> Just using the sorted map to build cache keys avoids this problem.

Done, modulo the issue with the key backward compatibility.

http://codereview.appspot.com/32111/diff/1061/1070
File java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpRequest.java
(right):

http://codereview.appspot.com/32111/diff/1061/1070#newcode55
Line 55: private final Map<String, String> params = Maps.newHashMap();
On 2009/04/08 04:41:31, etnu00 wrote:
> When adding this, all of the existing ad hoc params should be included as
well.
> This is probably best handled with a follow up patch for now though, to keep
the
> size of this change small.

Yes please, I prefer separating this.

http://codereview.appspot.com/32111/diff/1061/1070#newcode396
Line 396: String value = params.get(paramName);
On 2009/04/08 04:41:31, etnu00 wrote:
> This is a redundant hash lookup. Use params.get and perform a null check on
that
> instead of using containsKey.

Done.

http://codereview.appspot.com/32111/diff/1061/1070#newcode401
Line 401: params.put(paramName, paramValue.toString());
On 2009/04/08 04:41:31, etnu00 wrote:
> String.valueOf is a bit more robust here.

Done.

http://codereview.appspot.com/32111/diff/1061/1075
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/ImageUtils.java
(right):

http://codereview.appspot.com/32111/diff/1061/1075#newcode156
Line 156: {
On 2009/04/08 04:41:31, etnu00 wrote:
> This should be on the same line as the closing paren above.

Done.

http://codereview.appspot.com/32111/diff/1061/1071
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyBase.java
(right):

http://codereview.appspot.com/32111/diff/1061/1071#newcode129
Line 129: // additional referrer checks.
On 2009/04/08 04:41:31, etnu00 wrote:
> The HTTP spec actually spells this 'referer'. It' stupid, but it's not a
mistake
> here.

Done, pardon the wrongful exercise of OCD.

http://codereview.appspot.com/32111/diff/1061/1071#newcode148
Line 148: return true;
On 2009/04/08 04:41:31, etnu00 wrote:
> This makes it so that resized images will never be cached. I don't think
that's
> the behavior you actually want.

Done.

http://codereview.appspot.com/32111/diff/1061/1072
File
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyHandler.java
(right):

http://codereview.appspot.com/32111/diff/1061/1072#newcode69
Line 69: private HttpRequest buildHttpRequest(HttpServletRequest servletRequest)
throws GadgetException {
On 2009/04/08 04:41:31, etnu00 wrote:
> Please don't rename parameters or variables unless it's actually material to
the
> code in question. It complicates diffs unnecessarily.

Done.
Sign in to reply to this message.

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