Skip to content
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: compatible with windows path in Robolectric test. #300

Merged
merged 1 commit into from
Dec 14, 2022
Merged

fix: compatible with windows path in Robolectric test. #300

merged 1 commit into from
Dec 14, 2022

Conversation

alps2006
Copy link
Contributor

@alps2006 alps2006 commented Dec 7, 2022

Problem

When running Robolectric in windows os, following error can occur.

java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
	at java.base/java.util.regex.Pattern.error(Pattern.java:2027)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1788)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1428)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1068)
	at java.base/java.lang.String.split(String.java:2317)
	at java.base/java.lang.String.split(String.java:2364)
	at ch.qos.logback.core.rolling.helper.FileFinder.regexEscapePath(Unknown Source)
	at ch.qos.logback.core.rolling.helper.FileNamePattern.toRegex(Unknown Source)
	at ch.qos.logback.core.rolling.helper.DateParser.<init>(Unknown Source)
	at ch.qos.logback.core.rolling.helper.TimeBasedArchiveRemover.<init>(Unknown Source)
	at ch.qos.logback.core.rolling.helper.SizeAndTimeBasedArchiveRemover.<init>(Unknown Source)
	at ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.createArchiveRemover(Unknown Source)
	at ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP.start(Unknown Source)
	at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.start(Unknown Source)

Because String.split() method use a regex parameter, but there may be a \ in windows OS.

Resolving

In logback, log path was slashified, so i always use a / to split pattern and path.

@tony19 tony19 merged commit 2ae4dd4 into tony19:main Dec 14, 2022
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.

2 participants