private static void writeSideBand(OutputStream out, String textForGit)
throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
OutputStream msg = new SideBandOutputStream(CH_ERROR, SMALL_BUF, out);
msg.write(Constants.encode("error: " + textForGit));
msg.flush();
ptr++;
ptr++;
+ @SuppressWarnings("resource" /* java 7 */)
TemporaryBuffer.Heap raw = new TemporaryBuffer.Heap(bufArray.length);
InflaterInputStream inf = new InflaterInputStream(
new ByteArrayInputStream(bufArray, ptr, bufArray.length));
} catch (IOException e) {
// the test makes only sense if deletion of
// a file with open stream fails
+ } finally {
+ fis.close();
}
- fis.close();
FileUtils.delete(testFile);
CheckoutCommand co = git.checkout();
// delete Test.txt in branch test
}
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void absoluteGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
assertEquals(dir, repo2.getWorkTree());
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void relativeGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
assertEquals(dir, repo2.getWorkTree());
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void scanWithGitDirRef() throws Exception {
FileRepository repo1 = createWorkRepository();
assertFalse(gen.next());
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void repositoryWithRootLevelSubmoduleAbsoluteRef()
throws IOException, ConfigInvalidException {
assertFalse(gen.next());
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void repositoryWithRootLevelSubmoduleRelativeRef()
throws IOException, ConfigInvalidException {
@Test
public void testWrite_CH_DATA() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, SMALL_BUF, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ SMALL_BUF, rawOut);
out.write(new byte[] { 'a', 'b', 'c' });
out.flush();
assertBuffer("0008\001abc");
@Test
public void testWrite_CH_PROGRESS() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_PROGRESS, SMALL_BUF, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_PROGRESS,
+ SMALL_BUF, rawOut);
out.write(new byte[] { 'a', 'b', 'c' });
out.flush();
assertBuffer("0008\002abc");
@Test
public void testWrite_CH_ERROR() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_ERROR, SMALL_BUF, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_ERROR,
+ SMALL_BUF, rawOut);
out.write(new byte[] { 'a', 'b', 'c' });
out.flush();
assertBuffer("0008\003abc");
@Test
public void testWrite_Small() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, SMALL_BUF, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ SMALL_BUF, rawOut);
out.write('a');
out.write('b');
out.write('c');
@Test
public void testWrite_SmallBlocks1() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, 6, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
+ rawOut);
out.write('a');
out.write('b');
out.write('c');
@Test
public void testWrite_SmallBlocks2() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, 6, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 6,
+ rawOut);
out.write(new byte[] { 'a', 'b', 'c' });
out.flush();
assertBuffer("0006\001a0006\001b0006\001c");
@Test
public void testWrite_SmallBlocks3() throws IOException {
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, 7, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA, 7,
+ rawOut);
out.write('a');
out.write(new byte[] { 'b', 'c' });
out.flush();
buf[i] = (byte) i;
}
- final SideBandOutputStream out;
- out = new SideBandOutputStream(CH_DATA, MAX_BUF, rawOut);
+ @SuppressWarnings("resource" /* java 7 */)
+ final SideBandOutputStream out = new SideBandOutputStream(CH_DATA,
+ MAX_BUF, rawOut);
out.write(buf);
out.flush();
}
}
+ @SuppressWarnings("resource" /* java 7 */)
@Test
public void testFlush() throws IOException {
final int[] flushCnt = new int[1];
@Test
public void testDestroyWhileOpen() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final TemporaryBuffer b = new TemporaryBuffer.LocalFile();
try {
b.write(new TestRng(getName())
@Test
public void testHeap() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final TemporaryBuffer b = new TemporaryBuffer.Heap(2 * 8 * 1024);
final byte[] r = new byte[8 * 1024];
b.write(r);
}
assertEquals(expected.length, read);
+ cis2.close();
}
+ cis1.close();
}
private static byte[] asBytes(String in) {
@Test
public void testReadSingleBytes() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream();
assertTrue(u.isEmpty());
@Test
public void testReadByteBlocks() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream();
u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
u.add(new ByteArrayInputStream(new byte[] { 3 }));
@Test
public void testArrayConstructor() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream(
new ByteArrayInputStream(new byte[] { 1, 0, 2 }),
new ByteArrayInputStream(new byte[] { 3 }),
@Test
public void testMarkSupported() {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream();
assertFalse(u.markSupported());
u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
@Test
public void testSkip() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream();
u.add(new ByteArrayInputStream(new byte[] { 1, 0, 2 }));
u.add(new ByteArrayInputStream(new byte[] { 3 }));
@Test
public void testAutoCloseDuringRead() throws IOException {
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream();
final boolean closed[] = new boolean[2];
u.add(new ByteArrayInputStream(new byte[] { 1 }) {
throw new IOException("Expected");
}
};
+ @SuppressWarnings("resource" /* java 7 */)
final UnionInputStream u = new UnionInputStream(
new ByteArrayInputStream(new byte[]{1,2,3}),
errorReadStream);
JGitText.get().cannotCreateIndexfile, tmpIdx.getPath()));
// write the packfile
+ @SuppressWarnings("resource" /* java 7 */)
FileChannel channel = new FileOutputStream(tmpPack).getChannel();
OutputStream channelStream = Channels.newOutputStream(channel);
try {
}
// write the packindex
+ @SuppressWarnings("resource")
FileChannel idxChannel = new FileOutputStream(tmpIdx).getChannel();
OutputStream idxStream = Channels.newOutputStream(idxChannel);
try {
}
}
+ @SuppressWarnings("resource" /* java 7 */)
private File toTemp(final MessageDigest md, final int type, long len,
final InputStream is) throws IOException, FileNotFoundException,
Error {
}
}
+ @SuppressWarnings("resource" /* java 7 */)
private File toTemp(final int type, final byte[] buf, final int pos,
final int len) throws IOException, FileNotFoundException {
boolean delete = true;
private boolean reportInternalServerErrorOverSideband() {
try {
- @SuppressWarnings("resource")
+ @SuppressWarnings("resource" /* java 7 */)
SideBandOutputStream err = new SideBandOutputStream(
SideBandOutputStream.CH_ERROR,
SideBandOutputStream.SMALL_BUF,
} catch (ServiceMayNotContinueException noPack) {
if (sideband && noPack.getMessage() != null) {
noPack.setOutput();
- @SuppressWarnings("resource")
+ @SuppressWarnings("resource" /* java 7 */)
SideBandOutputStream err = new SideBandOutputStream(
SideBandOutputStream.CH_ERROR,
SideBandOutputStream.SMALL_BUF, rawOut);
if (last < 0)
return ByteBuffer.wrap(out, 0, pos);
+ @SuppressWarnings("resource" /* java 7 */)
TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
tmp.write(out);
tmp.write(last);