Skip to content

Commit 2e2ba81

Browse files
committed
bug(#301): suppress
1 parent 4681003 commit 2e2ba81

1 file changed

Lines changed: 46 additions & 46 deletions

File tree

src/test/java/com/jcabi/xml/XMLDocumentTest.java

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ void printsWithAndWithoutXmlHeader() {
340340
);
341341
}
342342

343+
@SuppressWarnings("PMD.CloseResource")
343344
@Test
344345
void parsesInMultipleThreads() throws Exception {
345346
final int timeout = 10;
@@ -348,19 +349,19 @@ void parsesInMultipleThreads() throws Exception {
348349
new XMLDocument("<root><hey/></root>"),
349350
XhtmlMatchers.hasXPath("/root/hey")
350351
);
351-
try (ExecutorService service = Executors.newFixedThreadPool(5)) {
352-
for (int count = 0; count < loop; count += 1) {
353-
service.submit(runnable);
354-
}
355-
service.shutdown();
356-
MatcherAssert.assertThat(
357-
service.awaitTermination(timeout, TimeUnit.SECONDS),
358-
Matchers.is(true)
359-
);
360-
service.shutdownNow();
352+
final ExecutorService service = Executors.newFixedThreadPool(5);
353+
for (int count = 0; count < loop; count += 1) {
354+
service.submit(runnable);
361355
}
356+
service.shutdown();
357+
MatcherAssert.assertThat(
358+
service.awaitTermination(timeout, TimeUnit.SECONDS),
359+
Matchers.is(true)
360+
);
361+
service.shutdownNow();
362362
}
363363

364+
@SuppressWarnings("PMD.CloseResource")
364365
@Test
365366
void xpathInMultipleThreads() throws Exception {
366367
final int timeout = 30;
@@ -385,19 +386,19 @@ void xpathInMultipleThreads() throws Exception {
385386
Matchers.iterableWithSize(1)
386387
);
387388
};
388-
try (ExecutorService service = Executors.newFixedThreadPool(5)) {
389-
for (int count = 0; count < loop; count += 1) {
390-
service.submit(runnable);
391-
}
392-
service.shutdown();
393-
MatcherAssert.assertThat(
394-
service.awaitTermination(timeout, TimeUnit.SECONDS),
395-
Matchers.is(true)
396-
);
397-
service.shutdownNow();
389+
final ExecutorService service = Executors.newFixedThreadPool(5);
390+
for (int count = 0; count < loop; count += 1) {
391+
service.submit(runnable);
398392
}
393+
service.shutdown();
394+
MatcherAssert.assertThat(
395+
service.awaitTermination(timeout, TimeUnit.SECONDS),
396+
Matchers.is(true)
397+
);
398+
service.shutdownNow();
399399
}
400400

401+
@SuppressWarnings("PMD.CloseResource")
401402
@Test
402403
void printsInMultipleThreads() throws Exception {
403404
final int repeat = 1000;
@@ -419,25 +420,24 @@ void printsInMultipleThreads() throws Exception {
419420
);
420421
done.incrementAndGet();
421422
};
422-
try (ExecutorService service = Executors.newFixedThreadPool(5)) {
423-
for (int count = 0; count < loop; count += 1) {
424-
service.submit(runnable);
423+
final ExecutorService service = Executors.newFixedThreadPool(5);
424+
for (int count = 0; count < loop; count += 1) {
425+
service.submit(runnable);
426+
}
427+
service.shutdown();
428+
while (true) {
429+
if (done.get() == loop) {
430+
break;
425431
}
426-
service.shutdown();
427-
while (true) {
428-
if (done.get() == loop) {
429-
break;
430-
}
431-
if (service.awaitTermination(1L, TimeUnit.MILLISECONDS)) {
432-
break;
433-
}
432+
if (service.awaitTermination(1L, TimeUnit.MILLISECONDS)) {
433+
break;
434434
}
435-
MatcherAssert.assertThat(
436-
service.awaitTermination(1L, TimeUnit.SECONDS),
437-
Matchers.is(true)
438-
);
439-
service.shutdownNow();
440435
}
436+
MatcherAssert.assertThat(
437+
service.awaitTermination(1L, TimeUnit.SECONDS),
438+
Matchers.is(true)
439+
);
440+
service.shutdownNow();
441441
}
442442

443443
@Test
@@ -650,6 +650,7 @@ void validatesLongXml() throws Exception {
650650
);
651651
}
652652

653+
@SuppressWarnings("PMD.CloseResource")
653654
@Test
654655
void validatesMultipleXmlsInThreads() throws Exception {
655656
final int random = 100;
@@ -682,17 +683,16 @@ void validatesMultipleXmlsInThreads() throws Exception {
682683
);
683684
return null;
684685
};
685-
try (ExecutorService service = Executors.newFixedThreadPool(5)) {
686-
for (int count = 0; count < loop; count += 1) {
687-
service.submit(callable);
688-
}
689-
service.shutdown();
690-
MatcherAssert.assertThat(
691-
service.awaitTermination(timeout, TimeUnit.SECONDS),
692-
Matchers.is(true)
693-
);
694-
service.shutdownNow();
686+
final ExecutorService service = Executors.newFixedThreadPool(5);
687+
for (int count = 0; count < loop; count += 1) {
688+
service.submit(callable);
695689
}
690+
service.shutdown();
691+
MatcherAssert.assertThat(
692+
service.awaitTermination(timeout, TimeUnit.SECONDS),
693+
Matchers.is(true)
694+
);
695+
service.shutdownNow();
696696
}
697697

698698
/**

0 commit comments

Comments
 (0)