Merge "modify fail fast mode for loading apns"
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 62435ee..b7cc7a9 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -342,21 +342,21 @@
             if (parser != null) {
                 try {
                     db.beginTransaction();
-                    while (true) {
-                        XmlUtils.nextElement(parser);
+                    XmlUtils.nextElement(parser);
+                    while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
                         ContentValues row = getRow(parser);
-                        if (row != null) {
-                            insertAddingDefaults(db, CARRIERS_TABLE, row);
-                        } else {
-                            break;  // do we really want to skip the rest of the file?
+                        if (row == null) {
+                            throw new XmlPullParserException("Expected 'apn' tag", parser, null);
                         }
+                        insertAddingDefaults(db, CARRIERS_TABLE, row);
+                        XmlUtils.nextElement(parser);
                     }
                     db.setTransactionSuccessful();
-                } catch (XmlPullParserException e)  {
-                    Log.e(TAG, "Got execption while loading apns.", e);
+                } catch (XmlPullParserException e) {
+                    Log.e(TAG, "Got XmlPullParserException while loading apns.", e);
                 } catch (IOException e) {
-                    Log.e(TAG, "Got IOExecption while loading apns.", e);
-                } catch (SQLException e){
+                    Log.e(TAG, "Got IOException while loading apns.", e);
+                } catch (SQLException e) {
                     Log.e(TAG, "Got SQLException while loading apns.", e);
                 } finally {
                     db.endTransaction();