This is an automated email from the ASF dual-hosted git repository.

shaojunwang pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-teaclave-java-tee-sdk.git

commit cd77439a3d86b5ff053c126f7f2e124bd8d91780
Author: cengfeng.lzy <[email protected]>
AuthorDate: Wed Jun 29 14:57:25 2022 +0800

    [Enc] Make test thread safe
    
    Summary: Make the test case thread safe
    
    Test Plan: all tests pass
    
    Reviewers: lei.yul, jeffery.wsj, sanhong.lsh
    
    Issue: https://aone.alibaba-inc.com/task/42894513
    
    CR: https://code.alibaba-inc.com/java-tee/JavaEnclave/codereview/9207941
---
 .../enclave/RunWithNativeImageTest.java                  |  1 -
 .../enclave/testservice/NumericMath.java                 | 16 ++++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git 
a/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/RunWithNativeImageTest.java
 
b/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/RunWithNativeImageTest.java
index 70e7c63..5fd5262 100644
--- 
a/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/RunWithNativeImageTest.java
+++ 
b/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/RunWithNativeImageTest.java
@@ -8,7 +8,6 @@ import 
com.alibaba.confidentialcomputing.enclave.testservice.PointMath;
 import com.oracle.svm.core.annotate.AutomaticFeature;
 import org.graalvm.nativeimage.hosted.Feature;
 import org.graalvm.nativeimage.hosted.RuntimeSerialization;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
diff --git 
a/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/testservice/NumericMath.java
 
b/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/testservice/NumericMath.java
index a26c861..052853e 100644
--- 
a/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/testservice/NumericMath.java
+++ 
b/sdk/enclave/src/test/java/com/alibaba/confidentialcomputing/enclave/testservice/NumericMath.java
@@ -6,23 +6,31 @@ public class NumericMath implements MathService<Number> {
 
     @Override
     public Number add(Number x, Number y) {
-        counter++;
+        synchronized (this) {
+            counter++;
+        }
         return x.intValue() + y.intValue();
     }
 
     @Override
     public Number minus(Number x, Number y) {
-        counter++;
+        synchronized (this) {
+            counter++;
+        }
         return x.intValue() - y.intValue();
     }
 
     @Override
     public Number div(Number x, Number y) {
-        counter++;
+        synchronized (this) {
+            counter++;
+        }
         return x.intValue() / y.intValue();
     }
 
     public int getCounter() {
-        return counter;
+        synchronized (this) {
+            return counter;
+        }
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to