Source:
<code>Entry getEntryFor(Transaction transaction, SimpleXid gtid) { Entry entry = (Entry) getResource(transaction, ENTRY_KEY); if (entry != null) { return entry; } final XidKey xidKey; synchronized (ENTRY_KEY) { entry = (Entry) getResource(transaction, ENTRY_KEY); if (entry != null) { return entry; } int lifetime = getTimeout(transaction) + staleTransactionTime; final long timeTick = getTimeTick(); xidKey = new XidKey(gtid, timeTick + lifetime * 1_000_000_000L); putResource(transaction, ENTRY_KEY, entry = new Entry(gtid, transaction, xidKey)); } timeoutSet.add(xidKey); if (! isStatusInactive(transaction)) { try { registerInterposedSynchronization(transaction, new Synchronization() { public void beforeCompletion() { } public void afterCompletion(final int status) { final long timeTick = getTimeTick(); final ConcurrentMap<SimpleXid, Entry> known = JBossLocalTransactionProvider.this.known; final Iterator<XidKey> iterator = timeoutSet.headSet(new XidKey(SimpleXid.EMPTY, timeTick)).iterator(); while (iterator.hasNext()) { SimpleXid xidToRemove = iterator.next().getId(); Entry knownEntry = known.remove(xidToRemove); if(knownEntry == null) { Log.log.unknownXidToBeRemovedFromTheKnownTransactionInstances(xidToRemove); <START> } else if(knownEntry.getTransaction() instanceof ImportedTransaction) { <END> try { ext.removeImportedTransaction(getXid(knownEntry.getTransaction())); } catch (XAException xae) { Log.log.cannotRemoveImportedTransaction(xidToRemove, xae); } } iterator.remove(); } } }); } catch (IllegalStateException e) { if (! isStatusInactive(transaction)) { throw e; } } } return entry; }</code><technical_language>knownEntry.getTransaction() factored a variable is referenced more once. Also, this is minor, please formatting rest of file (a space if)</technical_language>

Target:
Entry getEntryFor(Transaction transaction, SimpleXid gtid) { Entry entry = (Entry) getResource(transaction, ENTRY_KEY); if (entry != null) { return entry; } final XidKey xidKey; synchronized (ENTRY_KEY) { entry = (Entry) getResource(transaction, ENTRY_KEY); if (entry != null) { return entry; } int lifetime = getTimeout(transaction) + staleTransactionTime; final long timeTick = getTimeTick(); xidKey = new XidKey(gtid, timeTick + lifetime * 1_000_000_000L); putResource(transaction, ENTRY_KEY, entry = new Entry(gtid, transaction, xidKey)); } timeoutSet.add(xidKey); if (! isStatusInactive(transaction)) { try { registerInterposedSynchronization(transaction, new Synchronization() { public void beforeCompletion() { } public void afterCompletion(final int status) { final long timeTick = getTimeTick(); final ConcurrentMap<SimpleXid, Entry> known = JBossLocalTransactionProvider.this.known; final Iterator<XidKey> iterator = timeoutSet.headSet(new XidKey(SimpleXid.EMPTY, timeTick)).iterator(); while (iterator.hasNext()) { SimpleXid xidToRemove = iterator.next().getId(); Entry knownEntry = known.remove(xidToRemove); if (knownEntry == null) { Log.log.unknownXidToBeRemovedFromTheKnownTransactionInstances(xidToRemove); } else { final Transaction transaction = knownEntry.getTransaction(); if (transaction instanceof ImportedTransaction) { try { ext.removeImportedTransaction(getXid(transaction)); } catch (XAException xae) { Log.log.cannotRemoveImportedTransaction(xidToRemove, xae); } } } iterator.remove(); } } }); } catch (IllegalStateException e) { if (! isStatusInactive(transaction)) { throw e; } } } return entry; }