You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by fa...@apache.org on 2022/06/27 03:30:51 UTC

[incubator-seatunnel] branch api-draft updated: [api-draft][connector] fix ThreadLocalRandom use (#2059) (#2060)

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

fanjia pushed a commit to branch api-draft
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/api-draft by this push:
     new 97f7b432d [api-draft][connector] fix ThreadLocalRandom use (#2059) (#2060)
97f7b432d is described below

commit 97f7b432d3e77395405801e0d2a8c5cbb3eb70ec
Author: iture123 <10...@qq.com>
AuthorDate: Mon Jun 27 11:30:46 2022 +0800

    [api-draft][connector] fix ThreadLocalRandom use (#2059) (#2060)
---
 .../seatunnel/connectors/seatunnel/fake/source/FakeSourceReader.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeSourceReader.java b/seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeSourceReader.java
index e7b12eaf7..5a387f871 100644
--- a/seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeSourceReader.java
+++ b/seatunnel-connectors/seatunnel-connectors-seatunnel/seatunnel-connector-seatunnel-fake/src/main/java/org/apache/seatunnel/connectors/seatunnel/fake/source/FakeSourceReader.java
@@ -37,7 +37,6 @@ public class FakeSourceReader implements SourceReader<SeaTunnelRow, FakeSourceSp
 
     private final String[] names = {"Wenjun", "Fanjia", "Zongwen", "CalvinKirs"};
     private final int[] ages = {11, 22, 33, 44};
-    private final Random random = ThreadLocalRandom.current();
 
     public FakeSourceReader(SourceReader.Context context) {
         this.context = context;
@@ -57,7 +56,8 @@ public class FakeSourceReader implements SourceReader<SeaTunnelRow, FakeSourceSp
     @SuppressWarnings("magicnumber")
     public void pollNext(Collector<SeaTunnelRow> output) throws InterruptedException {
         // Generate a random number of rows to emit.
-        int size = random.nextInt(10);
+        Random random = ThreadLocalRandom.current();
+        int size = random.nextInt(10) + 1;
         for (int i = 0; i < size; i++) {
             int randomIndex = random.nextInt(names.length);
             SeaTunnelRow seaTunnelRow = new SeaTunnelRow(new Object[]{names[randomIndex], ages[randomIndex], System.currentTimeMillis()});