Fix potential NPE in OAL string match and a bug when right-hand-side variable includes double quotes (#8234)

This commit is contained in:
kezhenxu94 2021-12-02 22:08:40 +08:00 committed by GitHub
parent e7d6f89021
commit d557f547fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,7 @@ Release Notes.
#### OAP Server
* Fix potential NPE in OAL string match and a bug when right-hand-side variable includes double quotes.
#### UI

View File

@ -25,12 +25,12 @@ import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.FilterM
public class StringMatch {
public boolean match(String left, String right) {
if (left.startsWith("\"") && left.endsWith("\"")) {
if (left != null && left.startsWith("\"") && left.endsWith("\"")) {
left = left.substring(1, left.length() - 1);
}
if (right.startsWith("\"") && right.endsWith("\"")) {
right = left.substring(1, right.length() - 1);
if (right != null && right.startsWith("\"") && right.endsWith("\"")) {
right = right.substring(1, right.length() - 1);
}
return Objects.equals(left, right);