Skip to content

fix: escape closing brace in TemplateProcessing regex for Android ICU compatibility#323

Merged
HardNorth merged 1 commit into
reportportal:developfrom
blundell:fix/android-icu-regex-compatibility
Jun 8, 2026
Merged

fix: escape closing brace in TemplateProcessing regex for Android ICU compatibility#323
HardNorth merged 1 commit into
reportportal:developfrom
blundell:fix/android-icu-regex-compatibility

Conversation

@blundell

@blundell blundell commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Escapes the closing } in the TEMPLATE_GROUP regex in TemplateProcessing.java to fix a PatternSyntaxException on Android.

Problem

The regex \{([\w$]+(\.[\w$]+)*)} has an unescaped }. Java's Pattern on JVM is lenient and accepts this, but Android's ICU regex engine (com.android.icu.util.regex.PatternNative) is strict and rejects it at index 22.

Because this regex is compiled in a static initializer, the PatternSyntaxException becomes a permanent ExceptionInInitializerError — every subsequent call to LaunchImpl.startTestItem() via applyNameFormat() fails for the remainder of the JVM lifetime.

Fix

One-character change: )})\}

\} is valid on both standard JVM and Android ICU — no behavioural change for non-Android consumers. All existing TemplateProcessingTest tests pass.

Fixes #322

Summary by CodeRabbit

  • Bug Fixes
    • Improved template placeholder matching pattern for enhanced accuracy and compatibility.

… compatibility

Android's regex engine (com.android.icu.util.regex.PatternNative) is
stricter than the JVM's java.util.regex.Pattern and rejects unescaped '}'
with a PatternSyntaxException. Since this regex is compiled in a static
initializer, the class is permanently poisoned and every subsequent call
to LaunchImpl.startTestItem() fails with ExceptionInInitializerError.

Escaping the '}' as '\}' is valid on both JVM and Android ICU — no
behavioural change for non-Android consumers.

Fixes reportportal#322
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32d52c0f-8a67-42bf-9030-cddfb6a0c8d9

📥 Commits

Reviewing files that changed from the base of the PR and between 88ed5de and 6d38db0.

📒 Files selected for processing (1)
  • src/main/java/com/epam/reportportal/utils/formatting/templating/TemplateProcessing.java

Walkthrough

This PR fixes a critical Android compatibility issue in template processing. A single character escape is added to the regex pattern that matches template placeholders, resolving a PatternSyntaxException on Android's strict ICU regex engine that was breaking test item reporting.

Changes

Template regex Android compatibility

Layer / File(s) Summary
Escape closing brace in TEMPLATE_GROUP regex
src/main/java/com/epam/reportportal/utils/formatting/templating/TemplateProcessing.java
The TEMPLATE_GROUP Pattern constant's regex is updated from \\{([\\w$]+(\\.[\\w$]+)*)} to \\{([\\w$]+(\\.[\\w$]+)*)\\} to escape the closing brace, ensuring Android ICU compatibility without changing matching behavior on standard JVM.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🐰 A brace left bare caused an Android despair,
One backslash added, now templates flow fair.
No more regex cries on Samsung devices—
The fix is so small, yet such wise decisiveness! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: escaping a closing brace in the TemplateProcessing regex to fix Android ICU compatibility issues.
Linked Issues check ✅ Passed The pull request correctly implements the required fix from issue #322 by escaping the closing brace in the TEMPLATE_GROUP regex pattern.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the Android ICU regex compatibility issue described in issue #322; no out-of-scope changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HardNorth HardNorth merged commit cd50679 into reportportal:develop Jun 8, 2026
2 checks passed
@blundell blundell deleted the fix/android-icu-regex-compatibility branch June 9, 2026 10:57
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.

PatternSyntaxException on Android: unescaped '}' in TemplateProcessing regex

2 participants