You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AEM Version, including Service Packs, Cumulative Fix Packs, etc: _______
ACS AEM Commons Version: master
Reproducible on Latest? yes/no
Hi,
I find that the private field resourceIgnores at Line 53 in the file 'acs-aem-commons/bundle/src/main/java/com/adobe/acs/commons/version/impl/EvolutionAnalyserImpl.java' on the master branch is only assigned and used in the method activate. Therefore, this field can be removed from the class, and become a local variable in the method activate. This transformation will normally reduce memory usage and improve readability of your code.
privateString[] resourceIgnores; // line 53 this field can be replaced by local variableprotectedvoidactivate(finalMap<String, String> config) {
propertyIgnores = PropertiesUtil.toStringArray(config.get(PROPERTY_IGNORES), newString[] { "" });
// String[] resourceIgnores = PropertiesUtil.toStringArray(config.get(RESOURCE_IGNORES), new String[] { "" });resourceIgnores = PropertiesUtil.toStringArray(config.get(RESOURCE_IGNORES), newString[] { "" });
evolutionConfig = newEvolutionConfig(propertyIgnores, resourceIgnores);
log.debug("Ignored properties: {}", (Object[]) propertyIgnores);
log.debug("Ignored resources: {}", (Object[]) resourceIgnores);
}
Besides, there are other fields like this.I sorted them out and put them in the table below.
In addition, the private field resource at Line 42 in the file 'acs-aem-commons/bundle/src/main/java/com/adobe/acs/commons/version/impl/EvolutionContextImpl.java ' on the master branch is only assigned and used in the method EvolutionContextImpl. Therefore, this field can be removed from the class, and become a local variable in the method EvolutionContextImpl. Besides, for method populateEvolutions, the field resource can be converted to an input parameter.This transformation will normally reduce memory usage and improve readability of your code.I will be happy if this transformation is helpful.
privateResourceresource = null;// line 42 this field can be replaced by local variablepublicEvolutionContextImpl(Resourceresource, EvolutionConfigconfig) {
// Resource resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource;this.resource = resource.isResourceType("cq:Page") ? resource.getChild("jcr:content") : resource;
this.config = config;
// populateEvolutions(resource);populateEvolutions();
}
privatevoidpopulateEvolutions(Resourceresource) {
try {
this.resolver = resource.getResourceResolver();
this.versionManager = resolver.adaptTo(Session.class).getWorkspace().getVersionManager();
this.history = versionManager.getVersionHistory(resource.getPath());
Iterator<Version> iter = history.getAllVersions();
while (iter.hasNext()) {
Versionnext = iter.next();
StringversionPath = next.getFrozenNode().getPath();
ResourceversionResource = resolver.resolve(versionPath);
versions.add(newEvolutionImpl(next, versionResource, config));
log.debug("Version={} added to EvolutionItem", next.getName());
}
} catch (UnsupportedRepositoryOperationExceptione1) {
log.warn("Could not find version for resource={}", resource.getPath());
} catch (Exceptione) {
log.error("Could not find versions", e);
}
evolutionItems = newArrayList<>(versions);
// evolutionItems.add(new CurrentEvolutionImpl(resource, this.config));evolutionItems.add(newCurrentEvolutionImpl(this.resource, this.config));
}
Besides, there are other fields like this.I sorted them out and put them in the table below.
Required Information
Hi,
I find that the private field resourceIgnores at Line 53 in the file 'acs-aem-commons/bundle/src/main/java/com/adobe/acs/commons/version/impl/EvolutionAnalyserImpl.java' on the master branch is only assigned and used in the method activate. Therefore, this field can be removed from the class, and become a local variable in the method activate. This transformation will normally reduce memory usage and improve readability of your code.
Besides, there are other fields like this.I sorted them out and put them in the table below.
In addition, the private field resource at Line 42 in the file 'acs-aem-commons/bundle/src/main/java/com/adobe/acs/commons/version/impl/EvolutionContextImpl.java ' on the master branch is only assigned and used in the method EvolutionContextImpl. Therefore, this field can be removed from the class, and become a local variable in the method EvolutionContextImpl. Besides, for method populateEvolutions, the field resource can be converted to an input parameter.This transformation will normally reduce memory usage and improve readability of your code.I will be happy if this transformation is helpful.
Besides, there are other fields like this.I sorted them out and put them in the table below.
Expected Behavior
Some fields can be replaced by local variable.
Actual Behavior
Use fields as local variables.
Steps to Reproduce
See attachment for details
acs-aem-commons.md
Links
See attachment for details
The text was updated successfully, but these errors were encountered: