Description
TemplateProcessing.java line 43 compiles a regex with an unescaped closing brace:
private static final Pattern TEMPLATE_GROUP = Pattern.compile("\\{([\\w$]+(\\.[\\w$]+)*)}");
The trailing } is not escaped. On standard JVM this is accepted (Java's Pattern is lenient about lone }), but on Android the regex engine is backed by ICU (com.android.icu.util.regex.PatternNative), which is strict and rejects it:
java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 22
\{([\w$]+(\.[\w$]+)*)}
^
at com.android.icu.util.regex.PatternNative.compileImpl(Native Method)
at com.android.icu.util.regex.PatternNative.<init>(PatternNative.java:53)
at java.util.regex.Pattern.compile(Pattern.java:1550)
at java.util.regex.Pattern.<init>(Pattern.java:1426)
at java.util.regex.Pattern.compile(Pattern.java:1068)
at com.epam.reportportal.utils.formatting.templating.TemplateProcessing.<clinit>(TemplateProcessing.java:43)
Because this is in the static initializer, the class is permanently poisoned — every subsequent call that touches TemplateProcessing throws ExceptionInInitializerError (or NoClassDefFoundError). This breaks LaunchImpl.startTestItem() → applyRequestModifications() → applyNameFormat() for all test items.
Impact
Using client-java (any version up to 5.4.14) on Android with Cucumber or any framework that calls startTestItem with parameters causes a crash on devices with strict ICU regex (observed on Samsung devices with recent Android versions). The launch is created successfully, but no test items can be reported.
Reproduction
A minimal Android instrumented test project with:
client-java:5.4.13 (or any 5.4.x)
agent-java-cucumber6:5.5.7
- A Cucumber scenario with parameters (triggers
applyNameFormat)
Run on a Samsung device (e.g. Galaxy A16). The @Before hook may pass (runs before TemplateProcessing is loaded), but the first scenario step crashes.
Fix
Escape the closing brace in the regex. This is a one-character change:
- private static final Pattern TEMPLATE_GROUP = Pattern.compile("\\{([\\w$]+(\\.[\\w$]+)*)}");
+ private static final Pattern TEMPLATE_GROUP = Pattern.compile("\\{([\\w$]+(\\.[\\w$]+)*)\\}");
\\} is valid on both standard JVM and Android ICU — the fix has no effect on non-Android usage.
Workaround
We are currently patching the string constant in the class bytecode at build time using ASM before dexing. This works but is fragile.
Versions affected
Checked all tags through 5.4.14 — the same unescaped } is present in every version.
Description
TemplateProcessing.javaline 43 compiles a regex with an unescaped closing brace:The trailing
}is not escaped. On standard JVM this is accepted (Java'sPatternis lenient about lone}), but on Android the regex engine is backed by ICU (com.android.icu.util.regex.PatternNative), which is strict and rejects it:Because this is in the static initializer, the class is permanently poisoned — every subsequent call that touches
TemplateProcessingthrowsExceptionInInitializerError(orNoClassDefFoundError). This breaksLaunchImpl.startTestItem()→applyRequestModifications()→applyNameFormat()for all test items.Impact
Using
client-java(any version up to 5.4.14) on Android with Cucumber or any framework that callsstartTestItemwith parameters causes a crash on devices with strict ICU regex (observed on Samsung devices with recent Android versions). The launch is created successfully, but no test items can be reported.Reproduction
A minimal Android instrumented test project with:
client-java:5.4.13(or any 5.4.x)agent-java-cucumber6:5.5.7applyNameFormat)Run on a Samsung device (e.g. Galaxy A16). The
@Beforehook may pass (runs beforeTemplateProcessingis loaded), but the first scenario step crashes.Fix
Escape the closing brace in the regex. This is a one-character change:
\\}is valid on both standard JVM and Android ICU — the fix has no effect on non-Android usage.Workaround
We are currently patching the string constant in the class bytecode at build time using ASM before dexing. This works but is fragile.
Versions affected
Checked all tags through
5.4.14— the same unescaped}is present in every version.