File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
chainbase/src/main/java/org/tron/core/capsule
framework/src/test/java/org/tron/core/actuator/utils Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,6 @@ public class TransactionCapsule implements ProtoCapsule<Transaction> {
102
102
@ Setter
103
103
private TransactionTrace trxTrace ;
104
104
105
- private StringBuilder toStringBuff = new StringBuilder ();
106
105
@ Getter
107
106
@ Setter
108
107
private long time ;
@@ -738,7 +737,7 @@ public Transaction getInstance() {
738
737
739
738
@ Override
740
739
public String toString () {
741
-
740
+ StringBuilder toStringBuff = new StringBuilder ();
742
741
toStringBuff .setLength (0 );
743
742
toStringBuff .append ("TransactionCapsule \n [ " );
744
743
Original file line number Diff line number Diff line change 14
14
15
15
import com .google .protobuf .ByteString ;
16
16
import java .nio .charset .StandardCharsets ;
17
+ import java .util .ArrayList ;
17
18
import java .util .List ;
18
19
import lombok .extern .slf4j .Slf4j ;
19
20
import org .junit .Assert ;
@@ -431,4 +432,22 @@ public void estimateConsumeBandWidthSizeCorner() {
431
432
long actual = TransactionUtil .estimateConsumeBandWidthSize (dps , balance );
432
433
Assert .assertEquals (expected , actual );
433
434
}
435
+
436
+ @ Test
437
+ public void testConcurrentToString () throws InterruptedException {
438
+ Transaction .Builder builder = Transaction .newBuilder ();
439
+ TransactionCapsule trx = new TransactionCapsule (builder .build ());
440
+ List <Thread > threadList = new ArrayList <>();
441
+ int n = 10 ;
442
+ for (int i = 0 ; i < n ; i ++) {
443
+ threadList .add (new Thread (() -> trx .toString ()));
444
+ }
445
+ for (int i = 0 ; i < n ; i ++) {
446
+ threadList .get (i ).start ();
447
+ }
448
+ for (int i = 0 ; i < n ; i ++) {
449
+ threadList .get (i ).join ();
450
+ }
451
+ Assert .assertTrue (true );
452
+ }
434
453
}
You can’t perform that action at this time.
0 commit comments