Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

rgoldberg
Copy link
Contributor

Same as old PR #349 but without enabling enableDigests or skipNonDigests

@rgoldberg
Copy link
Contributor Author

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)
Copy link
Contributor

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

@davydotcom
Copy link
Contributor

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 @CompileStatic.

@rgoldberg
Copy link
Contributor Author

rgoldberg commented May 25, 2016

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?

@davydotcom
Copy link
Contributor

all it does is grab from the manifest whats the point in adding call stack execution for this?

@rgoldberg
Copy link
Contributor Author

rgoldberg commented May 25, 2016

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.

@davydotcom
Copy link
Contributor

  1. In that context manifest.properties can NOT be null (production always has a manifest).
  2. As this code is being rolled into the generic servlet for grails 3 this causes a divergence more than a benefit in saving 5 lines of code.
  3. I will make it in one servlet interface in the long rung.
  4. Groovy does typically end up wrapping methods especially possible in service beans and was intentionally kept out.

rgoldberg added 12 commits May 27, 2016 22:14
…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
@rgoldberg rgoldberg force-pushed the manifest-access-cleanup branch from d80efc1 to f443129 Compare May 28, 2016 02:23
@rgoldberg rgoldberg closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants