A few factoring comments. thanks Ziv!
http://codereview.appspot.com/157054/diff/1006/6 File java/gadgets/src/main/java/org/apache/shindig/gadgets/encoding/EncodingDetector.java (right): http://codereview.appspot.com/157054/diff/1006/6#newcode60 java/gadgets/src/main/java/org/apache/shindig/gadgets/encoding/EncodingDetector.java:60: return alternateDecoder.detectEncoding(input); IMO we should return ISO_8859_1 here to keep the API intact. We'd then rename CustomEncodingDetector to FallbackEncodingDetector, documenting that it only applies when !assume88591IfNotUtf8, putting the slow ICU impl in the fallback. http://codereview.appspot.com/157054/diff/1006/8 File java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java (right): http://codereview.appspot.com/157054/diff/1006/8#newcode88 java/gadgets/src/test/java/org/apache/shindig/gadgets/encoding/EncodingDetectorTest.java:88: } rather than passing in the custom detector from EncodingDetector, we should mock out a detector. Then in the "normal" tests, just ensure that the detector was or wasn't called (the mock will record this state), as appropriate. http://codereview.appspot.com/157054

