@@ -320,10 +320,14 @@ public void verifyNoAsyncErrorsNoDelay() {
320
320
321
321
/** If {@code TestEnvironment#printlnDebug} is true, print debug message to std out. */
322
322
public void debug (String msg ) {
323
- if (printlnDebug )
323
+ if (debugEnabled () )
324
324
System .out .printf ("[TCK-DEBUG] %s%n" , msg );
325
325
}
326
326
327
+ public final boolean debugEnabled () {
328
+ return printlnDebug ;
329
+ }
330
+
327
331
/**
328
332
* Looks for given {@code method} method in stack trace.
329
333
* Can be used to answer questions like "was this method called from onComplete?".
@@ -578,7 +582,8 @@ public ManualSubscriberWithSubscriptionSupport(TestEnvironment env) {
578
582
579
583
@ Override
580
584
public void onNext (T element ) {
581
- env .debug (String .format ("%s::onNext(%s)" , this , element ));
585
+ if (env .debugEnabled ())
586
+ env .debug (String .format ("%s::onNext(%s)" , this , element ));
582
587
if (subscription .isCompleted ()) {
583
588
super .onNext (element );
584
589
} else {
@@ -588,7 +593,8 @@ public void onNext(T element) {
588
593
589
594
@ Override
590
595
public void onComplete () {
591
- env .debug (this + "::onComplete()" );
596
+ if (env .debugEnabled ())
597
+ env .debug (this + "::onComplete()" );
592
598
if (subscription .isCompleted ()) {
593
599
super .onComplete ();
594
600
} else {
@@ -598,7 +604,8 @@ public void onComplete() {
598
604
599
605
@ Override
600
606
public void onSubscribe (Subscription s ) {
601
- env .debug (String .format ("%s::onSubscribe(%s)" , this , s ));
607
+ if (env .debugEnabled ())
608
+ env .debug (String .format ("%s::onSubscribe(%s)" , this , s ));
602
609
if (!subscription .isCompleted ()) {
603
610
subscription .complete (s );
604
611
} else {
@@ -608,7 +615,8 @@ public void onSubscribe(Subscription s) {
608
615
609
616
@ Override
610
617
public void onError (Throwable cause ) {
611
- env .debug (String .format ("%s::onError(%s)" , this , cause ));
618
+ if (env .debugEnabled ())
619
+ env .debug (String .format ("%s::onError(%s)" , this , cause ));
612
620
if (subscription .isCompleted ()) {
613
621
super .onError (cause );
614
622
} else {
@@ -631,7 +639,8 @@ public BlackholeSubscriberWithSubscriptionSupport(TestEnvironment env) {
631
639
632
640
@ Override
633
641
public void onNext (T element ) {
634
- env .debug (String .format ("%s::onNext(%s)" , this , element ));
642
+ if (env .debugEnabled ())
643
+ env .debug (String .format ("%s::onNext(%s)" , this , element ));
635
644
if (!subscription .isCompleted ()) {
636
645
env .flop (String .format ("Subscriber::onNext(%s) called before Subscriber::onSubscribe" , element ));
637
646
}
0 commit comments