auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public List<Task<? extends Serializable>> handle(Context context) throws SemanticException { DropDatabaseMessage msg = deserializer.getDropDatabaseMessage(context.dmd.getPayload()); String actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; DropDatabaseDesc desc = new DropDatabaseDesc(actualDbName, true); Task<? extends Serializable> dropDBTask = TaskFactory .get(new DDLWork(new HashSet<>(), new HashSet<>(), desc), context.hiveConf); context.log.info( "Added drop database task : {}:{}", dropDBTask.getId(), desc.getDatabaseName()); updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, null, null); return Collections.singletonList(dropDBTask); }

Target:
public List<Task<? extends Serializable>> handle(Context context) throws SemanticException { DropDatabaseMessage msg = deserializer.getDropDatabaseMessage(context.dmd.getPayload()); String actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; DropDatabaseDesc desc = new DropDatabaseDesc(actualDbName, true, context.eventOnlyReplicationSpec()); Task<? extends Serializable> dropDBTask = TaskFactory .get(new DDLWork(new HashSet<>(), new HashSet<>(), desc), context.hiveConf); context.log.info( "Added drop database task : {}:{}", dropDBTask.getId(), desc.getDatabaseName()); updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, null, null); return Collections.singletonList(dropDBTask); }
Source:
protected void autoMountPages() { if (!AutoMounter.mountAll(this)) { LOG.warn("Unable to Automount pages."); } final Class<? extends WebPage> authPage = getSignInPageClass(); if (authPage != null) { final MountPath mp = authPage.getAnnotation(MountPath.class); if (mp == null) { final SecureAutoMount annot = getClass().getAnnotation(SecureAutoMount.class); String root = annot.defaultRoot().trim(); if (!root.isEmpty() && !root.endsWith("/")) { root = root + "/"; } String mime = annot.defaultMimeExtension().trim(); if (!mime.isEmpty() && !mime.startsWith(".")) { mime = "." + mime; } final String loginPagePath = root + "login" + mime; LOG.info("Mounting SignInPageClass: to path {}", authPage, loginPagePath); mountPage(loginPagePath, authPage); } } }

Target:
protected boolean autoMountPages() { final boolean mountOk = AutoMounter.mountAll(this); if (!mountOk) { LOG.warn("Unable to Automount pages."); } final Class<? extends WebPage> authPage = getSignInPageClass(); if (authPage != null) { final MountPath mp = authPage.getAnnotation(MountPath.class); if (mp == null) { final SecureAutoMount annot = getClass().getAnnotation(SecureAutoMount.class); String root = annot.defaultRoot().trim(); if (!root.isEmpty() && !root.endsWith("/")) { root = root + "/"; } String mime = annot.defaultMimeExtension().trim(); if (!mime.isEmpty() && !mime.startsWith(".")) { mime = "." + mime; } final String loginPagePath = root + "login" + mime; LOG.info("Mounting SignInPageClass: to path {}", authPage, loginPagePath); mountPage(loginPagePath, authPage); } } return mountOk; }
Source:
private void createSkipLine(int row, SkippedLine line) { FlowPanel p = new FlowPanel(); InlineLabel l1 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionStart() + " "); InlineLabel l2 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionEnd() + " "); Anchor all = new Anchor(String.valueOf(line.getSize())); all.addClickHandler(expandAllListener); all.setStyleName(Gerrit.RESOURCES.css().skipLine()); if (line.getSize() > 30) { Anchor b = new Anchor(); Anchor a = new Anchor(); b.setHTML(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND)); a.setHTML(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND)); b.addClickHandler(expandBeforeListener); a.addClickHandler(expandAfterListener); b.setStyleName(Gerrit.RESOURCES.css().skipLine()); a.setStyleName(Gerrit.RESOURCES.css().skipLine()); p.add(b); p.add(l1); p.add(all); p.add(l2); p.add(a); } else { p.add(l1); p.add(all); p.add(l2); } table.setWidget(row, 1, p); }

Target:
private void createSkipLine(int row, SkippedLine line) { FlowPanel p = new FlowPanel(); InlineLabel l1 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionStart() + " "); InlineLabel l2 = new InlineLabel(" " + PatchUtil.C.patchSkipRegionEnd() + " "); Anchor all = new Anchor(String.valueOf(line.getSize())); all.addClickHandler(expandAllListener); all.setStyleName(Gerrit.RESOURCES.css().skipLine()); if (line.getSize() > 30) { Anchor b = new Anchor(PatchUtil.M.expandBefore(NUM_ROWS_TO_EXPAND), true); Anchor a = new Anchor(PatchUtil.M.expandAfter(NUM_ROWS_TO_EXPAND), true); b.addClickHandler(expandBeforeListener); a.addClickHandler(expandAfterListener); b.setStyleName(Gerrit.RESOURCES.css().skipLine()); a.setStyleName(Gerrit.RESOURCES.css().skipLine()); p.add(b); p.add(l1); p.add(all); p.add(l2); p.add(a); } else { p.add(l1); p.add(all); p.add(l2); } table.setWidget(row, 1, p); }
Source:
public void free() { try { store.releaseLease(path, leaseID); } catch (IOException e) { LOG.info("Exception when trying to free lease " + leaseID + " on " + path + ". " + e.getMessage()); } finally { leaseFreed = true; LOG.debug("Freed lease " + leaseID + " on " + path + " managed by thread " + renewer.getName()); } }

Target:
public void free() { try { LOG.debug("lease path: {}, release lease id: {}", path, leaseID); client.releaseLease(getRelativePath(path), leaseID); } catch (IOException e) { LOG.info("Exception when trying to release lease on {}. Lease will be left to expire: {}", leaseID, path, e.getMessage()); LOG.debug("Exception releasing lease", e); } finally { leaseFreed = true; LOG.debug("Freed lease on managed by thread {}", leaseID, path, renewer.getName()); } }
Source:
public void stopContainer(String container, long timeout, TimeUnit timeunit) throws IOException { final List<Pair<String, ?>> headers = new ArrayList<>(2); headers.add(Pair.of("Content-Type", "text/plain")); headers.add(Pair.of("Content-Length", 0)); try (DockerConnection connection = openConnection(dockerDaemonUri).method("POST") .path("/containers/" + container + "/stop") .query("t", timeunit.toSeconds(timeout)) .headers(headers)) { final DockerResponse response = connection.request(); final int status = response.getStatus(); if (!(204 == status || 304 == status)) { throw new DockerException(getDockerExceptionMessage(response), status); } } }

Target:
public void stopContainer(String container, long timeout, TimeUnit timeunit) throws IOException { final List<Pair<String, ?>> headers = new ArrayList<>(2); headers.add(Pair.of("Content-Type", MediaType.TEXT_PLAIN)); headers.add(Pair.of("Content-Length", 0)); try (DockerConnection connection = openConnection(dockerDaemonUri).method("POST") .path("/containers/" + container + "/stop") .query("t", timeunit.toSeconds(timeout)) .headers(headers)) { final DockerResponse response = connection.request(); final int status = response.getStatus(); if (!(NO_CONTENT.getStatusCode() == status || NOT_MODIFIED.getStatusCode() == status)) { throw new DockerException(getDockerExceptionMessage(response), status); } } }
Source:
public void onCheckoutClicked() { String name = selectedBranch.getDisplayName(); if (name == null) { return; } final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class); if (selectedBranch.isRemote()) { checkoutRequest.setTrackBranch(selectedBranch.getDisplayName()); } else { checkoutRequest.setName(selectedBranch.getDisplayName()); } final String path = project.getRootProject().getPath(); service.checkout(workspaceId, project.getRootProject(), checkoutRequest, new AsyncRequestCallback<String>() { @Override protected void onSuccess(String result) { getBranches(); projectExplorer.reloadChildren(); updateOpenedFiles(); projectService.getProject (appContext.getWorkspace().getId(), path, new AsyncRequestCallback<ProjectConfigDto>( dtoUnmarshallerFactory.newUnmarshaller(ProjectConfigDto.class)) { @Override protected void onSuccess(ProjectConfigDto result) { eventBus.fireEvent(new ProjectUpdatedEvent(path, result)); } @Override protected void onFailure(Throwable exception) { notificationManager .notify(exception.getLocalizedMessage(), FAIL, true, project.getProjectConfig()); } }); } @Override protected void onFailure(Throwable exception) { printGitMessage(exception.getMessage()); } }); }

Target:
public void onCheckoutClicked() { String name = selectedBranch.getDisplayName(); if (name == null) { return; } final CheckoutRequest checkoutRequest = dtoFactory.createDto(CheckoutRequest.class); if (selectedBranch.isRemote()) { checkoutRequest.setTrackBranch(selectedBranch.getDisplayName()); } else { checkoutRequest.setName(selectedBranch.getDisplayName()); } final String path = project.getRootProject().getPath(); service.checkout(workspaceId, project.getRootProject(), checkoutRequest, new AsyncRequestCallback<String>() { @Override protected void onSuccess(String result) { getBranches(); projectExplorer.reloadChildren(); updateOpenedFiles(); projectService.getProject (workspaceId, path, new AsyncRequestCallback<ProjectConfigDto>( dtoUnmarshallerFactory.newUnmarshaller(ProjectConfigDto.class)) { @Override protected void onSuccess(ProjectConfigDto result) { eventBus.fireEvent(new ProjectUpdatedEvent(path, result)); } @Override protected void onFailure(Throwable exception) { notificationManager .notify(exception.getLocalizedMessage(), FAIL, true, project.getProjectConfig()); } }); } @Override protected void onFailure(Throwable exception) { printGitMessage(exception.getMessage()); } }); }
Source:
void validateStringToSearch() throws IllegalArgumentException { if (stringToSearch == null) { throw new IllegalArgumentException("String to search must be non-null."); } else if (!stringToSearch.chars().allMatch(Character::isDigit)) { throw new IllegalArgumentException("String to search may only contain digits."); } }

Target:
private void validateStringToSearch() throws IllegalArgumentException { if (stringToSearch == null) { throw new IllegalArgumentException("String to search must be non-null."); } else if (!stringToSearch.chars().allMatch(Character::isDigit)) { throw new IllegalArgumentException("String to search may only contain digits."); } }
Source:
public DataTransactionResult removeFrom(ValueContainer<?> container) { if (container instanceof EntityPlayer) { final DataTransactionBuilder builder = DataTransactionBuilder.builder(); builder.replace(getApiValueFromContainer(container).get().asImmutable()); builder.replace(container.getValue(Keys.CAN_FLY).get().asImmutable()); ((EntityPlayer) container).capabilities.allowFlying = false; ((EntityPlayer) (container)).sendPlayerAbilities(); return builder.result(DataTransactionResult.Type.SUCCESS).build(); } return DataTransactionBuilder.failNoData(); }

Target:
public DataTransactionResult removeFrom(ValueContainer<?> container) { return DataTransactionBuilder.failNoData(); }
Source:
public void testSetBrightness() { mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT, Settings.System.SCREEN_BRIGHTNESS_MODE, "0"); testSetBrightnessWithValue(TEST_BRIGHTNESS_1); testSetBrightnessWithValue(TEST_BRIGHTNESS_2); }

Target:
public void testSetBrightness() { final int mode = Settings.System.getInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC); if(mode==1) { mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT, Settings.System.SCREEN_BRIGHTNESS_MODE, "0"); testSetBrightnessWithValue(TEST_BRIGHTNESS_1); testSetBrightnessWithValue(TEST_BRIGHTNESS_2); mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT, Settings.System.SCREEN_BRIGHTNESS_MODE, "1"); } else { testSetBrightnessWithValue(TEST_BRIGHTNESS_1); testSetBrightnessWithValue(TEST_BRIGHTNESS_2); } }
Source:
private static StoragePool createNewStoragePool() { StoragePool pool = createBasicPool(); pool.setcompatibility_version(VERSION_1_1); return pool; }

Target:
private static StoragePool createNewStoragePool() { StoragePool pool = createBasicPool(); pool.setIsLocal(false); pool.setcompatibility_version(VERSION_1_1); return pool; }
Source:
private void toggleCheckboxAndWriteBackDefaultValue(Address address, String attributeName) throws Exception { final ModelNodeResult value = operations.readAttribute(address, attributeName); value.assertSuccess(); final boolean booleanValue = value.booleanValue(); try { new ConfigChecker.Builder(client, address) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.CHECKBOX, attributeName, !booleanValue) .verifyFormSaved() .verifyAttribute(attributeName, !booleanValue); new ConfigChecker.Builder(client, address) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.CHECKBOX, attributeName, booleanValue) .verifyFormSaved() .verifyAttribute(attributeName, booleanValue); } finally { operations.writeAttribute(address, attributeName, value.value()); } }

Target:
private void toggleCheckboxAndWriteBackDefaultValue(Address address, String attributeName) throws Exception { final ModelNodeResult originalValueResult = operations.readAttribute(address, attributeName); originalValueResult.assertSuccess(); final boolean originalBooleanValue = originalValueResult.booleanValue(); try { new ConfigChecker.Builder(client, address) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.CHECKBOX, attributeName, !originalBooleanValue) .verifyFormSaved() .verifyAttribute(attributeName, !originalBooleanValue); new ConfigChecker.Builder(client, address) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.CHECKBOX, attributeName, originalBooleanValue) .verifyFormSaved() .verifyAttribute(attributeName, originalBooleanValue); } finally { operations.writeAttribute(address, attributeName, originalValueResult.value()); } }
Source:
static Arbitrary<LocalDateTime> localDateTime(LocalDateTime median, ChronoUnit unit) { return size -> random -> Gen.choose(median.minus(size, unit), median.plus(size, unit)).apply(random); }

Target:
static Arbitrary<LocalDateTime> localDateTime(LocalDateTime median, ChronoUnit unit) { Objects.requireNonNull(median, "median is null"); Objects.requireNonNull(unit, "unit is null"); return size -> { if(size == 0) { return Gen.of(median); } final LocalDateTime start = median.minus(size, unit); final LocalDateTime end = median.plus(size, unit); final long duration = Duration.between(start, end).toMillis(); final Gen<Long> from = Gen.choose(0, duration); return random -> start.plus(from.apply(random), ChronoUnit.MILLIS); }; }
Source:
public void deleteFromSubject(String tenant, String subject) { LOGGER.debug("Deleting all the content from tenant [" + tenant + "]" + " and subject [" + subject + "]"); String hql = "DELETE FROM Policy " + "WHERE subject = :subject_id"; Query query = this.currentSession().createQuery(hql); query.setParameter("subject_id", subject); int result = query.executeUpdate(); }

Target:
public void deleteFromSubject(String tenant, String subject) { LOGGER.debug("Deleting all the content from tenant [{}]" + " and subject [{}]", tenant, subject); String hql = "DELETE FROM Policy " + "WHERE subject = :subject_id"; Query query = this.currentSession().createQuery(hql); query.setParameter("subject_id", subject); int result = query.executeUpdate(); }
Source:
public void PlayingVideoTests_001_ooyala() { VideoComponentObject video; String providerName = "ooyala"; String articleName = "VideoOoyala"; ArticlePageObject article = base.openArticleByName(wikiURL, articleName); article.verifyVideo(); Integer videoWidth = article.getVideoWidth(); if ( videoWidth > 400 ) { video = article.clickThumbnailVideoInline(); article.verifyVideoAutoplay(providerName); } else { LightboxComponentObject lightbox = article.clickThumbnailVideo(); lightbox.verifyLightboxVideo(); lightbox.verifyVideoAutoplay(providerName); video = lightbox.getVideoPlayer(); videoWidth = videoWidthLightbox; } video.verifyVideoEmbedWidth(videoWidth); video.verifyVideoOoyalaAgeGate(); video.verifyVideoObjectVisible(); video.verifyVideoOoyalaEmbed(); }

Target:
public void PlayingVideoTests_001_ooyala() { String providerName = "ooyala"; String articleName = "VideoOoyala"; ArticlePageObject article = base.openArticleByName(wikiURL, articleName); article.verifyVideo(); VideoComponentObject video = article.clickThumbnailVideo(providerName); video.verifyVideoEmbedWidth(); video.verifyVideoOoyalaAgeGate(); video.verifyVideoObjectVisible(); video.verifyVideoOoyalaEmbed(); }
Source:
private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) { return false; } int as = a.lines.get(ai); int bs = b.lines.get(bi); final int ae = a.lines.get(ai + 1); final int be = b.lines.get(bi + 1); while (as < ae && bs < be) { while (as < ae - 1 && RawCharUtil.isWhitespace(a.content[as])) { as++; } while (bs < be - 1 && RawCharUtil.isWhitespace(b.content[bs])) { bs++; } if (a.content[as] != b.content[bs]) { return false; } as++; bs++; } while (as < ae) { if (!RawCharUtil.isWhitespace(a.content[as++])) { return false; } } while (bs < be) { if (!RawCharUtil.isWhitespace(b.content[bs++])) { return false; } } return true; }

Target:
private static boolean equals(final RawText a, final int ai, final RawText b, final int bi) { if (a.hashes.get(ai) != b.hashes.get(bi)) return false; int as = a.lines.get(ai); int bs = b.lines.get(bi); int ae = a.lines.get(ai + 1); int be = b.lines.get(bi + 1); as = trimLeadingWhitespace(a.content, as, ae); bs = trimLeadingWhitespace(b.content, bs, be); ae = trimTrailingWhitespace(a.content, as, ae); be = trimTrailingWhitespace(b.content, bs, be); while (as < ae && bs < be) { byte ac = a.content[as]; byte bc = b.content[bs]; while (as < ae - 1 && isWhitespace(ac)) { as++; ac = a.content[as]; } while (bs < be - 1 && isWhitespace(bc)) { bs++; bc = b.content[bs]; } if (ac != bc) return false; as++; bs++; } return true; }
Source:
public Color getForeground(Object element, int columnIndex) { String legendItemText = (String) element; if (legendItemText.equals("Population > 1,000,000") | legendItemText.equals("Population > 50,000")) { return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); } return null; }

Target:
public Color getForeground(Object element, int columnIndex) { String legendItemText = (String) element; if (legendItemText.equals("Population > 1,000,000") || legendItemText.equals("Population > 50,000")) { return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); } return null; }
Source:
protected abstract boolean doRemoveInternal(final K key) throws StoreAccessException; @Override public void clear() { clearObserver.begin(); statusTransitioner.checkAvailable(); try { store.clear(); clearObserver.end(ClearOutcome.SUCCESS); } catch (StoreAccessException e) { clearObserver.end(ClearOutcome.FAILURE); resilienceStrategy.clearFailure(e); } }

Target:
protected abstract boolean doRemoveInternal(final K key) throws StoreAccessException; @Override public void clear() { clearObserver.begin(); try { statusTransitioner.checkAvailable(); try { store.clear(); clearObserver.end(ClearOutcome.SUCCESS); } catch (StoreAccessException e) { resilienceStrategy.clearFailure(e); clearObserver.end(ClearOutcome.FAILURE); } } catch (Throwable e) { clearObserver.end(ClearOutcome.FAILURE); throw e; } }
Source:
static boolean deleteRealm(final RealmConfiguration configuration) { final String management = ".management"; final AtomicBoolean realmDeleted = new AtomicBoolean(true); RealmCache.invokeWithGlobalRefCount(configuration, new RealmCache.Callback() { @Override public void onResult(int count) { if (count != 0) { throw new IllegalStateException("It's not allowed to delete the file associated with an open Realm. " + "Remember to close() all the instances of the Realm before deleting its file: " + configuration.getPath()); } String canonicalPath = configuration.getPath(); File realmFolder = configuration.getRealmFolder(); String realmFileName = configuration.getRealmFileName(); List<File> filesToDelete = Arrays.asList(new File(canonicalPath), new File(realmFolder, realmFileName + ".lock"), new File(realmFolder, realmFileName + ".log_a"), new File(realmFolder, realmFileName + ".log_b"), new File(realmFolder, realmFileName + ".log")); for (File fileToDelete : filesToDelete) { if (fileToDelete.exists()) { boolean deleteResult = fileToDelete.delete(); if (!deleteResult) { realmDeleted.set(false); RealmLog.w("Could not delete the file " + fileToDelete); } } } File managementFolder = new File(realmFolder, realmFileName + management); if (managementFolder.exists()) { filesToDelete = Arrays.asList( new File(managementFolder, realmFileName + ".lock"), new File(managementFolder, realmFileName + ".log_a"), new File(managementFolder, realmFileName + ".log_b"), new File(managementFolder, realmFileName + ".log")); for (File fileToDelete : filesToDelete) { if (fileToDelete.exists()) { boolean deleteResult = fileToDelete.delete(); if (!deleteResult) { realmDeleted.set(false); RealmLog.w("Could not delete the file " + fileToDelete); } } } boolean deleteResult = managementFolder.delete(); if (!deleteResult) { realmDeleted.set(false); RealmLog.w("Could not delete the folder " + managementFolder); } } } }); return realmDeleted.get(); }

Target:
static boolean deleteRealm(final RealmConfiguration configuration) { final String management = ".management"; final AtomicBoolean realmDeleted = new AtomicBoolean(true); RealmCache.invokeWithGlobalRefCount(configuration, new RealmCache.Callback() { @Override public void onResult(int count) { if (count != 0) { throw new IllegalStateException("It's not allowed to delete the file associated with an open Realm. " + "Remember to close() all the instances of the Realm before deleting its file: " + configuration.getPath()); } String canonicalPath = configuration.getPath(); File realmFolder = configuration.getRealmFolder(); String realmFileName = configuration.getRealmFileName(); File managementFolder = new File(realmFolder, realmFileName + management); realmDeleted.set(deletes(realmFolder.getPath()+ "/" + realmFileName + management, managementFolder, realmFileName)); realmDeleted.set(realmDeleted.get() && deletes(canonicalPath, realmFolder, realmFileName)); } }); return realmDeleted.get(); }
Source:
public String[] getLocations() throws IOException, InterruptedException { if (locations == null) { Map<String, Integer> hosts = new HashMap<String, Integer>(); for (InputSplit s : splits) { String[] hints = s.getLocations(); if (hints != null) { for (String host : hints) { Integer value = hosts.get(host); if (value == null) { value = 0; } value++; hosts.put(host, value); } } } if (hosts.size() < 5) { locations = hosts.keySet().toArray(new String[hosts.size()]); } else { Queue<Pair<String, Integer>> queue = new PriorityQueue<Pair<String, Integer>>(hosts.size(), new Comparator<Pair<String, Integer>>() { public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return -o1.getSecond().compareTo(o2.getSecond()); } }); for (Map.Entry<String, Integer> entry : hosts.entrySet()) { queue.add(new Pair<String, Integer>(entry.getKey(), entry.getValue())); } locations = new String[] { queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst() }; } } return locations == null ? new String[] : locations.length > 5 ? Arrays.copyOf(locations, 5) : locations; }

Target:
public String[] getLocations() throws IOException, InterruptedException { if (locations == null) { Map<String, Integer> hosts = new HashMap<String, Integer>(); for (InputSplit s : splits) { String[] hints = s.getLocations(); if (hints != null) { for (String host : hints) { Integer value = hosts.get(host); if (value == null) { value = 0; } value++; hosts.put(host, value); } } } if (hosts.size() < 5) { locations = hosts.keySet().toArray(new String[hosts.size()]); } else { Queue<Pair<String, Integer>> queue = new PriorityQueue<Pair<String, Integer>>(hosts.size(), new Comparator<Pair<String, Integer>>() { public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return -o1.getSecond().compareTo(o2.getSecond()); } }); for (Map.Entry<String, Integer> entry : hosts.entrySet()) { queue.add(new Pair<String, Integer>(entry.getKey(), entry.getValue())); } locations = new String[] { queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst(), queue.remove().getFirst() }; } } return locations; }
Source:
public Transaction newTransaction() throws TransactionException { if (!connected) { throw new TransactionException("Not connected - cannot create transaction."); } Transaction transaction = new Transaction(metaStoreClient, lockOptions); long txnId = transaction.getTransactionId(); for (AcidTable table : tables) { try { table.setWriteId(metaStoreClient.allocateTableWriteId(txnId, table.getDatabaseName(), table.getTableName())); } catch (TException ex) { try { metaStoreClient.rollbackTxn(txnId); } catch (TException e) { LOG.warn("Operation failed and rollback transaction failed due to {}", txnId, e.getMessage()); } throw new TransactionException("Unable to allocate table write ID", ex); } } LOG.debug("Created transaction {}", transaction); return transaction; }

Target:
public Transaction newTransaction() throws TransactionException { if (!connected) { throw new TransactionException("Not connected - cannot create transaction."); } Transaction transaction = new Transaction(metaStoreClient, lockOptions); long txnId = transaction.getTransactionId(); for (AcidTable table : tables) { try { table.setWriteId(metaStoreClient.allocateTableWriteId(txnId, table.getDatabaseName(), table.getTableName())); } catch (TException ex) { try { metaStoreClient.rollbackTxn(txnId); } catch (TException e) { LOG.warn("Allocation of write id failed for table and rollback transaction failed due to {}", AcidUtils.getFullTableName(table.getDatabaseName(), table.getTableName()), txnId, e.getMessage()); } throw new TransactionException("Unable to allocate table write ID for table " + AcidUtils.getFullTableName(table.getDatabaseName(), table.getTableName()) + " under txn " + txnId, ex); } } LOG.debug("Created transaction {}", transaction); return transaction; }
Source:
private void release() { if (refcount.decrementAndGet() == 0) { ownerThread.set(null); } }

Target:
private void release() { if (refcount.decrementAndGet() == 0) { ownerThread.set(NO_CURRENT_THREAD); } }
Source:
public void run() { try { String message = String.format("Starting repair command #%d (%s), repairing keyspace %s with %s", cmd, parentSession, keyspace, options); logger.info(message); Tracing.traceRepair(message); fireProgressEvent(new ProgressEvent(ProgressEventType.START, 0, 100, message)); Pair<Context, String> setup = setup(); if (setup.right != null) { skip(setup.right); return; } Context ctx = setup.left; assert ctx != null : "Context is required but was not found"; this.context = ctx; start(ctx); } catch (Exception | Error e) { notifyError(e); fail(e.getMessage()); } }

Target:
public void run() { try { runMayThrow(); } catch (SkipRepairException e) { skip(e.getMessage()); } catch (Exception | Error e) { notifyError(e); fail(e.getMessage()); } }
Source:
public QueryResult countStudiesPerSpecies(QueryOptions queryOptions) { long start = System.currentTimeMillis(); Specification filterSpecification = getSpeciesAndTypeFilters(queryOptions); List<Tuple> countGroupBy = dgvaStudyBrowserRepository.groupCount(DgvaStudyBrowserRepository.COMMON_NAME, filterSpecification, false); Map<String, Long> result = new HashMap<>(); for (Tuple tuple : countGroupBy) { String[] species = tuple.get(0) != null ? ((String) tuple.get(0)).split(",") : new String[]{ "Others" }; long count = (long) tuple.get(1); for (String s : species) { if (result.containsKey(s)) { count += result.get(s); } result.put(s, count); } } long end = System.currentTimeMillis(); return new QueryResult(null, ((Long) (end - start)).intValue(), result.size(), result.size(), null, null, new LinkedList(result.entrySet())); }

Target:
public QueryResult countStudiesPerSpecies(QueryOptions queryOptions) { long start = System.currentTimeMillis(); Specification filterSpecification = getSpeciesAndTypeFilters(queryOptions); List<Tuple> countGroupBy = dgvaStudyBrowserRepository.groupCount(DgvaStudyBrowserRepository.COMMON_NAME, filterSpecification, false); Map<String, Long> result = new HashMap<>(); for (Tuple tuple : countGroupBy) { String[] species = tuple.get(0) != null ? ((String) tuple.get(0)).split(",") : new String[]{ "Others" }; for (String s : species) { long count = (long) tuple.get(1); if (result.containsKey(s)) { count += result.get(s); } result.put(s, count); } } long end = System.currentTimeMillis(); return new QueryResult(null, ((Long) (end - start)).intValue(), result.size(), result.size(), null, null, new LinkedList(result.entrySet())); }
Source:
public void runPinger() { if (pingInProgress.get()) { return; } else { pingInProgress.set(true); } Server[] allServers = null; boolean[] results = null; Lock allLock = null; Lock upLock = null; try { allLock = allServerLock.readLock(); allLock.lock(); allServers = allServerList.toArray(new Server[allServerList.size()]); allLock.unlock(); int numCandidates = allServers.length; results = pingerStrategy.pingServers(ping, allServers); final List<Server> newUpList = new ArrayList<Server>(); final List<Server> changedServers = new ArrayList<Server>(); for (int i = 0; i < numCandidates; i++) { boolean isAlive = results[i]; Server svr = allServers[i]; boolean oldIsAlive = svr.isAlive(); svr.setAlive(isAlive); if (oldIsAlive != isAlive) { changedServers.add(svr); logger.debug("LoadBalancer [{}]: Server status changed to {}", name, svr.getId(), (isAlive ? "ALIVE" : "DEAD")); } if (isAlive) { newUpList.add(svr); } } upLock = upServerLock.writeLock(); upLock.lock(); upServerList = newUpList; upLock.unlock(); notifyServerStatusChangeListener(changedServers); } catch (Exception e) { logger.error("LoadBalancer : Error running the Pinger", name, e); } finally { pingInProgress.set(false); } }

Target:
public void runPinger() throws Exception { if (!pingInProgress.compareAndSet(false, true)) { return; } Server[] allServers = null; boolean[] results = null; Lock allLock = null; Lock upLock = null; try { allLock = allServerLock.readLock(); allLock.lock(); allServers = allServerList.toArray(new Server[allServerList.size()]); allLock.unlock(); int numCandidates = allServers.length; results = pingerStrategy.pingServers(ping, allServers); final List<Server> newUpList = new ArrayList<Server>(); final List<Server> changedServers = new ArrayList<Server>(); for (int i = 0; i < numCandidates; i++) { boolean isAlive = results[i]; Server svr = allServers[i]; boolean oldIsAlive = svr.isAlive(); svr.setAlive(isAlive); if (oldIsAlive != isAlive) { changedServers.add(svr); logger.debug("LoadBalancer [{}]: Server status changed to {}", name, svr.getId(), (isAlive ? "ALIVE" : "DEAD")); } if (isAlive) { newUpList.add(svr); } } upLock = upServerLock.writeLock(); upLock.lock(); upServerList = newUpList; upLock.unlock(); notifyServerStatusChangeListener(changedServers); } finally { pingInProgress.set(false); } }
Source:
private static Stream<IdentifierTree> findClassInDefaultPackage(ExpressionTree expression) { if (expression.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree memberSelect = (MemberSelectExpressionTree) expression; if ("class".equals(memberSelect.identifier().name()) && memberSelect.expression().is(Tree.Kind.IDENTIFIER)) { IdentifierTree identifier = (IdentifierTree) memberSelect.expression(); if (isTypeInDefaultPackage(identifier.symbol())) { return Stream.of(identifier); } } } return Stream.empty(); }

Target:
private static Optional<IdentifierTree> findClassInDefaultPackage(ExpressionTree expression) { if (expression.is(Tree.Kind.MEMBER_SELECT)) { MemberSelectExpressionTree memberSelect = (MemberSelectExpressionTree) expression; if ("class".equals(memberSelect.identifier().name()) && memberSelect.expression().is(Tree.Kind.IDENTIFIER)) { IdentifierTree identifier = (IdentifierTree) memberSelect.expression(); if (isTypeInDefaultPackage(identifier.symbol())) { return Optional.of(identifier); } } } return Optional.empty(); }
Source:
public Boolean FNCallback(FeatureNode srcNode) { FeatureNode attr = srcNode.get("DISJUNCT"); if (attr == null) return false; if (!attr.isValued()) return false; String value = attr.getValue(); if (value.length() == 0) return false; String[] connectors = value.split(" "); str += "(LgWordCset \n"; str += " (WordInstanceNode \"" + srcNode.get("uuid").getValue() + "\")\n"; str += " (LgAnd \n"; for (String conn : connectors) { String name; String direction; Boolean multi; if (conn.charAt(0) == '@') { name = conn.substring(1, conn.length() - 1); direction = conn.substring(conn.length() - 1); multi = true; } else { name = conn.substring(0, conn.length() - 1); direction = conn.substring(conn.length() - 1); multi = false; } str += " (LgConnector \n"; str += " (LgConnectorNode \"" + name + "\")\n"; str += " (LgConnDirNode \"" + direction + "\")\n"; if (multi) str += " (LgConnMultiNode \"@\")\n"; str += " )\n"; } str += " )\n"; str += ")\n"; return false; }

Target:
public Boolean FNCallback(FeatureNode srcNode) { FeatureNode attr = srcNode.get("DISJUNCT"); if (attr == null || !attr.isValued()) return false; String value = attr.getValue(); if (value.length() == 0) return false; String[] connectors = value.split(" "); str += "(LgWordCset \n"; str += " (WordInstanceNode \"" + srcNode.get("uuid").getValue() + "\")\n"; str += " (LgAnd \n"; for (String conn : connectors) { String name; String direction; Boolean multi; if (conn.charAt(0) == '@') { name = conn.substring(1, conn.length() - 1); direction = conn.substring(conn.length() - 1); multi = true; } else { name = conn.substring(0, conn.length() - 1); direction = conn.substring(conn.length() - 1); multi = false; } str += " (LgConnector \n"; str += " (LgConnectorNode \"" + name + "\")\n"; str += " (LgConnDirNode \"" + direction + "\")\n"; if (multi) str += " (LgConnMultiNode \"@\")\n"; str += " )\n"; } str += " )\n"; str += ")\n"; return false; }
Source:
public XmlTextAnnotation createTextAnnotation(String xmlText, String corpusId, String docId) { Pair<StringTransformation, List<XmlDocumentProcessor.SpanInfo>> cleanResults = xmlProcessor.processXml(xmlText); TextAnnotation ta = taBuilder.createTextAnnotation(corpusId, docId, cleanResults.getFirst().getTransformedText()); return new XmlTextAnnotation(cleanResults.getFirst(), ta, cleanResults.getSecond()); }

Target:
public XmlTextAnnotation createTextAnnotation(String xmlText, String corpusId, String docId) { logger.debug("processing text from document {}", docId); Pair<StringTransformation, List<XmlDocumentProcessor.SpanInfo>> cleanResults = xmlProcessor.processXml(xmlText); TextAnnotation ta = taBuilder.createTextAnnotation(corpusId, docId, cleanResults.getFirst().getTransformedText()); return new XmlTextAnnotation(cleanResults.getFirst(), ta, cleanResults.getSecond()); }
Source:
public ChapterFragmentPagerAdapter(Context ctx, FragmentManager fm, @NonNull Chapter selectedChapter) { super(fm); mContext = ctx; this.mSelectedChapter = selectedChapter; }

Target:
public ChapterFragmentPagerAdapter(Context ctx, FragmentManager fm, @NonNull Chapter selectedChapter) { super(fm); mContext = ctx; mSelectedChapter = selectedChapter; }
Source:
public Solution_ read(File inputSolutionFile) { try(InputStream inputSolutionStream = Files.newInputStream(inputSolutionFile.toPath())) { return read(inputSolutionStream); } catch (IOException e) { throw new IllegalArgumentException("Failed reading inputSolutionFile (" + inputSolutionFile + ").", e); } }

Target:
public Solution_ read(File inputSolutionFile) { try (InputStream inputSolutionStream = Files.newInputStream(inputSolutionFile.toPath())) { return read(inputSolutionStream); } catch (Exception e) { throw new IllegalArgumentException("Failed reading inputSolutionFile (" + inputSolutionFile + ").", e); } }
Source:
protected void checkProducerMethod(EnhancedAnnotatedMethod<T, ? super X> method) { if (method.getEnhancedParameters(Observes.class).size() > 0) { throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Observes", this.method); } else if (method.getEnhancedParameters(Disposes.class).size() > 0) { throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Disposes", this.method); } else if (getDeclaringBean() instanceof SessionBean<?>) { boolean methodDeclaredOnTypes = false; for (Type type : getDeclaringBean().getTypes()) { Class<?> clazz = Reflections.getRawType(type); methodDeclaredOnTypes = doPrivileged(clazz, method.getName(), method.getParameterTypesAsArray()); if (methodDeclaredOnTypes) { break; } } if (!methodDeclaredOnTypes && Modifier.isStatic(method.slim().getJavaMember().getModifiers())) { methodDeclaredOnTypes = doPrivileged(getDeclaringBean().getBeanClass(), method.getName(), method.getParameterTypesAsArray()); } if (!methodDeclaredOnTypes) { throw BeanLogger.LOG.methodNotBusinessMethod(this, getDeclaringBean()); } } }

Target:
protected void checkProducerMethod(EnhancedAnnotatedMethod<T, ? super X> method) { if (method.getEnhancedParameters(Observes.class).size() > 0) { throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Observes", this.method); } else if (method.getEnhancedParameters(Disposes.class).size() > 0) { throw BeanLogger.LOG.inconsistentAnnotationsOnMethod(PRODUCER_ANNOTATION, "@Disposes", this.method); } else if (getDeclaringBean() instanceof SessionBean<?> && !Modifier.isStatic(method.slim().getJavaMember().getModifiers())) { boolean methodDeclaredOnTypes = false; for (Type type : getDeclaringBean().getTypes()) { Class<?> clazz = Reflections.getRawType(type); try { AccessController.doPrivileged(new GetMethodAction(clazz, method.getName(), method.getParameterTypesAsArray())); methodDeclaredOnTypes = true; break; } catch (PrivilegedActionException ignored) { } } if (!methodDeclaredOnTypes) { throw BeanLogger.LOG.methodNotBusinessMethod(this, getDeclaringBean()); } } }
Source:
public void test() { connect(); click(jq("@button")); waitResponse(); JQuery grid = jq("@grid"); int width = grid.width(); click(grid); JQuery body = grid.find(".z-grid-body"); body.scrollTop(body.scrollHeight()); waitResponse(); Assert.assertTrue(width < grid.width()); }

Target:
public void test() { connect(); click(jq("@button")); waitResponse(); JQuery grid = jq("@grid"); int width = grid.width(); click(grid); JQuery body = grid.find(".z-grid-body"); body.scrollTop(body.scrollHeight()); waitResponse(); Assert.assertThat(grid.width(), greaterThan(width)); }
Source:
public InsightCard(final Long accountId, final String title, final String message, final Category category, final TimePeriod timePeriod, final DateTime timestamp) { this.accountId = Optional.fromNullable(accountId); this.title = title; this.message = message; this.category = category; this.timePeriod = timePeriod; this.timestamp = timestamp; this.genericInsightCards = Collections.emptyList(); }

Target:
public InsightCard(final Long accountId, final String title, final String message, final Category category, final TimePeriod timePeriod, final DateTime timestamp) { this.accountId = Optional.fromNullable(accountId); this.title = title; this.message = message; this.category = category; this.timePeriod = timePeriod; this.timestamp = timestamp; }
Source:
public void setRootNode(String rootNode) { this.rootNode = rootNode; }

Target:
public void setRootNode(String rootNode) { fRootNode = rootNode; }
Source:
public String getSelectedRepositoryId() { Optional<PickerRepository> selectedRepository = matchingRepositories.stream() .filter(repo -> repo.isSelected()) .findFirst(); assert selectedRepository.isPresent(); return selectedRepository.get().getRepositoryId(); }

Target:
public String getSelectedRepositoryId() { Optional<PickerRepository> selectedRepository = suggestedRepositories.stream() .filter(repo -> repo.isSelected()) .findFirst(); assert selectedRepository.isPresent(); return selectedRepository.get().getRepositoryId(); }
Source:
public void flagAsEvicted() { if (_expireAfterDate == null) { _expireAfterDate = System.currentTimeMillis() + (_evictionDelayInSeconds * 1000); } }

Target:
public void flagAsEvicted() { if (_expireAfterDate == Long.MAX_VALUE) { _expireAfterDate = System.currentTimeMillis() + _evictionDelayInMilliSeconds; } }
Source:
public void close() { ExecutorService maybeNull = maybeNull(); if (maybeNull != null) { maybeNull.shutdownNow(); try { maybeNull.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { } } }

Target:
public void close() { ExecutorService maybeNull = maybeNull(); if (maybeNull != null) { maybeNull.shutdownNow(); try { maybeNull.awaitTermination(1, TimeUnit.SECONDS); } catch (InterruptedException e) { } } }
Source:
private URL buildUrlWithParams() throws MalformedURLException { Uri.Builder b = Uri.parse(url).buildUpon(); for (Map.Entry<String, String> param : params.entrySet()) { b.appendQueryParameter(param.getKey(), param.getValue()); } return new URL(b.build().toString()); }

Target:
private String buildUrlWithParams() throws MalformedURLException { Uri.Builder b = Uri.parse(url).buildUpon(); for (Map.Entry<String, String> param : params.entrySet()) { b.appendQueryParameter(param.getKey(), param.getValue()); } return b.build().toString(); }
Source:
public CSVTupleDataLoader(ClientImpl client, String procName, BulkLoaderErrorHandler errHandler, ExecutorService callbackExecutor, BulkLoaderSuccessCallback successCallback) throws IOException, ProcCallException { m_client = client; m_insertProcedure = procName; m_errHandler = errHandler; m_callbackExecutor = callbackExecutor; m_successCallback = successCallback; m_reinsertExecutor = CoreUtils.getSingleThreadExecutor(procName); m_autoReconnect = client.isAutoReconnectEnabled(); List<VoltType> typeList = Lists.newArrayList(); VoltTable procInfo = client.callProcedure("@SystemCatalog", "PROCEDURECOLUMNS").getResults()[0]; while (procInfo.advanceRow()) { if (m_insertProcedure.equalsIgnoreCase(procInfo.getString("PROCEDURE_NAME"))) { String typeStr = (String) procInfo.get("TYPE_NAME", VoltType.STRING); typeList.add(VoltType.typeFromString(typeStr)); } } if (typeList.isEmpty()) { throw new RuntimeException("No matching insert procedure available"); } m_columnTypes = typeList.toArray(new VoltType[0]); int sleptTimes = 0; while (!client.isHashinatorInitialized() && sleptTimes < 120) { try { Thread.sleep(500); sleptTimes++; } catch (InterruptedException ex) } }

Target:
public CSVTupleDataLoader(ClientImpl client, String procName, BulkLoaderErrorHandler errHandler, ExecutorService callbackExecutor, BulkLoaderSuccessCallback successCallback) throws IOException, ProcCallException { m_client = client; m_insertProcedure = procName; m_errHandler = errHandler; m_callbackExecutor = callbackExecutor; m_successCallback = successCallback; m_autoReconnect = client.isAutoReconnectEnabled(); if (m_autoReconnect) { m_reinsertExecutor = CoreUtils.getSingleThreadExecutor(procName); } else { m_reinsertExecutor = null; } List<VoltType> typeList = Lists.newArrayList(); VoltTable procInfo = client.callProcedure("@SystemCatalog", "PROCEDURECOLUMNS").getResults()[0]; while (procInfo.advanceRow()) { if (m_insertProcedure.equalsIgnoreCase(procInfo.getString("PROCEDURE_NAME"))) { String typeStr = (String) procInfo.get("TYPE_NAME", VoltType.STRING); typeList.add(VoltType.typeFromString(typeStr)); } } if (typeList.isEmpty()) { throw new RuntimeException("No matching insert procedure available"); } m_columnTypes = typeList.toArray(new VoltType[0]); int sleptTimes = 0; while (!client.isHashinatorInitialized() && sleptTimes < 120) { try { Thread.sleep(500); sleptTimes++; } catch (InterruptedException ex) } }
Source:
BitMappedTrie(Object[] array, int offset, int length, int depthShift) { this.array = array; this.offset = offset; this.length = length; this.depthShift = depthShift; assert length() <= treeSize(branchingFactor(), depthShift); }

Target:
BitMappedTrie(Object[] array, int offset, int length, int depthShift) { this.array = array; this.offset = offset; this.length = length; this.depthShift = depthShift; assert length <= treeSize(branchingFactor(), depthShift); assert (EMPTY == null) || ((length > 0) && (array.length > 0)); }
Source:
public boolean performNextOperation(int completedChildCount) { log.info("Command '{}' id '{}' executing step '{}'", getActionType(), getCommandId(), getParameters().getNextCommandStep()); switch (getParameters().getNextCommandStep()) { case UPDATE_OVF_STORE: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.UPDATE_OVF_STORE); runInternalAction(ActionType.UpdateOvfStoreForStorageDomain, createUpdateOvfStoreParams(), cloneContext().withoutCompensationContext()); getParameters().setNextCommandStep( DeactivateStorageDomainWithOvfUpdateStep.DEACTIVATE_STORAGE_DOMAIN ); break; case DEACTIVATE_STORAGE_DOMAIN: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.DEACTIVATE_STORAGE_DOMAIN); executeDeactivateCommand(); getParameters().setNextCommandStep(DeactivateStorageDomainWithOvfUpdateStep.COMPLETE); break; case COMPLETE: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.COMPLETE); setCommandStatus(CommandStatus.SUCCEEDED); return false; } return true; }

Target:
public boolean performNextOperation(int completedChildCount) { log.info("Command '{}' id '{}' executing step '{}'", getActionType(), getCommandId(), getParameters().getNextCommandStep()); switch (getParameters().getNextCommandStep()) { case UPDATE_OVF_STORE: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.UPDATE_OVF_STORE); runInternalAction(ActionType.UpdateOvfStoreForStorageDomain, createUpdateOvfStoreParams(), cloneContext().withoutCompensationContext()); getParameters().setNextCommandStep( DeactivateStorageDomainWithOvfUpdateStep.DEACTIVATE_STORAGE_DOMAIN ); break; case DEACTIVATE_STORAGE_DOMAIN: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.DEACTIVATE_STORAGE_DOMAIN); executeDeactivateCommand(); getParameters().setNextCommandStep(DeactivateStorageDomainWithOvfUpdateStep.COMPLETE); break; case COMPLETE: getParameters().setCommandStep(DeactivateStorageDomainWithOvfUpdateStep.COMPLETE); setCommandStatus(CommandStatus.SUCCEEDED); return false; } persistCommandIfNeeded(); return true; }
Source:
public void closedHigh(boolean closedHigh) { this.closedHigh = closedHigh == false; }

Target:
public void closedHigh(boolean closedHigh) { this.closedHigh = closedHigh; }
Source:
public boolean hasMatch() { return rawHasMatch(fEmptyArray); }

Target:
public boolean hasMatch() { return rawHasMatch(emptyArray()); }
Source:
public void nextIsInvoke() { m.visitInsn(Opcodes.NOP); m.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V", false); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKESTATIC, "owner", "name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "another_owner", "name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "another_name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "another_name", "()I"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V"); assertSame(m.instructions.getLast(), matcher.cursor); matcher.cursor = null; matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V"); }

Target:
public void nextIsInvoke() { m.visitInsn(Opcodes.NOP); m.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V", false); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKESTATIC, "owner", "name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "another_owner", "name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "another_name", "()V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "(Lanother_descriptor;)V"); assertNull(matcher.cursor); matcher.cursor = m.instructions.getFirst(); matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V"); assertSame(m.instructions.getLast(), matcher.cursor); matcher.cursor = null; matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V"); }