Adobe-Consulting-Services / acs-aem-commons

http://adobe-consulting-services.github.io/acs-aem-commons/
Apache License 2.0
453 stars 600 forks source link

Versioned ClientLibs: MD5 does not change when modifying an embeddeds clientlib category #1203

Closed kwin closed 6 years ago

kwin commented 6 years ago

Currently the MD5 calculation only happens in https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/f7424effb1fd68e8d494988fe74c009b4ccab4bb/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java#L278, in case the clientlib is not in the cache. The cache entries are itself only invalidated via https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/f7424effb1fd68e8d494988fe74c009b4ccab4bb/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java#L315 (based on the event topic: com/adobe/granite/ui/librarymanager/INVALIDATED).

Now consider the following use case

  1. Client library with category a embeds client library with category b
  2. MD5 for a is correctly being generated once
  3. The category name of client library b* switches to b

The client library's MD5 of a is not invalidated, as there is no OSGi event which invalidates the embedding client library. Therefore the client library is requested with the same URL (and therefore potentially being delivered in the wrong version from the client's cache).

If an embedded clientlibrary is moved out of an embedding clientlib (in the example from above by switching from b to b*, both libraries are correctly invalidated, i.e. the embedded as well as the embedding one) but the invalidation does not take place vice versa.

kwin commented 6 years ago

Another smaller related issue is that the input stream in https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/f7424effb1fd68e8d494988fe74c009b4ccab4bb/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/VersionedClientlibsTransformerFactory.java#L288 is not closed!

justinedelson commented 6 years ago

yikes. I thought that DigestUtils closed the stream, but it looks like it didn't. good catch.

In terms of the core issue, I would suggest that this is a product defect. please raise this with DayCare.

justinedelson commented 6 years ago

Created separate issue for the stream issue.

kwin commented 6 years ago

I further investigated and subsequently opened #1208.

irenebijo commented 2 years ago

Is there any ways we can induce MD5 change for css and js file

pooja-chauhan commented 2 years ago

@irenebijo is there ?