Skip to content

Conversation

@dennisl
Copy link
Contributor

@dennisl dennisl commented Apr 12, 2022

…ltered.

https://issues.apache.org/jira/browse/MWAR-450

The fix for this issue is similar to MRESOURCES-171. We have added a configuration parameter called propertiesEncoding to the Mojo. If it is not specified it will not be used. Under the hood maven-filtering has been updated to 3.2.0 to be able to use the propertiesEncoding feature in it. maven-shared-utils is also updated to match the version in maven-filtering.

An integration test MWAR-450 has been added to cover the use case described in JIRA. There is already another integration test called web-resources-filtering that covers the behavior prior to this patch.

[ X ] I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

[ X ] I am a commiter for the Apache Software Foundation

cstamas and others added 2 commits October 11, 2021 13:46
Move maven to proper scope, update dependencies,
remove unused ones.
@dennisl
Copy link
Contributor Author

dennisl commented Apr 19, 2022

Thanks for the review Michael! I have made changes based on your suggestions.

@michael-o michael-o self-requested a review April 19, 2022 15:54
<resource>
<targetPath>WEB-INF/classes</targetPath>
<filtering>true</filtering>
<directory>src/main/webapp/WEB-INF/classes</directory>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't they in src/main/resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they don't in our use case. We like to separate our config files from our resources. This way the config files end up readable in the exploded war, instead of being packaged in the jar file of the project.

}
FileInputStream fis = new FileInputStream ( log4jxml );
String paramContent = IOUtil.toString ( fis, "UTF-8" );
System.out.println( "content='" + paramContent + "'" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output will be mangled if run on non-UTF-8.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have tried this on both Windows (CP-1252) and Linux (UTF-8), and the output from the integration test looks fine for us, without mangled characters. Which platform did you have problems on?

properties.load( fis );
fis.close();
String property = properties.get( "my.property" );
System.out.println( "my.property='" + property + "'" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

}
FileInputStream fis = new FileInputStream ( myfile );
String paramContent = IOUtil.toString ( fis, "UTF-8" );
System.out.println( "content='" + paramContent + "'" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

System.err.println( "my.properties is missing or is a directory." );
return false;
}
Properties properties = new Properties();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In jdk9 encoding of properties was changed.
https://docs.oracle.com/javase/9/intl/internationalization-enhancements-jdk-9.htm

Maybe good assertions will be length of file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true that changes were made in Java 9. From what I understand the changes were made with regards to internationalization in PropertyResourceBundle, but not to regular Properties. https://docs.oracle.com/javase/9/docs/api/java/util/Properties.html

The assertions that are in place should work fine regardless of Java version since we specify the encoding to use when reading the files, in the plugin's code. The only exception som that rule is when reading the properties file in the verify.bsh file in the integration test.

@dennisl dennisl merged commit 6abd29b into apache:master Apr 25, 2022
@michael-o
Copy link
Member

Oh c'mon, really why didn't you rebase first? Now we have those useless merge commits on master.

@dennisl
Copy link
Contributor Author

dennisl commented Apr 25, 2022

Sorry, I messed up. I wanted to apply the pull requests in order, but there was a conflict between the PR for MWAR-444 and MWAR-450 that I was unable to resolve at github. Also I wanted to make sure that the failed checks for MWAR-444 had been resolved in master, so I decided to merge the PR for MWAR-444 into our fork. That was apparently one too many remote references for me to handle. I really hate those merge commits...

@jira-importer
Copy link

Resolve #528

1 similar comment
@jira-importer
Copy link

Resolve #528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants