Source:
private void commitImpl(Set<String> partitions, String key, String value) throws StreamingException { try { if ((key == null && value != null) || (key != null && value == null)) { throw new StreamingException(String.format( "If key is set, the value should be as well and vice versa," + " key, value = %s, %s", key, value)); } recordWriter.flush(); TxnToWriteId txnToWriteId = txnToWriteIds.get(currentTxnIndex); if (conn.isDynamicPartitioning()) { List<String> partNames = new ArrayList<>(recordWriter.getPartitions()); createdPartitions.addAll(partNames); if (partitions != null) { partNames.addAll(partitions); } if (!partNames.isEmpty()) { conn.getMSC().addDynamicPartitions(txnToWriteId.getTxnId(), txnToWriteId.getWriteId(), conn.getDatabase(), conn.getTable().getTableName(), partNames, DataOperationType.INSERT); } } if (currentTxnIndex + 1 >= txnToWriteIds.size()) { recordWriter.close(); conn.addWriteNotificationEvents(); } transactionLock.lock(); try { if (key != null) { conn.getMSC().commitTxnWithKeyValue(txnToWriteId.getTxnId(), tableId, key, value); } else { conn.getMSC().commitTxn(txnToWriteId.getTxnId()); } if (currentTxnIndex + 1 < txnToWriteIds.size()) { minTxnId.set(txnToWriteIds.get(currentTxnIndex + 1).getTxnId()); } else { minTxnId.set(-1); } } finally { transactionLock.unlock(); } state = HiveStreamingConnection.TxnState.COMMITTED; txnStatus[currentTxnIndex] = HiveStreamingConnection.TxnState.COMMITTED; } catch (NoSuchTxnException e) { throw new TransactionError("Invalid transaction id : " + getCurrentTxnId(), e); } catch (TxnAbortedException e) { throw new TransactionError("Aborted transaction " + "cannot be committed", e); } catch (TException e) { throw new TransactionError("Unable to commitTransaction transaction" + getCurrentTxnId(), e); } }

Target:
private void commitImpl(Set<String> partitions, String key, String value) throws StreamingException { try { if ((key == null && value != null) || (key != null && value == null)) { throw new StreamingException(String.format( "If key is set, the value should be as well and vice versa," + " key, value = %s, %s", key, value)); } recordWriter.flush(); TxnToWriteId txnToWriteId = txnToWriteIds.get(currentTxnIndex); if (conn.isDynamicPartitioning()) { List<String> partNames = new ArrayList<>(recordWriter.getPartitions()); createdPartitions.addAll(partNames); if (partitions != null) { partNames.addAll(partitions); } if (!partNames.isEmpty()) { conn.getMSC().addDynamicPartitions(txnToWriteId.getTxnId(), txnToWriteId.getWriteId(), conn.getDatabase(), conn.getTable().getTableName(), partNames, DataOperationType.INSERT); } } if ((currentTxnIndex + 1) >= txnToWriteIds.size()) { recordWriter.close(); conn.addWriteNotificationEvents(); } transactionLock.lock(); try { if (key != null) { conn.getMSC().commitTxnWithKeyValue(txnToWriteId.getTxnId(), tableId, key, value); } else { conn.getMSC().commitTxn(txnToWriteId.getTxnId()); } if (currentTxnIndex + 1 < txnToWriteIds.size()) { minTxnId.set(txnToWriteIds.get(currentTxnIndex + 1).getTxnId()); } else { minTxnId.set(-1); } } finally { transactionLock.unlock(); } state = HiveStreamingConnection.TxnState.COMMITTED; txnStatus[currentTxnIndex] = HiveStreamingConnection.TxnState.COMMITTED; } catch (NoSuchTxnException e) { throw new TransactionError("Invalid transaction id : " + getCurrentTxnId(), e); } catch (TxnAbortedException e) { throw new TransactionError("Aborted transaction " + "cannot be committed", e); } catch (TException e) { throw new TransactionError("Unable to commitTransaction transaction" + getCurrentTxnId(), e); } }