[MGNLRES-103] InstallTextResourcesTask's pattern is always set to UTF-8 Created: 03/Mar/14  Updated: 29/Mar/22  Resolved: 19/May/14

Status: Closed
Project: Magnolia Resources Module
Component/s: updates
Affects Version/s: 2.2.2
Fix Version/s: 2.3

Type: Bug Priority: Neutral
Reporter: Christian Hamm Assignee: Karel Nedoma
Resolution: Fixed Votes: 0
Labels: maintenance, quickwin
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MGNLRES-42 Issues with InstallResourcesTask and ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Team: Nucleus

 Description   

Hey guys,

I've found a bug in the resources module concerning the install task. Please take a closer look to the constructor of InstallTextResourcesTask:

public class InstallTextResourcesTask extends AbstractRepositoryTask {

  ...

    public InstallTextResourcesTask(String pattern, String template, boolean processed, String modelClass, boolean preserveResourcesParameters) {
        this("Install text resources", "Installs all resources matching the " + pattern + " pattern.", InstallTextResourceTask.DEFAULT_ENCODING, pattern, template, processed, modelClass, preserveResourcesParameters);
    }

    public InstallTextResourcesTask(String pattern, String template, String encoding, boolean processed, String modelClass, boolean preserveResourcesParameters) {
        this("Install text resources", "Installs all resources matching the " + pattern + " pattern.", encoding, pattern, template, processed, modelClass, preserveResourcesParameters);
    }

    public InstallTextResourcesTask(String taskName, String taskDescription, String pattern, String encoding, String template, boolean processed, String modelClass, boolean preserveResourcesParameters) {
        super(taskName, taskDescription);
        this.pattern = pattern;
        this.template = template;
        this.modelClass = modelClass;
        this.processed = processed;
        this.preserveResourcesParameters = preserveResourcesParameters;
    }

    ...

}

Notice the order of the parameters the first two constructors call the last big constructor:

  taskName, taskDescription, encoding, pattern, ...

But in the last constructor the parameters "encoding" and "pattern" are swapped:

  taskName, taskDescription, pattern, encoding

This leads to every task having a pattern of "UTF-8" which is definetly not what we want.



 Comments   
Comment by Roman Kovařík [ 16/May/14 ]
  1. Commit message MGLNRES-103 swap pattern and encoding tasks is not correct. pattern and encoding are parameters (arguments) of the method, not tasks + typo MGLNRES-103 -> MGNLRES-103.
  2. This code is not used:
        private InstallContext installContext;
        private MockSession session;
    
        @Before
        public void setUp() throws RepositoryException {
             installContext = mock(InstallContext.class);
             session = new MockSession("resources");
             when(installContext.getJCRSession(ResourcesModule.DEFAULT_WORKSPACE)).thenReturn(session);
        }
    
Comment by Roman Kovařík [ 19/May/14 ]

Commits:
http://git.magnolia-cms.com/gitweb/?p=modules/resources.git;a=shortlog;h=refs/heads/MGNLRES-103

Generated at Mon Feb 12 06:47:25 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.