[ 
https://issues.apache.org/jira/browse/SLING-10929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Niek Raaijmakers updated SLING-10929:
-------------------------------------
    Description: 
Currently, when performing a CPConversion, if the customer has wrong code, 
sometimes the exception can be very obfuscated.

This gives the customer no chance to fix their error easily:

In this example a xml file is empty:
[ERROR] Unable to convert content-package 
[/tmp/packages/???.ui.content-1.28.0-SNAPSHOT.zip, 
/tmp/packages/???.ui.apps-1.28.0-SNAPSHOT.zip]: Premature end of file.
We would like a path to be provided in the exception so the customer can take a 
look there.

  was:
[~karlpauls], while trying to fix some sonar findings in the converter I came 
across a warning about a null {{NodeTypeManager}} being passed to 
{{CndImporter.registerNodeTypes}} in the following new method introduced with  
SLING-10243:

{code}
public void registerCnd(Reader reader, String systemId) throws ParseException, 
RepositoryException, IOException {
        NodeTypeManager ntManager = null;
        ValueFactory valueFactory = null;
        CndImporter.registerNodeTypes(reader, systemId, ntManager, this, 
valueFactory, false);
        registeredCndSystemIds.add(systemId);
    }
{code}

a simple test shows that the method always fails with NPE.
so, unless i am missing something that code calling this method doesn't work at 
all..... according to 
https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-feature-cpconverter&metric=uncovered_conditions&selected=apache_sling-org-apache-sling-feature-cpconverter%3Asrc%2Fmain%2Fjava%2Forg%2Fapache%2Fsling%2Ffeature%2Fcpconverter%2Fvltpkg%2FJcrNamespaceRegistry.java&view=list
 the method isn't covered with any tests either.... so that might explain why 
it has not been spotted before.

what would be the best approach to get this fixed? should we revert changes 
made with SLING-10243? There is most probably no instance of JCR 
{{NodeTypeManager}} available if there is no JCR repository available at the 
stage the converter is being executed and I don't think mocking it at this 
stage is sensible.


> CPConverter - error messages can be obfuscated
> ----------------------------------------------
>
>                 Key: SLING-10929
>                 URL: https://issues.apache.org/jira/browse/SLING-10929
>             Project: Sling
>          Issue Type: Bug
>          Components: Content-Package to Feature Model Converter
>            Reporter: Niek Raaijmakers
>            Assignee: Niek Raaijmakers
>            Priority: Major
>             Fix For: Content-Package to Feature Model Converter 1.1.12
>
>
> Currently, when performing a CPConversion, if the customer has wrong code, 
> sometimes the exception can be very obfuscated.
> This gives the customer no chance to fix their error easily:
> In this example a xml file is empty:
> [ERROR] Unable to convert content-package 
> [/tmp/packages/???.ui.content-1.28.0-SNAPSHOT.zip, 
> /tmp/packages/???.ui.apps-1.28.0-SNAPSHOT.zip]: Premature end of file.
> We would like a path to be provided in the exception so the customer can take 
> a look there.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to