>From Rithwik Koul <[email protected]>:

Rithwik Koul has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21227?usp=email )


Change subject: [NO TICKET][RT] Surface ASX1113 for invalid regex patterns - 
user model changes: no - storage format changes: no - interface changes: no
......................................................................

[NO TICKET][RT] Surface ASX1113 for invalid regex patterns
- user model changes: no
- storage format changes: no
- interface changes: no

Details : Wrap Pattern.compile in RegExpMatcher.build with try/catch for
PatternSyntaxException; rethrow as RuntimeDataException with the existing
INVALID_REGEX_PATTERN(1113) error code. Previously, invalid regex patterns
in regex_matches / regex_replace / regex_split / regex_position /
regex_contains / regex_like (and their flag/offset variants) plus the
SQL LIKE operator surfaced as generic "Internal error" (code 25000) with
a leaked Java stack trace. The error code already existed in
ErrorCode.INVALID_REGEX_PATTERN and was used in ExternalDataUtils.java
for the same purpose; this patch wires up the runtime evaluator path to
the same convention.

Ext-ref: NO TICKET
Change-Id: I09b5a2c5fd6fc2e845e88a702f0a4cca00d427da
---
M 
asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/utils/RegExpMatcher.java
1 file changed, 8 insertions(+), 1 deletion(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/27/21227/1

diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/utils/RegExpMatcher.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/utils/RegExpMatcher.java
index 1a190cc..34d4f1a 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/utils/RegExpMatcher.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/utils/RegExpMatcher.java
@@ -21,7 +21,10 @@

 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;

+import org.apache.asterix.common.exceptions.ErrorCode;
+import org.apache.asterix.common.exceptions.RuntimeDataException;
 import org.apache.asterix.runtime.evaluators.functions.StringEvaluatorUtils;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
@@ -126,7 +129,11 @@
                 // use whatever flags the previous pattern was using
                 flags = pattern.flags();
             }
-            pattern = Pattern.compile(patternString, flags);
+            try {
+                pattern = Pattern.compile(patternString, flags);
+            } catch (PatternSyntaxException ex) {
+                throw new 
RuntimeDataException(ErrorCode.INVALID_REGEX_PATTERN, ex, patternString);
+            }
             matcher = pattern.matcher(charSeq);
         } else {
             matcher.reset(charSeq);

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21227?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: lumina
Gerrit-Change-Id: I09b5a2c5fd6fc2e845e88a702f0a4cca00d427da
Gerrit-Change-Number: 21227
Gerrit-PatchSet: 1
Gerrit-Owner: Rithwik Koul <[email protected]>

Reply via email to