Merge pull request #531 from krabaey/feature-close-files
Close streams to avoid leakage
This commit is contained in:
commit
2e89c3cf39
1 changed files with 12 additions and 4 deletions
|
@ -1,12 +1,10 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.osmand.Collator;
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -120,11 +118,21 @@ public class RoutingConfiguration {
|
||||||
|
|
||||||
public static RoutingConfiguration.Builder getDefault() {
|
public static RoutingConfiguration.Builder getDefault() {
|
||||||
if (DEFAULT == null) {
|
if (DEFAULT == null) {
|
||||||
|
InputStream resourceAsStream = null;
|
||||||
try {
|
try {
|
||||||
DEFAULT = parseFromInputStream(RoutingConfiguration.class.getResourceAsStream("routing.xml"));
|
resourceAsStream = RoutingConfiguration.class.getResourceAsStream("routing.xml");
|
||||||
|
DEFAULT = parseFromInputStream(resourceAsStream);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
} finally {
|
||||||
|
if (resourceAsStream != null) {
|
||||||
|
try {
|
||||||
|
resourceAsStream.close();
|
||||||
|
} catch (IOException ignore) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue