You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Leif Bennett (JIRA)" <ji...@codehaus.org> on 2007/11/16 01:35:25 UTC

[jira] Updated: (MCHECKSTYLE-59) Checkstyle Report fails if propertyExpansion contains file names

     [ http://jira.codehaus.org/browse/MCHECKSTYLE-59?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leif Bennett updated MCHECKSTYLE-59:
------------------------------------

    Attachment: MCHECKSTYLE-59-PATCH2.patch

The problem appears to occur because of the documented behavior of java.util.Properties.load(InputStream), which interprets all backslash characters as escape sequences, and silently drops the backslash if it is not part of a valid escape sequence. On a Windows machine, the propertyExpansion field will contain backslash characters as part of the directory path in 'resourcedir'. These are either removed or changed (e.g., a path containing "plugin\trunk" will convert to "plugin<tab>runk").

The patch I supply appears to have identical functionality to the one submitted by Lars Behnke, but is perhaps more terse.

A similar strategy could be needed for some of the other values in this method, but have not caused a problem for me.

> Checkstyle Report fails if propertyExpansion contains file names
> ----------------------------------------------------------------
>
>                 Key: MCHECKSTYLE-59
>                 URL: http://jira.codehaus.org/browse/MCHECKSTYLE-59
>             Project: Maven 2.x Checkstyle Plugin
>          Issue Type: Bug
>    Affects Versions: 2.1
>         Environment: Windows XP, JDK 1.4, Maven 2.0.4
>            Reporter: Carsten Karkola
>         Attachments: MCHECKSTYLE-59-PATCH.patch, MCHECKSTYLE-59-PATCH2.patch
>
>
> The chechkstyle plugin fails on windows plattforms, if the propertyExpansion element contains file names like 
>   mms.suppressions.file=${basedir}/../../project/resources/checkstyle/suppressions.xml
> The backslashes in ${basedir} (like D:\foo\bar) are missing (D:foobar) and checkstyle fails. It seems to be an issue with StringInputStream.
> I've replaced the following old code in CheckstyleReport.java
>             if ( StringUtils.isNotEmpty( propertyExpansion ) )
>             {
>                 p.load( new StringInputStream( propertyExpansion ) );
>             }
> with the new Code
>       if ( StringUtils.isNotEmpty( propertyExpansion ) ) {
>         BufferedReader reader = new BufferedReader(new StringReader(propertyExpansion));
>         String line = reader.readLine();
>         while (line != null) {
>           int delimPosition = line.indexOf('=');
>           if (delimPosition > -1) {
>             String name = line.substring(0, delimPosition).trim();
>             delimPosition++;
>             if (delimPosition < line.length()) {
>               String value = line.substring(delimPosition).trim();
>               if (value.length() > 0) {
>                 p.put(name, value);
>                 getLog().info("Property: " + name + " = " + p.getProperty(name));
>               }
>             }
>           }
>           line = reader.readLine();
>         }
>         reader.close();
>       }
> and it works.
> Regards, carsten

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira