You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Karl Heinz Marbaise (JIRA)" <ji...@apache.org> on 2016/10/01 13:44:20 UTC

[jira] [Closed] (MNGSITE-293) Maven Profile activation (via property) bug (or misleading doc): profile active even if property doesn't exist

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

Karl Heinz Marbaise closed MNGSITE-293.
---------------------------------------
    Resolution: Fixed
      Assignee: Guillaume Boué

> Maven Profile activation (via property) bug (or misleading doc): profile active even if property doesn't exist
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: MNGSITE-293
>                 URL: https://issues.apache.org/jira/browse/MNGSITE-293
>             Project: Maven Project Web Site
>          Issue Type: Bug
>         Environment: Windows 7
>            Reporter: A. Di Matteo
>            Assignee: Guillaume Boué
>
> Based on the following profile:
> {code}
> <profile>
>     <id>test-profile</id>
>     <activation>
>         <property>
>             <name>something</name>
>             <value>!a</value>
>         </property>
>     </activation>
>     ...
> </profile>
> {code}
> And not setting the something property, the profile is always active (by default). This is in contradiction with the official Maven profile documentation on the !true value example:
> {quote}
> The following profile will be activated when the system property "debug" is defined with a value which is not "true".
> {quote}
> A bug or misleading documentation?
> If the mechanism is still implemented by the SystemPropertyProfileActivator, deprecated but not documented by which componenet it was replaced, if already replaced, then the (potential) bug is confirmed by the following shortened code:
> ActivationProperty property = activation.getProperty();
> {code}
> if ( property != null ) {
>     String name = property.getName();
>     boolean reverseName = false;
>     String sysValue = properties.getProperty( name );
>     String propValue = property.getValue();
>     if ( StringUtils.isNotEmpty( propValue ) ) {
>         boolean reverseValue = false;
>         if ( propValue.startsWith( "!" ) ) {
>             reverseValue = true;
>             propValue = propValue.substring( 1 );
>         }
>         // we have a value, so it has to match the system value...
>         boolean result = propValue.equals( sysValue );
>         if ( reverseValue ) {
>             return !result;
>         }
>         else {
>             return result;
>         }
>     }
> }
> {code}
> The issue is: the sysValue real property value by the defined name is not taken into account, it will be null in this specific case. However, its check on equals will return false, but then the further check on reverseValue would turn it to true, regardless of the existence of the name property and effectively activating the profile in this case.
> Full description at:
> http://stackoverflow.com/q/39632024/5606016



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)