mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform-tests] Use try-with-resources
GitOrigin-RevId: df3140b9f881771896efbad3e7636b382db776e1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
850eeea88c
commit
ddcb403606
+6
-30
@@ -225,8 +225,7 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
final long[] offsetsToRequest = IntStream.range(0, DIFFERENT_OFFSETS_TO_REQUEST)
|
||||
.mapToLong(i -> ThreadLocalRandom.current().nextLong(FILE_SIZE))
|
||||
.toArray();
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final Callable<Void> task = () -> {
|
||||
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
|
||||
final int requestNo = rnd.nextInt(offsetsToRequest.length);
|
||||
@@ -282,9 +281,6 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
final FilePageCacheStatistics statistics = pageCache.getStatistics();
|
||||
System.out.println(statistics);
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -296,8 +292,7 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
final long[] offsetsToRequest = IntStream.range(0, DIFFERENT_OFFSETS_TO_REQUEST)
|
||||
.mapToLong(i -> ThreadLocalRandom.current().nextLong(FILE_SIZE))
|
||||
.toArray();
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final Callable<Void> task = () -> {
|
||||
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
|
||||
final int requestNo = rnd.nextInt(offsetsToRequest.length);
|
||||
@@ -356,9 +351,6 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
final FilePageCacheStatistics statistics = pageCache.getStatistics();
|
||||
System.out.println(statistics);
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -366,8 +358,7 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
|
||||
private void readFileSequentiallyTwice(final @NotNull File file,
|
||||
final @NotNull ByteBuffer buffer) throws IOException {
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final long blocksCount = FILE_SIZE / BUFFER_SIZE;
|
||||
for (int turn = 0; turn < TWICE; turn++) {
|
||||
for (int blockNo = 0; blockNo < blocksCount; blockNo++) {
|
||||
@@ -391,15 +382,11 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void readFileRandomlyApproximatelyTwice(final @NotNull File file,
|
||||
final @NotNull ByteBuffer buffer) throws IOException {
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
|
||||
final long blocksCount = FILE_SIZE / BUFFER_SIZE;
|
||||
for (int i = 0; i < blocksCount * TWICE; i++) {
|
||||
@@ -423,15 +410,11 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFileSequentiallyTwice(final @NotNull File file,
|
||||
final @NotNull ByteBuffer buffer) throws IOException {
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final long blocksCount = FILE_SIZE / BUFFER_SIZE;
|
||||
for (int turn = 0; turn < TWICE; turn++) {
|
||||
for (int blockNo = 0; blockNo < blocksCount; blockNo++) {
|
||||
@@ -454,15 +437,11 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFileRandomlyApproximatelyTwice(final @NotNull File file,
|
||||
final @NotNull ByteBuffer buffer) throws IOException {
|
||||
final PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true);
|
||||
try {
|
||||
try (PagedFileStorage pagedStorage = new PagedFileStorage(file.toPath(), storageContext, BUFFER_SIZE, true, true)) {
|
||||
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
|
||||
final long blocksCount = FILE_SIZE / BUFFER_SIZE;
|
||||
for (int i = 0; i < blocksCount * TWICE; i++) {
|
||||
@@ -485,8 +464,5 @@ public class PerformanceOfFileAccessWithFilePageCacheTest extends PerformanceOfF
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
pagedStorage.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user