Program: 112554
Project: 112554
Buggy source:
/** 
 * <p>Loads wallet data from the given protocol buffer and inserts it into the given Wallet object. This is primarily useful when you wish to pre-register extension objects. Note that if loading fails the provided Wallet object may be in an indeterminate state and should be thrown away.</p> <p>A wallet can be unreadable for various reasons, such as inability to open the file, corrupt data, internally inconsistent data, a wallet extension marked as mandatory that cannot be handled and so on. You should always handle   {@link UnreadableWalletException} and communicate failure to the user in an appropriate manner.</p>
 * @throws UnreadableWalletException thrown in various error conditions (see description).
 */
public static Wallet readWallet(Protos.Wallet walletProto) throws UnreadableWalletException {
  if (walletProto.getVersion() > 2)   throw new UnreadableWalletException.FutureVersion();
  if (walletProto.getVersion() < 2) {
    walletProto=updateV1toV2Proto(walletProto);
  }
  final KeyCrypter crypter=getKeyCrypter(walletProto);
  DeterministicSeed seed=null;
  if (walletProto.hasSeed()) {
    Protos.Key key=walletProto.getSeed();
    if (key.hasSecretBytes()) {
      List<String> mnemonic=Splitter.on("String_Node_Str").splitToList(key.getSecretBytes().toStringUtf8());
      seed=new DeterministicSeed(new byte[16],mnemonic,0);
    }
 else     if (key.hasEncryptedData()) {
      EncryptedData data=new EncryptedData(key.getEncryptedData().getInitialisationVector().toByteArray(),key.getEncryptedData().getEncryptedPrivateKey().toByteArray());
      seed=new DeterministicSeed(data,null,0);
    }
 else {
      throw new UnreadableWalletException("String_Node_Str" + key.toString());
    }
  }
  DeterministicKey masterKey=KeyUtils.getDeterministicKey(walletProto.getMasterKey(),null,crypter);
  Wallet wallet=new Wallet(masterKey,seed);
  if (walletProto.hasVersion()) {
    wallet.setVersion(walletProto.getVersion());
  }
  WalletPocketProtobufSerializer pocketSerializer=new WalletPocketProtobufSerializer();
  NxtFamilyWalletProtobufSerializer nxtPocketSerializer=new NxtFamilyWalletProtobufSerializer();
  for (  Protos.WalletPocket pocketProto : walletProto.getPocketsList()) {
    CoinType type=getType(pocketProto);
    AbstractWallet pocket;
    if (type instanceof BitFamily) {
      pocket=pocketSerializer.readWallet(pocketProto,crypter);
    }
 else     if (type instanceof NxtFamily) {
      pocket=nxtPocketSerializer.readWallet(pocketProto,crypter);
    }
 else {
      throw new UnreadableWalletException("String_Node_Str" + type);
    }
    wallet.addAccount(pocket);
  }
  if (wallet.getVersion() < 2) {
    updateV1toV2(wallet);
  }
  return wallet;
}

Fixed version (ground truth):
/** 
 * <p>Loads wallet data from the given protocol buffer and inserts it into the given Wallet object. This is primarily useful when you wish to pre-register extension objects. Note that if loading fails the provided Wallet object may be in an indeterminate state and should be thrown away.</p> <p>A wallet can be unreadable for various reasons, such as inability to open the file, corrupt data, internally inconsistent data, a wallet extension marked as mandatory that cannot be handled and so on. You should always handle   {@link UnreadableWalletException} and communicate failure to the user in an appropriate manner.</p>
 * @throws UnreadableWalletException thrown in various error conditions (see description).
 */
public static Wallet readWallet(Protos.Wallet walletProto) throws UnreadableWalletException {
  if (walletProto.getVersion() > 3)   throw new UnreadableWalletException.FutureVersion();
  walletProto=applyProtoUpdates(walletProto);
  final KeyCrypter crypter=getKeyCrypter(walletProto);
  DeterministicSeed seed=null;
  if (walletProto.hasSeed()) {
    Protos.Key key=walletProto.getSeed();
    if (key.hasSecretBytes()) {
      List<String> mnemonic=Splitter.on("String_Node_Str").splitToList(key.getSecretBytes().toStringUtf8());
      seed=new DeterministicSeed(new byte[16],mnemonic,0);
    }
 else     if (key.hasEncryptedData()) {
      EncryptedData data=new EncryptedData(key.getEncryptedData().getInitialisationVector().toByteArray(),key.getEncryptedData().getEncryptedPrivateKey().toByteArray());
      seed=new DeterministicSeed(data,null,0);
    }
 else {
      throw new UnreadableWalletException("String_Node_Str" + key.toString());
    }
  }
  DeterministicKey masterKey=KeyUtils.getDeterministicKey(walletProto.getMasterKey(),null,crypter);
  Wallet wallet=new Wallet(masterKey,seed);
  if (walletProto.hasVersion()) {
    wallet.setVersion(walletProto.getVersion());
  }
  WalletPocketProtobufSerializer pocketSerializer=new WalletPocketProtobufSerializer();
  NxtFamilyWalletProtobufSerializer nxtPocketSerializer=new NxtFamilyWalletProtobufSerializer();
  for (  Protos.WalletPocket pocketProto : walletProto.getPocketsList()) {
    CoinType type=getType(pocketProto);
    AbstractWallet pocket;
    if (type instanceof BitFamily) {
      pocket=pocketSerializer.readWallet(pocketProto,crypter);
    }
 else     if (type instanceof NxtFamily) {
      pocket=nxtPocketSerializer.readWallet(pocketProto,crypter);
    }
 else {
      throw new UnreadableWalletException("String_Node_Str" + type);
    }
    wallet.addAccount(pocket);
  }
  applyWalletUpdates(wallet);
  return wallet;
}