-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with string replace methods removing backslashes #51
Conversation
…aths for instance as user.home, but other examples might exist).
nice catch. I never tried to build on windows. Thanks for this. |
It's worth noting there are other issues building on windows, but I did not want to try and address those yet. I can poke around on it more tonight. There are about ~6 unit tests that fail for me. Unfortunately at work I'm on linux so I can't test here =) |
Fix issue with string replace methods removing backslashes
Wow... 6 tests failing on Windows... I need to pay more attention to this. |
On Mon, Sep 23, 2013 at 10:58 PM, Andy Christianson <
Hi Andy, I think I fixed the problems related to Windows build. I was not calling some OutputStream.close() on some test methods while Now tests are green. Thanks for pointing this out, so I could fix this. I had to setup a VMWare virtual machine, setup an entire development Thanks and best regards, Luigi. |
There's one last scenario (2 tests) that fail on windows. If the HOME environment variable isn't set (default for windows), two tests are failing to assert because null != "". The tests are: |
I just tried with latest master in my branch, and all tests are green:
What are you getting? Can you please update from my master, rerun the tests and let me know if things are still failing? Thanks. |
Yea, on my machine HOME env var isn't set. I see in your log, yours is. When it's not set, that test is asserting the value it received (null) against a string which replaced the null with an empty string, so it fails. When I mess with that variable, it also starts to mess with other things in windows (cygwin takes over that home too for instance). I can get my tests to pass by putting any value at all in HOME env var, but the real issue I think is that the test is reaching into global state which means they may not consistently pass. The way I've typically handled sys props and env vars myself is to have a wrapper class around them that I can then mock appropriately in tests. That ensures that no system would be able to cause a failure. |
You are right. This is a fresh installation of Windows XP, but usually I use mingw as bash client. I don't know if that variable comes from there. I'll verify this. Thanks. |
On master I did it already, I just need to set up the test properly. |
Hi. Just found that mvn 3.1.0 batch script sets the HOME variable at beginning
Anyway, it's a good idea not to depend on it. |
released version 1.0.5 few moments ago. The updated jar is already available in maven central repository. Have a look at the release notes. Thanks @NiXXeD for your support. |
Java string replace methods don't properly handle backslashes in the replacement string.
See http://stackoverflow.com/questions/9575116/forward-slash-in-java-regex
Suggestion as of that SO page is to replace backslash with double backslash ("" with "\") in the replacement string prior to replacing.
I ran into this because user.home on windows machines is something like C:\Users\NiXXeD, and several of the tests failed for me on a clean repo. I updated the affected tests to reproduce the issue prior to making changes.