Buggy code:
class IdentityPatchRunner implements InstallationManager . ModificationCompletion { private static final String DIRECTORY_SUFFIX = "jboss-as-patch-" ; private static final File TEMP_DIR = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; private final InstalledImage installedImage ; IdentityPatchRunner ( InstalledImage installedImage ) { } public PatchingResult applyPatch ( final Patch patch , final PatchContentProvider contentProvider , final ContentVerificationPolicy contentPolicy , final InstallationManager . InstallationModification modification ) throws PatchingException { } private PatchingResult applyPatch ( final String patchId , final Patch patch , final IdentityPatchContext context ) throws IOException , XMLStreamException , PatchingException { final List < String > invalidation ; final Identity identity = patch . getIdentity ( ) ; final Patch . PatchType patchType = identity . getPatchType ( ) ; final InstallationManager . InstallationModification modification = context . getModification ( ) ; if ( patchType == ( PatchType . ONE_OFF ) ) { invalidation = Collections . emptyList ( ) ; final Identity . IdentityOneOffPatch oneOffPatch = identity . forType ( ONE_OFF , IdentityOneOffPatch . class ) ; if ( ! ( modification . getCumulativeID ( ) . equals ( oneOffPatch . getCumulativePatchId ( ) ) ) ) { throw MESSAGES . doesNotApply ( oneOffPatch . getCumulativePatchId ( ) , modification . getCumulativeID ( ) ) ; } } else { invalidation = new ArrayList < String > ( modification . getPatchIDs ( ) ) ; if ( ! ( BASE . equals ( modification . getCumulativeID ( ) ) ) ) { invalidation . add ( modification . getCumulativeID ( ) ) ; } } for ( final String rollback : invalidation ) { rollback ( rollback , context , false ) ; } if ( patchType == ( PatchType . UPGRADE ) ) { final String releasePatchID = modification . getReleasePatchID ( ) ; if ( ! ( BASE . equals ( releasePatchID ) ) ) { portForward ( modification . getReleasePatchID ( ) , context ) ; } } for ( final PatchElement element : patch . getElements ( ) ) { final IdentityPatchContext . PatchEntry target = context . resolveForElement ( element ) ; final PatchElementProvider provider = element . getProvider ( ) ; final Patch . PatchType elementPatchType = provider . getPatchType ( ) ; final String elementPatchId = element . getId ( ) ; if ( target . isApplied ( elementPatchId ) ) { throw MESSAGES . alreadyApplied ( elementPatchId ) ; } IdentityPatchRunner . checkUpgradeConditions ( provider , target ) ; if ( elementPatchType == ( PatchType . ONE_OFF ) ) { PatchElementProvider . OneOffPatchTarget oneOffPatch = provider . forType ( ONE_OFF , OneOffPatchTarget . class ) ; if ( ! ( target . getCumulativeID ( ) . equals ( oneOffPatch . getCumulativePatchId ( ) ) ) ) { throw MESSAGES . doesNotApply ( oneOffPatch . getCumulativePatchId ( ) , target . getCumulativeID ( ) ) ; } } PatchingTasks . apply ( elementPatchId , element . getModifications ( ) , target . getDefinitions ( ) ) ; target . apply ( elementPatchId , elementPatchType ) ; } final IdentityPatchContext . PatchEntry identityEntry = context . getIdentityEntry ( ) ; PatchingTasks . apply ( patchId , patch . getModifications ( ) , identityEntry . getDefinitions ( ) ) ; identityEntry . apply ( patchId , patchType ) ; if ( patchType == ( PatchType . UPGRADE ) ) { final Identity . IdentityUpgrade upgrade = identity . forType ( UPGRADE , IdentityUpgrade . class ) ; identityEntry . setResultingVersion ( upgrade . getResultingVersion ( ) ) ; } final IdentityApplyCallback callback = new IdentityApplyCallback ( patch , identityEntry . getDirectoryStructure ( ) ) ; try { return IdentityPatchRunner . executeTasks ( context , callback ) ; } catch ( Exception e ) { <START_BUG> callback . operationCancelled ( ) ; <END_BUG> throw IdentityPatchRunner . rethrowException ( e ) ; } } public PatchingResult rollbackPatch ( final String patchId , final ContentVerificationPolicy contentPolicy , final boolean rollbackTo , final boolean resetConfiguration , InstallationManager . InstallationModification modification ) throws PatchingException { } @ Override public void completed ( ) { } @ Override public void canceled ( ) { } private void portForward ( final String patchID , final IdentityPatchContext context ) throws PatchingException { } private void rollback ( final String patchID , final IdentityPatchContext context , boolean restoreFromHistory ) throws PatchingException { } static void restoreFromHistory ( final InstallationManager . MutablePatchingTarget target , final String rollbackPatchId , final Patch . PatchType patchType , final PatchableTarget . TargetInfo history ) throws PatchingException { } static void checkState ( final PatchableTarget . TargetInfo o , final PatchableTarget . TargetInfo n ) { } static PatchingResult executeTasks ( final IdentityPatchContext context , final IdentityPatchContext . FinalizeCallback callback ) throws Exception { } static void prepareTasks ( final IdentityPatchContext . PatchEntry entry , final IdentityPatchContext context , final List < IdentityPatchRunner . PreparedTask > tasks , final List < ContentItem > conflicts ) throws PatchingException { } static PatchingTask createTask ( final PatchingTasks . ContentTaskDefinition definition , final PatchContentProvider provider , final PatchingTaskContext context ) { } static class PreparedTask { private final PatchingTask task ; private final PatchEntry entry ; PreparedTask ( PatchingTask task , IdentityPatchContext . PatchEntry entry ) { } ContentItem getContentItem ( ) { } protected void execute ( ) throws IOException { } } static Patch loadPatchInformation ( final String patchId , final InstalledImage installedImage ) throws IOException , XMLStreamException { } static RollbackPatch loadRollbackInformation ( final String patchId , final InstalledImage installedImage ) throws IOException , XMLStreamException { } static File createTempDir ( ) throws PatchingException { } static PatchingException rethrowException ( final Exception e ) { } static void checkUpgradeConditions ( final UpgradeCondition condition , final InstallationManager . MutablePatchingTarget target ) throws PatchingException { } }

Fix:
callback . operationCancelled ( context ) ;