summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-13 17:24:10 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2018-03-13 22:21:34 +0100
commitbf757cd1c6202aa6b891bdc47c206039cbf798f0 (patch)
treed41c923c2b092230078268d14e9084c071f5462c /org.eclipse.jgit.test
parent5c70be00856d5375485e6f062b6e1e09a606601f (diff)
downloadjgit-bf757cd1c6202aa6b891bdc47c206039cbf798f0.tar.gz
jgit-bf757cd1c6202aa6b891bdc47c206039cbf798f0.zip
TemporaryBufferTest: Suppress "should be managed by try-with-resource"
In most of the tests, the temporary buffer is explicitly destroyed in a finally block after being closed. This is not possible if using the try-with-resource construct, because the variable is not accessible in the finally block scope. Change-Id: I3bab30695ddd12e1a0ae107989638428fe3ef551 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
index 327ee279a1..e73dab2ce6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
@@ -61,6 +61,7 @@ import org.junit.Test;
public class TemporaryBufferTest {
@Test
public void testEmpty() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
try {
b.close();
@@ -75,6 +76,7 @@ public class TemporaryBufferTest {
@Test
public void testOneByte() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte test = (byte) new TestRng(getName()).nextInt();
try {
@@ -100,6 +102,7 @@ public class TemporaryBufferTest {
@Test
public void testOneBlock_BulkWrite() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.Block.SZ);
@@ -129,6 +132,7 @@ public class TemporaryBufferTest {
@Test
public void testOneBlockAndHalf_BulkWrite() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.Block.SZ * 3 / 2);
@@ -158,6 +162,7 @@ public class TemporaryBufferTest {
@Test
public void testOneBlockAndHalf_SingleWrite() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.Block.SZ * 3 / 2);
@@ -185,6 +190,7 @@ public class TemporaryBufferTest {
@Test
public void testOneBlockAndHalf_Copy() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.Block.SZ * 3 / 2);
@@ -213,6 +219,7 @@ public class TemporaryBufferTest {
@Test
public void testLarge_SingleWrite() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 3);
@@ -252,6 +259,7 @@ public class TemporaryBufferTest {
@Test
public void testInCoreLimit_SwitchOnAppendByte() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.DEFAULT_IN_CORE_LIMIT + 1);
@@ -279,6 +287,7 @@ public class TemporaryBufferTest {
@Test
public void testInCoreLimit_SwitchBeforeAppendByte() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 3);
@@ -306,6 +315,7 @@ public class TemporaryBufferTest {
@Test
public void testInCoreLimit_SwitchOnCopy() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final byte[] test = new TestRng(getName())
.nextBytes(TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 2);
@@ -336,7 +346,7 @@ public class TemporaryBufferTest {
@Test
public void testDestroyWhileOpen() throws IOException {
- @SuppressWarnings("resource" /* java 7 */)
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
try {
b.write(new TestRng(getName())
@@ -348,6 +358,7 @@ public class TemporaryBufferTest {
@Test
public void testRandomWrites() throws IOException {
+ @SuppressWarnings("resource") // Buffer is explicitly destroyed in finally block
final TemporaryBuffer b = new TemporaryBuffer.LocalFile(null);
final TestRng rng = new TestRng(getName());
final int max = TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 2;