Petals CDK

getExtensions(String) does not trim values

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Resolution: Won't Fix
  • Affects Version/s: 5.0.3
  • Fix Version/s: None
  • Component/s: Utils
  • Security Level: Public
  • Description:
    Hide

    When retrivieving parameter values defines the jbi.xml of a SU (and maybe from a component), the value is not trimed.
    As an example, in the EJB BC, depending on the XML shape, there can be an error while loading the EJB class, because of formatting spaces.

    <ejb:class-name>com.toto.MyEJB</ejb:class-name>

    is not interpreted like

    <ejb:class-name>
                    com.toto.MyEJB
    </ejb:class-name>

    The value is retrieved in the component by using getExtension( "class-name" ).
    If the value is not null, then it should be trimed. Notice that some components bypass it in the SU manager to use this method only once and by triming the result.

    getComponentExtension(String) should also be checked.

    Show
    When retrivieving parameter values defines the jbi.xml of a SU (and maybe from a component), the value is not trimed. As an example, in the EJB BC, depending on the XML shape, there can be an error while loading the EJB class, because of formatting spaces.
    <ejb:class-name>com.toto.MyEJB</ejb:class-name>
    is not interpreted like
    <ejb:class-name>
                    com.toto.MyEJB
    </ejb:class-name>
    The value is retrieved in the component by using getExtension( "class-name" ). If the value is not null, then it should be trimed. Notice that some components bypass it in the SU manager to use this method only once and by triming the result. getComponentExtension(String) should also be checked.
  • Environment:
    Windows XP

Activity

Hide
Roland Naudin added a comment - Thu, 4 Nov 2010 - 15:31:38 +0100

I never have been agree about this trim issue.

The eclipse formater is worng, it should not format meaninglfull section like XML CONTENT DATA.
What if i want to set a space in my value? how can i do that?

It is not because eclipse format XML in a way that is not XML compatible that we must adapt to that defect.

Show
Roland Naudin added a comment - Thu, 4 Nov 2010 - 15:31:38 +0100 I never have been agree about this trim issue. The eclipse formater is worng, it should not format meaninglfull section like XML CONTENT DATA. What if i want to set a space in my value? how can i do that? It is not because eclipse format XML in a way that is not XML compatible that we must adapt to that defect.
Hide
Vincent Zurczak added a comment - Thu, 4 Nov 2010 - 16:30:08 +0100 - edited

It is compatible with XML... => http://www.w3.org/TR/REC-xml/#sec-white-space
An element value is a Text node, whose parent is the element.
In addition, does XML pretty printer sound familiar to you?

getProvides().getAny() should be enough to retrieve DOM elements and get values with formatting.
getExtension() is a utility method, that should be convenient. Removing surrounding spaces would make sense.
Otherwise, all the components should stop using this method in JBI and External listeners, and go through an internal model.
That's what I did in all my components (SCA, Jsr181, Validation, XSLT, Talend, Quartz), because this CDK method is not reliable.

It appears to be a problem in other components as well, and I'm sure all the component developers do not know it preserves surronding white spaces.

PS: I agree about Eclipse formatting automatically the XML.
I created this issue PETALSSTUD-94.

Show
Vincent Zurczak added a comment - Thu, 4 Nov 2010 - 16:30:08 +0100 - edited It is compatible with XML... => http://www.w3.org/TR/REC-xml/#sec-white-space An element value is a Text node, whose parent is the element. In addition, does XML pretty printer sound familiar to you? getProvides().getAny() should be enough to retrieve DOM elements and get values with formatting. getExtension() is a utility method, that should be convenient. Removing surrounding spaces would make sense. Otherwise, all the components should stop using this method in JBI and External listeners, and go through an internal model. That's what I did in all my components (SCA, Jsr181, Validation, XSLT, Talend, Quartz), because this CDK method is not reliable. It appears to be a problem in other components as well, and I'm sure all the component developers do not know it preserves surronding white spaces. PS: I agree about Eclipse formatting automatically the XML. I created this issue PETALSSTUD-94.
Hide
Christophe DENEUX added a comment - Thu, 4 Nov 2010 - 16:54:19 +0100

Vincent, I think that you need to declare your data as "token", see http://www.w3.org/TR/xmlschema-2/#token

Show
Christophe DENEUX added a comment - Thu, 4 Nov 2010 - 16:54:19 +0100 Vincent, I think that you need to declare your data as "token", see http://www.w3.org/TR/xmlschema-2/#token
Hide
Vincent Zurczak added a comment - Thu, 4 Nov 2010 - 17:15:09 +0100

The fact is, I don't need it.
But, there are components, including the EJB component, whose values are taken with white spaces.
If you try to instantiate a class with white spaces, it will always fail.

A user is not supposed to guess that trailing white spaces are important.
Otherwise, every component has to do getExtension( "blabla" ), test if it is null or not, and trim it if it can.
The CDK should provide this behavior by default.

Show
Vincent Zurczak added a comment - Thu, 4 Nov 2010 - 17:15:09 +0100 The fact is, I don't need it. But, there are components, including the EJB component, whose values are taken with white spaces. If you try to instantiate a class with white spaces, it will always fail. A user is not supposed to guess that trailing white spaces are important. Otherwise, every component has to do getExtension( "blabla" ), test if it is null or not, and trim it if it can. The CDK should provide this behavior by default.
Hide
Mathieu Carrolle added a comment - Thu, 4 Nov 2010 - 17:39:22 +0100

Sorry

Show
Mathieu Carrolle added a comment - Thu, 4 Nov 2010 - 17:39:22 +0100 Sorry
Mathieu Carrolle made changes - Thu, 4 Nov 2010 - 17:39:22 +0100
Field Original Value New Value
Resolution Won't Fix [ 2 ]
Status New [ 10000 ] Resolved [ 10004 ]
Transition Status Change Time Execution Times Last Executer Last Execution Date
New New Resolved Resolved
2h 12m
1
Mathieu Carrolle
Thu, 4 Nov 2010 - 17:39:22 +0100



People

Dates

  • Created:
    Thu, 4 Nov 2010 - 15:27:18 +0100
    Updated:
    Thu, 4 Nov 2010 - 17:39:22 +0100
    Resolved:
    Thu, 4 Nov 2010 - 17:39:22 +0100