File tree Expand file tree Collapse file tree 6 files changed +58
-0
lines changed
guava-tests/test/com/google/common/util/concurrent
guava/src/com/google/common/util/concurrent
guava-tests/test/com/google/common/util/concurrent
guava/src/com/google/common/util/concurrent Expand file tree Collapse file tree 6 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1717package com .google .common .util .concurrent ;
1818
1919import static com .google .common .truth .Truth .assertThat ;
20+ import static com .google .common .util .concurrent .MoreExecutors .newSequentialExecutor ;
2021import static com .google .common .util .concurrent .Uninterruptibles .awaitUninterruptibly ;
2122
2223import com .google .common .collect .ImmutableList ;
@@ -348,4 +349,21 @@ public void run() {
348349 assertThat (expected ).hasCauseThat ().isInstanceOf (RejectedExecutionException .class );
349350 }
350351 }
352+
353+ public void testToString () {
354+ Executor delegate =
355+ new Executor () {
356+ @ Override
357+ public void execute (Runnable task ) {}
358+
359+ @ Override
360+ public String toString () {
361+ return "theDelegate" ;
362+ }
363+ };
364+ Executor sequential1 = newSequentialExecutor (delegate );
365+ Executor sequential2 = newSequentialExecutor (delegate );
366+ assertThat (sequential1 .toString ()).contains ("theDelegate" );
367+ assertThat (sequential1 .toString ()).isNotEqualTo (sequential2 .toString ());
368+ }
351369}
Original file line number Diff line number Diff line change @@ -985,6 +985,11 @@ public void run() {
985985 thrownFromDelegate = false ;
986986 command .run ();
987987 }
988+
989+ @ Override
990+ public String toString () {
991+ return command .toString ();
992+ }
988993 });
989994 } catch (RejectedExecutionException e ) {
990995 if (thrownFromDelegate ) {
Original file line number Diff line number Diff line change 1919import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .QUEUED ;
2020import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .QUEUING ;
2121import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .RUNNING ;
22+ import static java .lang .System .identityHashCode ;
2223
2324import com .google .common .annotations .GwtIncompatible ;
2425import com .google .common .base .Preconditions ;
@@ -239,4 +240,9 @@ private void workOnQueue() {
239240 }
240241 }
241242 }
243+
244+ @ Override
245+ public String toString () {
246+ return "SequentialExecutor@" + identityHashCode (this ) + "{" + executor + "}" ;
247+ }
242248}
Original file line number Diff line number Diff line change 1717package com .google .common .util .concurrent ;
1818
1919import static com .google .common .truth .Truth .assertThat ;
20+ import static com .google .common .util .concurrent .MoreExecutors .newSequentialExecutor ;
2021import static com .google .common .util .concurrent .Uninterruptibles .awaitUninterruptibly ;
2122
2223import com .google .common .collect .ImmutableList ;
@@ -348,4 +349,21 @@ public void run() {
348349 assertThat (expected ).hasCauseThat ().isInstanceOf (RejectedExecutionException .class );
349350 }
350351 }
352+
353+ public void testToString () {
354+ Executor delegate =
355+ new Executor () {
356+ @ Override
357+ public void execute (Runnable task ) {}
358+
359+ @ Override
360+ public String toString () {
361+ return "theDelegate" ;
362+ }
363+ };
364+ Executor sequential1 = newSequentialExecutor (delegate );
365+ Executor sequential2 = newSequentialExecutor (delegate );
366+ assertThat (sequential1 .toString ()).contains ("theDelegate" );
367+ assertThat (sequential1 .toString ()).isNotEqualTo (sequential2 .toString ());
368+ }
351369}
Original file line number Diff line number Diff line change @@ -1090,6 +1090,11 @@ public void run() {
10901090 thrownFromDelegate = false ;
10911091 command .run ();
10921092 }
1093+
1094+ @ Override
1095+ public String toString () {
1096+ return command .toString ();
1097+ }
10931098 });
10941099 } catch (RejectedExecutionException e ) {
10951100 if (thrownFromDelegate ) {
Original file line number Diff line number Diff line change 1919import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .QUEUED ;
2020import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .QUEUING ;
2121import static com .google .common .util .concurrent .SequentialExecutor .WorkerRunningState .RUNNING ;
22+ import static java .lang .System .identityHashCode ;
2223
2324import com .google .common .annotations .GwtIncompatible ;
2425import com .google .common .base .Preconditions ;
@@ -239,4 +240,9 @@ private void workOnQueue() {
239240 }
240241 }
241242 }
243+
244+ @ Override
245+ public String toString () {
246+ return "SequentialExecutor@" + identityHashCode (this ) + "{" + executor + "}" ;
247+ }
242248}
You can’t perform that action at this time.
0 commit comments