am a406b5fc: Cherry pick relavant changes to mr0 to fix bug of losing national prefix in formatInOriginalFormat.
* commit 'a406b5fc8c99b50812e9e1a97cdaa4cb1be505ee':
Cherry pick relavant changes to mr0 to fix bug of losing national prefix in formatInOriginalFormat.
diff --git a/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java b/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
index df8de2a..7c40d18 100644
--- a/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
+++ b/java/src/com/android/i18n/phonenumbers/PhoneNumberUtil.java
@@ -607,7 +607,7 @@
private void loadMetadataForRegionFromFile(String filePrefix, String regionCode) {
InputStream source =
PhoneNumberUtil.class.getResourceAsStream(filePrefix + "_" + regionCode);
- ObjectInputStream in;
+ ObjectInputStream in = null;
try {
in = new ObjectInputStream(source);
PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection();
@@ -617,6 +617,18 @@
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, e.toString());
+ } finally {
+ close(in);
+ }
+ }
+
+ private void close(InputStream in) {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, e.toString());
+ }
}
}
diff --git a/java/src/com/android/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java b/java/src/com/android/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java
index 1d0af1b..a577e10 100644
--- a/java/src/com/android/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java
+++ b/java/src/com/android/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java
@@ -59,12 +59,14 @@
private void loadMappingFileProvider() {
InputStream source =
PhoneNumberOfflineGeocoder.class.getResourceAsStream(phonePrefixDataDirectory + "config");
- ObjectInputStream in;
+ ObjectInputStream in = null;
try {
in = new ObjectInputStream(source);
mappingFileProvider.readExternal(in);
} catch (IOException e) {
LOGGER.log(Level.WARNING, e.toString());
+ } finally {
+ close(in);
}
}
@@ -83,7 +85,7 @@
private void loadAreaCodeMapFromFile(String fileName) {
InputStream source =
PhoneNumberOfflineGeocoder.class.getResourceAsStream(phonePrefixDataDirectory + fileName);
- ObjectInputStream in;
+ ObjectInputStream in = null;
try {
in = new ObjectInputStream(source);
AreaCodeMap map = new AreaCodeMap();
@@ -91,6 +93,18 @@
availablePhonePrefixMaps.put(fileName, map);
} catch (IOException e) {
LOGGER.log(Level.WARNING, e.toString());
+ } finally {
+ close(in);
+ }
+ }
+
+ private void close(InputStream in) {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ LOGGER.log(Level.WARNING, e.toString());
+ }
}
}
diff --git a/java/src/com/android/i18n/phonenumbers/geocoding/data/1_en b/java/src/com/android/i18n/phonenumbers/geocoding/data/1_en
deleted file mode 100644
index b8661ef..0000000
--- a/java/src/com/android/i18n/phonenumbers/geocoding/data/1_en
+++ /dev/null
Binary files differ
diff --git a/java/test/com/android/i18n/phonenumbers/geocoding/testing_data/1_en b/java/test/com/android/i18n/phonenumbers/geocoding/testing_data/1_en
deleted file mode 100644
index 74ef19c..0000000
--- a/java/test/com/android/i18n/phonenumbers/geocoding/testing_data/1_en
+++ /dev/null
Binary files differ