Use try-with-resources statements
- instead of finally blocks - in cases of missing try-finally Change-Id: I94f481a33d8e6a3180c436245d6e95e4d525280c
This commit is contained in:
@@ -77,19 +77,14 @@ public class CssLinker extends AbstractLinker {
|
||||
|
||||
private String name(final TreeLogger logger, final PublicResource r)
|
||||
throws UnableToCompleteException {
|
||||
final InputStream in = r.getContents(logger);
|
||||
final ByteArrayOutputStream tmp = new ByteArrayOutputStream();
|
||||
try {
|
||||
try {
|
||||
final byte[] buf = new byte[2048];
|
||||
int n;
|
||||
while ((n = in.read(buf)) >= 0) {
|
||||
tmp.write(buf, 0, n);
|
||||
}
|
||||
tmp.close();
|
||||
} finally {
|
||||
in.close();
|
||||
try (InputStream in = r.getContents(logger)) {
|
||||
final byte[] buf = new byte[2048];
|
||||
int n;
|
||||
while ((n = in.read(buf)) >= 0) {
|
||||
tmp.write(buf, 0, n);
|
||||
}
|
||||
tmp.close();
|
||||
} catch (IOException e) {
|
||||
final UnableToCompleteException ute = new UnableToCompleteException();
|
||||
ute.initCause(e);
|
||||
|
Reference in New Issue
Block a user