#8156 : StructuralSearchInspection, Prohibit check on Thread.ge… (#8394)

* StructuralSearchInspection, Prohibit check on Thread.getState()

* review changes - 1

* review changes 2

* review changes 3

* test fix

* review changes-2

* review changes-3
This commit is contained in:
SandishKumarHN 2019-09-22 04:12:05 -07:00 committed by Roman Leventov
parent 868bb42301
commit ade8d1922d
4 changed files with 11 additions and 6 deletions

View File

@ -311,6 +311,14 @@
<constraint name="k" within="" contains="" />
<constraint name="v" within="" contains="" />
</searchConfiguration>
<searchConfiguration name="Prohibit Thread.getState() != TERMINATED antipattern" text="$t$.getState()!=Thread.State.$state$" recursive="true" caseInsensitive="true" type="JAVA">
<constraint name="t" within="" contains="" />
<constraint name="state" within="" contains="" />
</searchConfiguration>
<searchConfiguration name="Prohibit Thread.getState() == TERMINATED antipattern" text="$t$.getState()==Thread.State.$state$" recursive="true" caseInsensitive="true" type="JAVA">
<constraint name="t" within="" contains="" />
<constraint name="state" within="" contains="" />
</searchConfiguration>
<searchConfiguration name="Use CollectionUtils.mapValues(Map&lt;K,V&gt;, Function&lt;V,V2&gt;)" text="$x$.entrySet().stream().collect(Collectors.toMap($k$ -&gt; $k$.getKey(), $y$))" recursive="true" caseInsensitive="true" type="JAVA">
<constraint name="x" within="" contains="" />
<constraint name="y" within="" contains="" />

View File

@ -179,6 +179,7 @@ final class DeadlockDetectingFailOnTimeout extends Statement
* problem or if the thread cannot be determined. The return value is never equal
* to {@code mainThread}.
*/
@SuppressWarnings("SSBasedInspection") // Prohibit check on Thread.getState()
private Thread getStuckThread(Thread mainThread)
{
List<Thread> threadsInGroup = getThreadsInGroup(mainThread.getThreadGroup());

View File

@ -100,9 +100,7 @@ public class EventReceiverFirehoseIdleTest
private void awaitDelayedExecutorThreadTerminated() throws InterruptedException
{
while (firehose.getDelayedCloseExecutor().getState() != Thread.State.TERMINATED) {
Thread.sleep(50);
}
firehose.getDelayedCloseExecutor().join();
}
@Test(timeout = 40_000L)

View File

@ -275,9 +275,7 @@ public class EventReceiverFirehoseTest
private void awaitDelayedExecutorThreadTerminated() throws InterruptedException
{
while (firehose.getDelayedCloseExecutor().getState() != Thread.State.TERMINATED) {
Thread.sleep(50);
}
firehose.getDelayedCloseExecutor().join();
}
@Test(timeout = 60_000L)