Skip to content

Java compilation error occurs for envoy since v1.37.0#1383

Open
jrhee17 wants to merge 1 commit intobufbuild:mainfrom
jrhee17:bugfix/java-regex-escape
Open

Java compilation error occurs for envoy since v1.37.0#1383
jrhee17 wants to merge 1 commit intobufbuild:mainfrom
jrhee17:bugfix/java-regex-escape

Conversation

@jrhee17
Copy link
Copy Markdown

@jrhee17 jrhee17 commented Apr 8, 2026

Motivation

Upstream envoy protos recently added new regex rules: e.g. ^$|^[^\\x00-\\x1f\\x7f \",;<>\\\\]+$

This is causing a compilation error on our side:

/Users/user/Projects/armeria/xds-api/build/generated/sources/proto/main/javapgv/io/envoyproxy/envoy/extensions/filters/http/oauth2/v3/CookieConfigValidator.java:20: error: illegal start of expression
                com.google.re2j.Pattern PATH__PATTERN = com.google.re2j.Pattern.compile("^$|^/[^\\x00-\\x1f\\x7f \\",;<>\\\\]*$");

From my reading, it seems like the string escape method is causing this

func (fns javaFuncs) javaStringEscape(s string) string {
s = fmt.Sprintf("%q", s)
s = s[1 : len(s)-1]
s = strings.ReplaceAll(s, `\u00`, `\x`)
s = strings.ReplaceAll(s, `\x`, `\\x`)
// s = strings.ReplaceAll(s, `\`, `\\`)
s = strings.ReplaceAll(s, `"`, `\"`)
return `"` + s + `"`
}

  • \\x case: %q produces \\x00, ReplaceAll matches \x within it and over-escapes to \\\x00
  • " case: %q already produces \", the extra ReplaceAll over-escapes to \\"

This currently requires the following workaround line/armeria#6714

Modifications

  • Removed \u00 rewrites since Java natively supports them anyways
  • Removed ReplaceAll(s, ", ") since this is handled by Sprintf
  • Rewrite \x to \\x only if exactly \x (without a prepending backslash)

Misc

  • Updated zlib from 1.2.13 to 1.3.1 in bazel/repositories.bzl to fix local build errors on macOS. Happy to revert if maintainers prefer.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@jrhee17 jrhee17 marked this pull request as ready for review April 8, 2026 07:56
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