diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/AbstractTag.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/AbstractTag.java index 646df9a60..c4cbcc99b 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/AbstractTag.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/tag/AbstractTag.java @@ -51,7 +51,7 @@ public abstract class AbstractTag { } public boolean sameWith(AbstractTag tag) { - return canOverwrite && tag.id == tag.id; + return canOverwrite && this.id == tag.id; } public int getId() { diff --git a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java index b700abc65..bb8b07d2c 100644 --- a/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java +++ b/oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/SourceColumn.java @@ -62,6 +62,7 @@ public class SourceColumn { case "String": this.type = String.class; typeName = "String"; + break; default: try { this.type = Class.forName(typeName); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java index c40783ecf..96e4849b6 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java @@ -18,6 +18,8 @@ package org.apache.skywalking.oap.server.core.analysis.metrics.expression; +import java.util.Objects; + /** * @author wusheng */ @@ -39,19 +41,19 @@ public class EqualMatch { } public boolean match(Integer left, Integer right) { - return left == right; + return Objects.equals(left, right); } public boolean match(Long left, Long right) { - return left == right; + return Objects.equals(left, right); } public boolean match(Float left, Float right) { - return left == right; + return Objects.equals(left, right); } public boolean match(Double left, Double right) { - return left == right; + return Objects.equals(left, right); } public boolean match(Boolean left, Boolean right) { @@ -63,6 +65,6 @@ public class EqualMatch { } public boolean match(Object left, Object right) { - return left.equals(right); + return Objects.equals(left, right); } } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatchTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatchTest.java new file mode 100644 index 000000000..e288d2543 --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatchTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author kezhenxu94 + */ +public class EqualMatchTest { + + @Test + public void integerShouldEqualWhenLargerThan128() { + Integer a = 334; + Integer b = 334; + boolean match = new EqualMatch().match(a, b); + assertTrue(match); + } + + @Test + public void longShouldEqualWhenLargerThan128() { + Long a = 334L; + Long b = 334L; + boolean match = new EqualMatch().match(a, b); + assertTrue(match); + } + + @Test + public void doubleShouldEqualWhenLargerThan128() { + Double a = 334.0; + Double b = 334.0; + boolean match = new EqualMatch().match(a, b); + assertTrue(match); + } + + @Test + public void floatShouldEqualWhenLargerThan128() { + Float a = 334.0F; + Float b = 334.0F; + boolean match = new EqualMatch().match(a, b); + assertTrue(match); + } +} \ No newline at end of file