-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manifest access cleanup #352
Conversation
CI failure is probably because of 2.5.4 wrapper issue also mentioned in #351 |
manifestPath = fileUri.substring(1) //Omit forward slash | ||
} | ||
fileUri = manifest?.getProperty(manifestPath, manifestPath) | ||
fileUri = applicationContext.assetProcessorService.getAssetPath(fileUri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentional that the servlet filter be entirely self sufficient and not utilize any grails specific beans. This is the one area i would not touch with regards to accessing the assetProcessorService
Ok so this PR looks great save for one thing. It was intentional that the servlet filter not access an assetProcessorService bean. It was intended that the servlet filter become entirely independent of any grails specific services or beans. As a matter of fact the grails3 version will be moving to the asset-pipeline-servlet to further improve performance and reduce duplication. As far as converting things to final and static typing this is great as it provides the potential for moving modules to |
If I move getAssetPath(...) from AssetProcessorService to some other POJO or POGO class as a static method, will that work? If so, what class should I move it into? Or should I just make it a static method in AssetProcessorService? |
all it does is grab from the manifest whats the point in adding call stack execution for this? |
1 Code reuse prevents bugs. The existing copied code had bugs (or at least unnecessary code). e.g., if manifest is null, then fileUri is incorrectly set to null by: fileUri = manifest?.getProperty(manifestPath, manifestPath) If manifest can be null, it should be: fileUri = manifest?.getProperty(manifestPath) :? manifestPath If it cannot be null, it should be: fileUri = manifest.getProperty(manifestPath, manifestPath) 2 A single line call is easier to read than 5 lines of code 3 If you ever make a change to how you get an asset path, code reuse allows you to make that change in one place and automatically apply it everywhere. A while ago, I fixed a problem where initial slashes weren't removed from asset URIs. Code reuse allows that change to be made once in one place. Besides having to fix copied code in many places, copied code can get out of sync. 4 For normal Java (I don't know about Groovy), method calls are inlined if there are no overriding methods. So a call stack execution isn't added. And even if it were, a call stack execution (at least in Java) is very quick. There are many worse performance inefficiencies than a single method call that can be fixed up more easily by having cleaner code. |
|
…ly reading from manifest. Benefits: 1. cleaner code 2. easier to read 3. abstracted, so any changes to getAssetPath(...) are applied everywhere, e.g.: trimming initial slash 4. abstracted, prevents bugs., e.g.: before this commit, if manifest was null, AssetPipelineFilter would set fileUri = null, and AssetResourceLocator would set uri = null, which were both bugs
d80efc1
to
f443129
Compare
Same as old PR #349 but without enabling enableDigests or skipNonDigests