You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Matías Albanesi (JIRA)" <ji...@codehaus.org> on 2014/03/20 15:22:59 UTC

[jira] (SCM-744) api's AbstractConsumer ignores Locale when using a custom dateFormatter

Matías Albanesi created SCM-744:
-----------------------------------

             Summary: api's AbstractConsumer ignores Locale when using a custom dateFormatter
                 Key: SCM-744
                 URL: https://jira.codehaus.org/browse/SCM-744
             Project: Maven SCM
          Issue Type: Bug
          Components: maven-scm-api
    Affects Versions: 1.8.1
            Reporter: Matías Albanesi
            Priority: Minor


Class org.apache.maven.scm.util.AbstractConsumer contains a method:

protected Date parseDate( String date, String userPattern, String defaultPattern, Locale locale )

Which ignores the specified locale if there is a userPattern specified. Current implementation is:
        if ( StringUtils.isNotEmpty( userPattern ) )
        {
            format = new SimpleDateFormat( userPattern );
            patternUsed = userPattern;
        }

When the date parsing fails it misleadingly displays a message indicating that it did make use of the Locale but clearly it did not:

[ERROR] skip ParseException: Unparseable date: "Mon Oct 21 18:14:36 2013 -0300" during parsing date Mon Oct 21 18:14:36 2013 -0300 with pattern EEE MMM dd HH:mm:ss yyyy Z with Locale en
java.text.ParseException: Unparseable date: "Mon Oct 21 18:14:36 2013 -0300"
	at java.text.DateFormat.parse(DateFormat.java:337)
	at org.apache.maven.scm.util.AbstractConsumer.parseDate(AbstractConsumer.java:112)
	at org.apache.maven.scm.provider.hg.command.changelog.HgChangeLogConsumer.doConsume(HgChangeLogConsumer.java:196)
	at org.apache.maven.scm.provider.hg.command.changelog.HgChangeLogConsumer.consumeLine(HgChangeLogConsumer.java:97)
	at org.codehaus.plexus.util.cli.StreamPumper.consumeLine(StreamPumper.java:195)

The issue happens because my environment has user.language=es, user.country=AR. Even passing these parameters in the command line does not help:

mvn clean changelog:changelog -Duser.language=en -Duser.country=US

fails the same way.

How this was tested:
- Mercurial repository
- using maven-changelog-plugin (specifying system parameters here does not help either)
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-changelog-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <dateFormat>EEE MMM dd HH:mm:ss yyyy Z</dateFormat>
      <systemProperties>
       <property><name>user.language</name><value>en</value></property>
       <property><name>user.country</name><value>US</value></property>
      </systemProperties>
    </configuration>
  </plugin>




--
This message was sent by Atlassian JIRA
(v6.1.6#6162)