You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Piotr Zygielo (Jira)" <ji...@apache.org> on 2024/06/09 20:49:00 UTC

[jira] [Commented] (MNG-7194) PluginParameterExpressionEvaluator incorrectly interpolates unknown subexpression

    [ https://issues.apache.org/jira/browse/MNG-7194?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17853537#comment-17853537 ] 

Piotr Zygielo commented on MNG-7194:
------------------------------------

Just wonder if this could be related to my unmet expectation I have with surefire and {{{}surefire.forkNumber{}}}.

Given [https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#forkCount]
{quote}The system properties and the argLine of the forked processes may contain the place holder string \{${surefire.forkNumber}}, which is replaced with a fixed number for each of the parallel forks
{quote}
When I configure {{m-surefire-p}} with
{code:xml}
<systemPropertyVariables>
  <p1>${surefire.forkNumber}</p1>
</systemPropertyVariables>
{code}
Then {{p1}} system property (available in test) is set to empty string (it's not set during interpolation of parameters for plugin and {{SurefireHelper.replaceThreadNumberPlaceholders}} finds nothing to work with).
(While {color:#de350b}I expect(ed){color} the value {{N}} there.)

But when I use
{code:xml}
<systemPropertyVariables>
  <p1>_${surefire.forkNumber}_</p1>
</systemPropertyVariables>
{code}
(where {{_}} can be anything just to not leave {{{}${}}}-property reference alone)
Then {{p1}} system property is set to {{_N_}} as expected, as it's passed to SF as unchanged {{_${surefire.forkNumber}_}} and {{SurefireHelper.replaceThreadNumberPlaceholders}} is happy with that.

If those cases are linked - then perhaps if
{quote}It should be just pre?
{quote}
is implemented, (would it cause {{__}} to be passed for my {{p1}} to SF?) it would probably need some changes in SF in such case.
(Or could be handled in SF in first place separately.)
I think.

> PluginParameterExpressionEvaluator incorrectly interpolates unknown subexpression
> ---------------------------------------------------------------------------------
>
>                 Key: MNG-7194
>                 URL: https://issues.apache.org/jira/browse/MNG-7194
>             Project: Maven
>          Issue Type: Bug
>          Components: Inheritance and Interpolation
>            Reporter: Robert Scholte
>            Priority: Minor
>
> The PluginParameterExpressionEvaluator evaluate(String,Class)-method ends like this:
> {code:java}
>         if ( value instanceof String )
>         {
>             // TODO: without #, this could just be an evaluate call...
>             String val = (String) value;
>             int exprStartDelimiter = val.indexOf( "${" );
>             if ( exprStartDelimiter >= 0 )
>             {
>                 if ( exprStartDelimiter > 0 )
>                 {
>                     value = val.substring( 0, exprStartDelimiter ) + evaluate( val.substring( exprStartDelimiter ) );
>                 }
>                 else
>                 {
>                     value = evaluate( val.substring( exprStartDelimiter ) );
>                 }
>             }
>         }
> {code}
> Assume that pre${unknown} needs to be evaluated and {{unknown}} does not exist, the result well be "{{prenull}}"
> Just ${unknown} evaluates to null, but because there's no String concat it will be a real null.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)