Use try with resources
This commit is contained in:
parent
aebb8b87d2
commit
5174eebb3a
@ -103,9 +103,8 @@ public class MotorDatabaseLoader extends AsynchronousDatabaseLoader {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void loadSerialized(Pair<File, InputStream> f) {
|
||||
try {
|
||||
log.debug("Reading motors from file " + f.getU().getPath());
|
||||
ObjectInputStream ois = new ObjectInputStream(f.getV());
|
||||
log.debug("Reading motors from file " + f.getU().getPath());
|
||||
try (ObjectInputStream ois = new ObjectInputStream(f.getV())) {
|
||||
List<ThrustCurveMotor> motors = (List<ThrustCurveMotor>) ois.readObject();
|
||||
addMotors(motors);
|
||||
} catch (Exception ex) {
|
||||
|
@ -52,7 +52,6 @@ public class RASPMotorLoader extends AbstractMotorLoader {
|
||||
public List<ThrustCurveMotor.Builder> load(Reader reader, String filename, boolean removeDelayFromDesignation)
|
||||
throws IOException {
|
||||
List<ThrustCurveMotor.Builder> motors = new ArrayList<>();
|
||||
BufferedReader in = new BufferedReader(reader);
|
||||
|
||||
String manufacturer = "";
|
||||
String designation = "";
|
||||
@ -68,7 +67,7 @@ public class RASPMotorLoader extends AbstractMotorLoader {
|
||||
double propW = 0;
|
||||
double totalW = 0;
|
||||
|
||||
try {
|
||||
try (BufferedReader in = new BufferedReader(reader)) {
|
||||
String line;
|
||||
String[] pieces, buf;
|
||||
|
||||
|
@ -406,11 +406,9 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
|
||||
* Package scope so the factory can call it.
|
||||
*/
|
||||
void computeDigest() {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream os = new DataOutputStream(bos);
|
||||
|
||||
try (DataOutputStream os = new DataOutputStream(bos)) {
|
||||
List<TypedKey<?>> keys = new ArrayList<>(properties.keySet());
|
||||
|
||||
keys.sort(new Comparator<>() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user