2 Replies Latest reply on Oct 13, 2011 4:25 AM by Lukáš Fryč

    Strange behavior of DynamicResourceWrapper handling resource extensions

    Lukáš Fryč Master

      Hi guys,

       

      we have found strange piece of code in maven-resources-plugin [1].

       

      Basically files with libraryName=xyz and resourceName=abc.js

      are written using maven-resources-plugin as libraryName=abc and resourceName=js.

       

      It is causing problem in servers unable to detect mime-type for resources with name js.

       

      The cause is following piece of code [2]:

       

       

              String resourceName = getResourceName();
      
              String libraryName = getLibraryName();
      
              if (Strings.isNullOrEmpty(libraryName)) {
                  int idx = resourceName.lastIndexOf('.');
      
                  if (idx >= 0) {
                      libraryName = resourceName.substring(0, idx);
                      resourceName = resourceName.substring(idx + 1);
                  }
              }
      
      
              String versionedName = DASH_JOINER.join(resourceName, getVersion()) + Strings.nullToEmpty(resourceExtension);
              String resourcePath = SLASH_JOINER.join(libraryName, versionedName);
      
      
      

       

      [1] https://issues.jboss.org/browse/RF-11475

      [2] https://github.com/richfaces/cdk/blob/develop/maven-resources-plugin/src/main/java/org/richfaces/cdk/resource/handler/impl/DynamicResourceWrapper.java#L124