You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by dd...@apache.org on 2013/01/18 23:49:09 UTC

svn commit: r1435399 - /shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java

Author: ddumont
Date: Fri Jan 18 22:49:09 2013
New Revision: 1435399

URL: http://svn.apache.org/viewvc?rev=1435399&view=rev
Log:
Fix for shindig closure compiler cache misses.

Modified:
    shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java

Modified: shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java?rev=1435399&r1=1435398&r2=1435399&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java (original)
+++ shindig/trunk/java/gadgets/src/main/java16/org/apache/shindig/gadgets/rewrite/js/ClosureJsCompiler.java Fri Jan 18 22:49:09 2013
@@ -172,6 +172,16 @@ public class ClosureJsCompiler implement
     CompilerOptions options = getCompilerOptions(jsUri);
     StringBuilder compiled = new StringBuilder();
     StringBuilder exports = new StringBuilder();
+    boolean useExterns = compileLevel.equals("advanced");
+    if (!useExterns) {
+      /*
+       * Kicking the can down the road.  Advanced optimizations doesn't currently work with the closure compiler in shindig.
+       * When it's fixed, we need to make sure all externs are included (not just externs for what was requested) otherwise
+       * the cache key will fluctuate with the url hit, and we will get massive cache churn and possible DDOS scenarios
+       * when we recompile all requested modules on the fly because the cache key was different.
+       */
+      externs = "";
+    }
 
     // Add externs export to the list if set in options.
     if (options.isExternExportsEnabled()) {
@@ -224,9 +234,11 @@ public class ClosureJsCompiler implement
       for (Future<CompileResult> future : futures) {
         CompileResult result = future.get();
         compiled.append(result.getContent());
-        String export = result.getExternExport();
-        if (export != null) {
-          exports.append(export);
+        if (useExterns) {
+          String export = result.getExternExport();
+          if (export != null) {
+            exports.append(export);
+          }
         }
       }