Source:
<code>public boolean commit(UserDatabase userDB) { for (ID tradeId : newTrades) { Trade trade = DatabaseController.getTradeByID(tradeId); User otherUser = DatabaseController.getAccountByUserID(trade.getHalf2().getUser()); User theUser = DatabaseController.getAccountByUserID(getOwnerID()); otherUser.getTradeList().addTrade(userDB, trade); try { MasterController.getUserDB().getElastic().updateDocument("user", otherUser.getProfile().getUsername(), otherUser.getTradeList(), "tradeList"); MasterController.getUserDB().getElastic().updateDocument("user", theUser.getProfile().getUsername(), theUser.getTradeList(), "tradeList"); } catch (IOException e) { e.printStackTrace(); return false; } if (!trade.commit(userDB)) return false; } newTrades.clear(); for (ID tradeId : deletedTrades) { Trade trade = DatabaseController.getTradeByID(tradeId); User currentUser = DatabaseController.getAccountByUserID(getOwnerID()); User tradePartner = DatabaseController.getAccountByUserID(trade.getHalf2().getUser()); <START> if (tradeId == null){ <END> continue; } if (tradePartner.getTradeList().contains(tradeId)){ tradePartner.getTradeList().delete(trade); } else if (currentUser.getTradeList().contains(tradeId)){ currentUser.getTradeList().delete(trade); } try { MasterController.getUserDB().getElastic().updateDocument("user", tradePartner.getProfile().getUsername(), tradePartner.getTradeList(), "tradeList"); MasterController.getUserDB().getElastic().updateDocument("user", currentUser.getProfile().getUsername(), currentUser.getTradeList(), "tradeList"); } catch (IOException e) { e.printStackTrace(); return false; } if (!trade.commit(userDB)) return false; } deletedTrades.clear(); return true; }</code><technical_language>if a null, a bigger error else. I</technical_language>

Target:
public boolean commit(UserDatabase userDB) { for (ID tradeId : newTrades) { Trade trade = DatabaseController.getTradeByID(tradeId); User otherUser = DatabaseController.getAccountByUserID(trade.getHalf2().getUser()); User theUser = DatabaseController.getAccountByUserID(getOwnerID()); otherUser.getTradeList().addTrade(userDB, trade); try { MasterController.getUserDB().getElastic().updateDocument("user", otherUser.getProfile().getUsername(), otherUser.getTradeList(), "tradeList"); MasterController.getUserDB().getElastic().updateDocument("user", theUser.getProfile().getUsername(), theUser.getTradeList(), "tradeList"); } catch (IOException e) { e.printStackTrace(); return false; } if (!trade.commit(userDB)) return false; } newTrades.clear(); for (ID tradeId : deletedTrades) { Trade trade = DatabaseController.getTradeByID(tradeId); User currentUser = DatabaseController.getAccountByUserID(getOwnerID()); User tradePartner = DatabaseController.getAccountByUserID(trade.getHalf2().getUser()); if (tradePartner.getTradeList().contains(tradeId)){ tradePartner.getTradeList().delete(trade); } else if (currentUser.getTradeList().contains(tradeId)){ currentUser.getTradeList().delete(trade); } try { MasterController.getUserDB().getElastic().updateDocument("user", tradePartner.getProfile().getUsername(), tradePartner.getTradeList(), "tradeList"); MasterController.getUserDB().getElastic().updateDocument("user", currentUser.getProfile().getUsername(), currentUser.getTradeList(), "tradeList"); } catch (IOException e) { e.printStackTrace(); return false; } if (!trade.commit(userDB)) return false; } deletedTrades.clear(); return true; }