|
|
@ -18,7 +18,6 @@ package com.google.i18n.phonenumbers; |
|
|
|
|
|
|
|
|
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata; |
|
|
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadata; |
|
|
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadataCollection; |
|
|
import com.google.i18n.phonenumbers.nano.Phonemetadata.PhoneMetadataCollection; |
|
|
import com.google.protobuf.nano.CodedInputByteBufferNano; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
@ -101,10 +100,9 @@ final class SingleFileMetadataSourceImpl implements MetadataSource { |
|
|
logger.log(Level.SEVERE, "missing metadata: " + fileName); |
|
|
logger.log(Level.SEVERE, "missing metadata: " + fileName); |
|
|
throw new IllegalStateException("missing metadata: " + fileName); |
|
|
throw new IllegalStateException("missing metadata: " + fileName); |
|
|
} |
|
|
} |
|
|
ObjectInputStream in = null; |
|
|
|
|
|
try { |
|
|
try { |
|
|
in = new ObjectInputStream(source); |
|
|
|
|
|
PhoneMetadataCollection metadataCollection = loadMetadataAndCloseInput(in); |
|
|
|
|
|
|
|
|
PhoneMetadataCollection metadataCollection = |
|
|
|
|
|
loadMetadataAndCloseInput(new ObjectInputStream(source)); |
|
|
PhoneMetadata[] metadataList = metadataCollection.metadata; |
|
|
PhoneMetadata[] metadataList = metadataCollection.metadata; |
|
|
if (metadataList.length == 0) { |
|
|
if (metadataList.length == 0) { |
|
|
logger.log(Level.SEVERE, "empty metadata: " + fileName); |
|
|
logger.log(Level.SEVERE, "empty metadata: " + fileName); |
|
|
@ -140,9 +138,8 @@ final class SingleFileMetadataSourceImpl implements MetadataSource { |
|
|
|
|
|
|
|
|
PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection(); |
|
|
PhoneMetadataCollection metadataCollection = new PhoneMetadataCollection(); |
|
|
try { |
|
|
try { |
|
|
CodedInputByteBufferNano byteBuffer = MetadataManager.convertStreamToByteBuffer( |
|
|
|
|
|
source, SINGLE_FILE_BUFFER_SIZE); |
|
|
|
|
|
metadataCollection.mergeFrom(byteBuffer); |
|
|
|
|
|
|
|
|
metadataCollection.mergeFrom( |
|
|
|
|
|
MetadataManager.convertStreamToByteBuffer(source, SINGLE_FILE_BUFFER_SIZE)); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
logger.log(Level.WARNING, "error reading input (ignored)", e); |
|
|
logger.log(Level.WARNING, "error reading input (ignored)", e); |
|
|
} finally { |
|
|
} finally { |
|
|
|