-
Notifications
You must be signed in to change notification settings - Fork 903
Open
Description
Hello, I found this issue when updating the formatter version in googleapis/java-spanner
package com.example;
final class Test {
// Error: unclosed string literal
String breaks = "'\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(READ_TIMESTAMP)[\\t";
// Works
String fix = "'\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(READ_TIMESTAMP)[\u005Ct";
}Produces the following error:
hi on] diegomarquezp:java-spanner$ java -jar ~/.library_generation/google-java-format.jar --version
google-java-format: Version 1.26.0
[hi on] diegomarquezp:java-spanner$ java -jar ~/.library_generation/google-java-format.jar test.java
test.java:7:13: error: unclosed string literal
String fix = "'((STRONG)|(MIN_READ_TIMESTAMP)[\\t ]+((\\d{4})-(\\d{2})-(\\d{2})([Tt](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(READ_TIMESTAMP)[\u005Ct ]+((\\d{4})-(\\d{2})-(\\d{2})([Tt](\\d{2}):(\\d{2}):( \\d{2})(\\.\\d{1,9})?)([Zz]|([+-])(\\d{2}):(\\d{2})))|(MAX_STALENESS)[\u005Ct ]+((\\d{1,19})(s|ms|us|ns))|(EXACT_STALENESS)[\\t ]+((\\d{1,19})(s|ms|us|ns)))'";
^
[hi on] diegomarquezp:java-spanner$
Note that String fix doesn't have the error after replacing these two specific double backslashes \\ with the hexcode version \u0005C.
update: simplified reproducer code.
cushon
Metadata
Metadata
Assignees
Labels
No labels