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

ASF GitHub Bot commented on MNG-6401:
-------------------------------------

hboutemy commented on issue #163: [MNG-6401] - Cannot interpolate property in 
proxy port of settings.xml
URL: https://github.com/apache/maven/pull/163#issuecomment-390640786
 
 
   on String interpolation vs Object interpolation:
   String based interpolation was replaced by Object interpolation a few years 
ago (perhaps during the switch from Maven 2 to Maven 3, I need to get precise 
facts if necessary): I don't precisely know why (is Object interpolation more 
robust, against XML injection?)
   
   what I see in this precise case of proxy port interpolation: it's an int, 
then it's hard to do Object interpolation on "${param}" value once it has been 
transfrmed to a String...
   at least, this give us the good root cause: if we want interpolation with 
Object implementation, we need to change the field type to String
   
   I know that we have such a case with booleans, where we do not put the 
effective field type in the descriptor but String for more flexibility: in this 
boolean case, it was about inheritance, to make the difference between 
inheriting and overriding with a value.
   Then there is a hand-written getter to get the field as boolean (instead of 
the internal String)
   
   I don't know if we have such cases in Maven core with ints, but the previous 
pattern hand-writing a typed getter to int should do the job.
   
   Now what's the best solution for now:
   - switch back to String based interpolation instead of Object interpolation?
   - change the field from int to String and add the hand-written getter?
   
   at this time, I don't have strong opinion: I wanted to write and share the 
analysis.
   
   Now I need to dig into the reasons why we switched from String based 
interpolation to Object based: this is where we should find the best view on 
what issue could arise when getting back to former solution

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Cannot interpolate property in proxy port of settings.xml
> ---------------------------------------------------------
>
>                 Key: MNG-6401
>                 URL: https://issues.apache.org/jira/browse/MNG-6401
>             Project: Maven
>          Issue Type: Bug
>          Components: Bootstrap & Build
>    Affects Versions: 3.0, 3.5.3
>            Reporter: KATADA Junya
>            Assignee: Michael Osipov
>            Priority: Minor
>             Fix For: 3.5.4-candidate
>
>
> If you use a property in proxy port of settings.xml, the property is not 
> replaced and the port number is "0" instead of property value.
> My minimal demo about this problem is 
> [here|https://github.com/jkatada/maven-property-demo]. 
> In my demo, export two environment variables as follows.
> {code}
> export MAVEN_PROXY_HOST_STRING=proxy.foo.com
> export MAVEN_PROXY_PORT_INT=18080
> {code}
> These variables are used in settings.xml for proxy settings.
> {code:xml}
> <proxy>
>     <id>my_proxy</id>
>     <active>true</active>
>     <protocol>http</protocol>
>     <host>${env.MAVEN_PROXY_HOST_STRING}</host>
>     <port>${env.MAVEN_PROXY_PORT_INT}</port>
>     <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
>  </proxy>
> {code}
> Execute maven-help-plugin to show effective settings.xml.
> {code}
> mvn help:effective-settings -X
> {code}
> The result is as follows.
> {code:xml}
> <proxy>
>     <port>0</port>
>     <host>proxy.foo.com</host>
>     <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
>     <id>my_proxy</id>
> </proxy>
>  {code}
> `*${env.MAVEN_PROXY_HOST_STRING}*` is replaced with `*proxy.foo.com*`, 
>  but `*${env.MAVEN_PROXY_PORT_INT}*` is not replaced with `*18080*`.
> I found the following WARNING message in console.
> {code:java}
> [WARNING] Some problems were encountered while building the effective settings
> [WARNING] Unable to parse element 'port', must be an integer (position: 
> END_TAG seen ...<port>${env.MAVEN_PROXY_PORT_INT}</port>... @12:47) caused 
> by: java.lang.NumberFormatException: For input string: 
> "${env.MAVEN_PROXY_PORT_INT}" @ /root/.m2/settings.xml, line 12, column 47
> {code}
> I think that the cause of this problem is to parse settings.xml before 
> interpolation.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to