You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
3 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
|
||
|
package codetoanalyze.java.checkers;
|
||
|
|
||
|
import java.io.Closeable;
|
||
|
import java.io.FileInputStream;
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class LeaksAccessPathsInterprocedural {
|
||
|
|
||
|
void closeResourceOk(Closeable c) throws IOException {
|
||
|
c.close();
|
||
|
}
|
||
|
|
||
|
void closeResourceWrapperOk(Closeable c) throws IOException {
|
||
|
closeResourceOk(c);
|
||
|
}
|
||
|
|
||
|
void closeResourceDirectOK() throws IOException, FileNotFoundException {
|
||
|
closeResourceOk(new FileInputStream("file.txt"));
|
||
|
}
|
||
|
|
||
|
void closeResourceTransitiveOk() throws IOException, FileNotFoundException {
|
||
|
closeResourceOk(new FileInputStream("file.txt"));
|
||
|
}
|
||
|
|
||
|
void closeOne(Closeable c1, Closeable c2) throws IOException {
|
||
|
c2.close();
|
||
|
}
|
||
|
|
||
|
void closeOnlyOneBad() throws IOException, FileNotFoundException {
|
||
|
closeOne(new FileInputStream("1.txt"), new FileInputStream("2.txt")); // warning
|
||
|
}
|
||
|
}
|