Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6611

Missing check for IScopeAwareTextResourceProcessor when concatenating resources

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 8.1.0
    • 8.5.0, 9.0.0-M2, 7.14.0
    • wicket-core
    • None

    Description

      Resource concatenation cannot be used with text compressors relying on scope information.

      I tried to use CssUrlReplacer in my application and it failed on startup with an UnsupportedOperationException in the compress method.

      In CssPackageResource we have the following code:  

      ICssCompressor compressor = getCompressor();
      
      if (compressor != null && getCompress())
      {
         try
         {
            String charsetName = "UTF-8";
            String nonCompressed = new String(processedResponse, charsetName);
            String output;
            if (compressor instanceof IScopeAwareTextResourceProcessor)
            {
               IScopeAwareTextResourceProcessor scopeAwareProcessor = (IScopeAwareTextResourceProcessor) compressor;
               output = scopeAwareProcessor.process(nonCompressed, getScope(), name);
            }
            else
            {
               output = compressor.compress(nonCompressed);
            }
            return output.getBytes(charsetName);
         }
         catch (Exception e)
         {
            log.error("Error while filtering content", e);
            return processedResponse;
         }
      }

      In ConcatBundleResource this instanceof is missing and compress is called directly.

      if (getCompressor() != null)
      {
         String nonCompressed = new String(bytes, "UTF-8");
         bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
      }

       

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              thomas.heigl Thomas Heigl
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: