auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void prepareFilterBar() { final boolean cacheTypeFilterActive = Settings.getCacheType() != CacheType.ALL; if (cacheTypeFilterActive || adapter.isFiltered()) { final List<String> filters = new ArrayList<>(); if (cacheTypeFilterActive) { filters.add(Settings.getCacheType().getL10n()); } if (adapter.isFiltered()) { filters.add(adapter.getFilterName()); } final TextView filterTextView = ButterKnife.findById(this, R.id.filter_text); filterTextView.setText(TextUtils.join(", ", filters)); findViewById(R.id.filter_bar).setVisibility(View.VISIBLE); } else { findViewById(R.id.filter_bar).setVisibility(View.GONE); } }

Target:
private void prepareFilterBar() { final List<String> filterNames = getFilterNames(); if (filterNames.isEmpty()) { findViewById(R.id.filter_bar).setVisibility(View.GONE); } else { final TextView filterTextView = ButterKnife.findById(this, R.id.filter_text); filterTextView.setText(TextUtils.join(", ", filterNames)); findViewById(R.id.filter_bar).setVisibility(View.VISIBLE); } }
Source:
private Object evaluateCondition(Method method, ExtensionContext context) { Preconditions.condition(method.getReturnType() == boolean.class, () -> format("method [%s] should return a boolean", method.getName())); Preconditions.condition(areParametersSupported(method), () -> format("method [%s] should take either an ExtensionContext or no parameters", method.getName())); Object testInstance = context.getRequiredTestInstance(); if (method.getParameterCount() == 0) { return ReflectionUtils.invokeMethod(method, testInstance); } return ReflectionUtils.invokeMethod(method, testInstance, context); }

Target:
private Object evaluateCondition(Method method, ExtensionContext context) { Preconditions.condition(method.getReturnType() == boolean.class, () -> format("method [%s] should return a boolean", method.getName())); Preconditions.condition(areParametersSupported(method), () -> format("method [%s] should take either an ExtensionContext or no parameters", method.getName())); Object testInstance = context.getTestInstance().orElse(null); if (method.getParameterCount() == 0) { return ReflectionUtils.invokeMethod(method, testInstance); } return ReflectionUtils.invokeMethod(method, testInstance, context); }
Source:
private void loadModel() { ISecurePreferences secureAccountRoot = getSecureAccountsPreferences(); Preferences accountsRoot = getAccountsPreferences(); try { String[] ids = accountsRoot.childrenNames(); for(String id: ids) { Cluster cluster = new Cluster(this, id); Preferences clusterNode = accountsRoot.node(id); ISecurePreferences secureClusterNode = secureAccountRoot.node(id); try { cluster.load(clusterNode, secureClusterNode); clusters.add(cluster); } catch (StorageException e) { OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e); } } } catch (BackingStoreException e) { OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e); } if (clusters.isEmpty()) { addCluster(createCluster("OpenShift.io")); } }

Target:
private void loadModel() { ISecurePreferences secureAccountRoot = getSecureAccountsPreferences(); Preferences accountsRoot = getAccountsPreferences(); try { String[] ids = accountsRoot.childrenNames(); for(String id: ids) { Cluster cluster = new Cluster(this, id); Preferences clusterNode = accountsRoot.node(id); ISecurePreferences secureClusterNode = secureAccountRoot.node(id); addCluster(cluster, clusterNode, secureClusterNode); } } catch (BackingStoreException e) { OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e); } if (clusters.isEmpty()) { addCluster(createCluster("OpenShift.io")); } }
Source:
protected float getAssignmentScore(AssignableNode node, AssignableReplica replica, ClusterContext clusterContext) { if (!replica.isReplicaTopState()) { return 0; } int curTopPartitionCountForResource = node.getAssignedTopStatePartitionsCount(); int estimatedMaxTopStateCount = clusterContext.getEstimatedMaxTopStateCount(); return computeUtilizationScore(estimatedMaxTopStateCount, curTopPartitionCountForResource); }

Target:
protected double getAssignmentScore(AssignableNode node, AssignableReplica replica, ClusterContext clusterContext) { if (!replica.isReplicaTopState()) { return 0; } int curTopPartitionCountForResource = node.getAssignedTopStatePartitionsCount(); int estimatedMaxTopStateCount = clusterContext.getEstimatedMaxTopStateCount(); return computeUtilizationScore(estimatedMaxTopStateCount, curTopPartitionCountForResource); }
Source:
public HashGenerationOptimizer(FunctionManager functionManager) { this.functionManager = functionManager; }

Target:
public HashGenerationOptimizer(FunctionManager functionManager) { this.functionManager = requireNonNull(functionManager, "functionManager is null"); }
Source:
public void run() { threadPool = Executors.newCachedThreadPool(); int read = -1; int bufferSize = 0; while (!isInterrupted() || reConnectCounter == -1) { try { if(inputStream == null) { reconnect(); } else { read = inputStream.read(); lastReceiveTime = System.nanoTime(); bufferSize = inputStream.available(); if(read == -1) { logger.info("eBUS read timeout occured, no data on bus ..."); } else { byte receivedByte = (byte)(read & 0xFF); inputBuffer.put(receivedByte); if(receivedByte == EBusTelegram.SYN) { onEBusSyncReceived(bufferSize==0); } } } } catch (IOException e) { logger.error("An IO exception has occured! Try to reconnect eBus connector ...", e); try { reconnect(); } catch (IOException e1) { logger.error(e.toString(), e); } catch (InterruptedException e1) { logger.error(e.toString(), e); } } catch (BufferOverflowException e) { logger.error("eBUS telegram buffer overflow - not enough sync bytes received! Try to adjust eBus adapter."); inputBuffer.clear(); } catch (Exception e) { logger.error(e.toString(), e); inputBuffer.clear(); } } try { disconnect(); } catch (IOException e) { logger.error(e.toString(), e); } if(threadPool != null && !threadPool.isShutdown()) threadPool.shutdown(); }

Target:
public void run() { threadPool = Executors.newCachedThreadPool(); int read = -1; int bufferSize = 0; while (!isInterrupted() || reConnectCounter == -1) { try { if(inputStream == null) { reconnect(); } else { read = inputStream.read(); lastReceiveTime = System.nanoTime(); bufferSize = inputStream.available(); if(read == -1) { logger.debug("eBUS read timeout occured, no data on bus ..."); } else { byte receivedByte = (byte)(read & 0xFF); inputBuffer.put(receivedByte); if(receivedByte == EBusTelegram.SYN) { onEBusSyncReceived(bufferSize==0); } } } } catch (IOException e) { logger.error("An IO exception has occured! Try to reconnect eBus connector ...", e); try { reconnect(); } catch (IOException e1) { logger.error(e.toString(), e); } catch (InterruptedException e1) { logger.error(e.toString(), e); } } catch (BufferOverflowException e) { logger.error("eBUS telegram buffer overflow - not enough sync bytes received! Try to adjust eBus adapter."); inputBuffer.clear(); } catch (Exception e) { logger.error(e.toString(), e); inputBuffer.clear(); } } try { disconnect(); } catch (IOException e) { logger.error(e.toString(), e); } if(threadPool != null && !threadPool.isShutdown()) threadPool.shutdown(); }
Source:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor = m != null ? m : new NullProgressMonitor(); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { pm.beginTask("", 2); pm.subTask(MessageFormat.format( CoreText.RevertCommitOperation_reverting, Integer.valueOf(commits.size()))); RevertCommand command = new Git(repo).revert(); for (RevCommit commit : commits) { command.include(commit); } try { newHead = command.call(); reverted = command.getRevertedRefs(); result = command.getFailingResult(); } catch (GitAPIException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); } pm.worked(1); ProjectUtil.refreshValidProjects( ProjectUtil.getValidOpenProjects(repo), new SubProgressMonitor(pm, 1)); pm.done(); } }; ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, monitor); }

Target:
public void execute(IProgressMonitor m) throws CoreException { IProgressMonitor monitor = m != null ? m : new NullProgressMonitor(); IWorkspaceRunnable action = new IWorkspaceRunnable() { public void run(IProgressMonitor pm) throws CoreException { pm.beginTask("", 2); pm.subTask(MessageFormat.format( CoreText.RevertCommitOperation_reverting, Integer.valueOf(commits.size()))); RevertCommand command = new Git(repo).revert(); for (RevCommit commit : commits) command.include(commit); try { newHead = command.call(); reverted = command.getRevertedRefs(); result = command.getFailingResult(); } catch (GitAPIException e) { throw new TeamException(e.getLocalizedMessage(), e.getCause()); } pm.worked(1); ProjectUtil.refreshValidProjects( ProjectUtil.getValidOpenProjects(repo), new SubProgressMonitor(pm, 1)); pm.done(); } }; ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, monitor); }
Source:
public boolean validateTarget(ClassMetaData clazz) { VariableElement field = clazz.getDeclaredField(sourceField); if (field == null) { Utils.error(String.format( "Field \"%s\", the target of the @LinkedObjects annotation on field \"%s.%s\", does not exist in class \"%s\".", sourceField, targetClass, targetField, sourceClass)); return false; } String fieldType = field.asType().toString(); if (!(targetClass.equals(fieldType) || targetClass.equals(Utils.getRealmListType(field)))) { Utils.error(String.format( "Field \"%s.%s\", the target of the @LinkedObjects annotation on field \"%s.%s\", has type \"%s\" instead of \"%s\".", sourceClass, sourceField, targetClass, targetField, fieldType, targetClass)); return false; } return true; }

Target:
public boolean validateTarget(ClassMetaData clazz) { VariableElement field = clazz.getDeclaredField(sourceField); if (field == null) { Utils.error(String.format( "Field \"%s\", the target of the @LinkedObjects annotation on field \"%s.%s\", does not exist in class \"%s\".", sourceField, targetClass, targetField, sourceClass)); return false; } String fieldType = field.asType().toString(); if (!(targetClass.equals(fieldType) || targetClass.equals(Utils.getRealmListType(field)))) { Utils.error(String.format( "Field \"%s.%s\", the target of the @LinkedObjects annotation on field \"%s.%s\", has type \"%s\" instead of \"%3$s\".", sourceClass, sourceField, targetClass, targetField, fieldType)); return false; } return true; }
Source:
public ContainerVirtualGuestConfiguration(Set<ContainerVirtualGuestConfigurationOption> blockDevices, Set<ContainerVirtualGuestConfigurationOption> datacenters, Set<ContainerVirtualGuestConfigurationOption> memory, Set<ContainerVirtualGuestConfigurationOption> networkComponents, Set<ContainerVirtualGuestConfigurationOption> operatingSystems, Set<ContainerVirtualGuestConfigurationOption> processors) { this.blockDevices = blockDevices; this.datacenters = datacenters; this.memory = memory; this.networkComponents = networkComponents; this.operatingSystems = operatingSystems; this.processors = processors; }

Target:
public ContainerVirtualGuestConfiguration(Set<ContainerVirtualGuestConfigurationOption> blockDevices, Set<ContainerVirtualGuestConfigurationOption> datacenters, Set<ContainerVirtualGuestConfigurationOption> memory, Set<ContainerVirtualGuestConfigurationOption> networkComponents, Set<ContainerVirtualGuestConfigurationOption> operatingSystems, Set<ContainerVirtualGuestConfigurationOption> processors) { this.blockDevices = checkNotNull(blockDevices, "blockDevices"); this.datacenters = checkNotNull(datacenters, "datacenters"); this.memory = checkNotNull(memory, "memory"); this.networkComponents = checkNotNull(networkComponents, "networkComponents"); this.operatingSystems = checkNotNull(operatingSystems, "operatingSystems"); this.processors = checkNotNull(processors, "processors"); }
Source:
private GHRepository resolveRepository() throws ProjectConfigurationException { String repositoryURL; GithubProjectProperty githubProperty = build.getParent().getProperty(GithubProjectProperty.class); if (isNull(githubProperty) || isBlank(githubProperty.getProjectUrlStr())) { throw new ProjectConfigurationException("pullRequest: GitHub repository not configured for build project"); } repositoryURL = githubProperty.getProjectUrlStr(); GitHubRepositoryName repoName = GitHubRepositoryName.create(repositoryURL); if (isNull(repoName)) { throw new ProjectConfigurationException("Invalid URL \"" + repositoryURL + "\" provided as GitHub project"); } GHRepository resolvedRepo = repoName.resolveOne(); if (isNull(resolvedRepo)) { throw new ProjectConfigurationException("No configuration found for GitHub server at \"" + repositoryURL + "\". Check global configuration."); } return resolvedRepo; }

Target:
private GHRepository resolveRepository() throws ProjectConfigurationException { try { GitHubPRTrigger trigger = JobInfoHelpers.triggerFrom(run.getParent(), GitHubPRTrigger.class); return trigger.getRemoteRepo(); } catch (Exception e) { throw new ProjectConfigurationException("pullRequest: GitHub repository not configured for project", e); } }
Source:
protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) { HttpParameters previousParams = ac.getParameters(); HttpParameters.Builder combinedParams = HttpParameters.create(); if (overwrite) { if (previousParams != null) { combinedParams = combinedParams.withParent(previousParams); } if (newParams != null) { combinedParams = combinedParams.withExtraParams(newParams); } } else { if (newParams != null) { HttpParameters newHttpParameters = HttpParameters.create(newParams).build(); combinedParams = combinedParams.withParent(newHttpParameters); } if (previousParams != null) { combinedParams = combinedParams.withParent(previousParams); } } ac.setParameters(combinedParams.build()); }

Target:
protected void addParametersToContext(ActionContext ac, Map<String, ?> newParams) { HttpParameters previousParams = ac.getParameters(); HttpParameters.Builder combinedParams; if (overwrite) { combinedParams = HttpParameters.create().withParent( previousParams); combinedParams = combinedParams.withExtraParams(newParams); } else { combinedParams = HttpParameters.create(newParams); combinedParams = combinedParams.withExtraParams(previousParams); } ac.setParameters(combinedParams.build()); }
Source:
void addPredicateParamMissingForReference(String theResourceName, String theParamName, boolean theMissing, RequestPartitionId theRequestPartitionId) { From<?, SearchParamPresent> paramPresentJoin = myQueryRootStack.createJoin(SearchBuilderJoinEnum.PRESENCE, null); Expression<Long> hashPresence = paramPresentJoin.get("myHashPresence").as(Long.class); Long hash = SearchParamPresent.calculateHashPresence(myPartitionSettings, theRequestPartitionId, theResourceName, theParamName, !theMissing); List<Predicate> predicates = new ArrayList<>(); predicates.add(myCriteriaBuilder.equal(hashPresence, hash)); addPartitionIdPredicate(theRequestPartitionId, paramPresentJoin, predicates); myQueryRootStack.setHasIndexJoins(); myQueryRootStack.addPredicates(predicates); }

Target:
void addPredicateParamMissingForReference(String theResourceName, String theParamName, boolean theMissing, RequestPartitionId theRequestPartitionId) { From<?, SearchParamPresent> paramPresentJoin = myQueryStack.createJoin(SearchBuilderJoinEnum.PRESENCE, null); Expression<Long> hashPresence = paramPresentJoin.get("myHashPresence").as(Long.class); Long hash = SearchParamPresent.calculateHashPresence(myPartitionSettings, theRequestPartitionId, theResourceName, theParamName, !theMissing); List<Predicate> predicates = new ArrayList<>(); predicates.add(myCriteriaBuilder.equal(hashPresence, hash)); addPartitionIdPredicate(theRequestPartitionId, paramPresentJoin, predicates); myQueryStack.addPredicatesWithImplicitTypeSelection(predicates); }
Source:
public void shouldCreateNewDruReferenceMap() throws Exception { final String JSON = "{\n" + " \"conceptReferenceTerm\":\"ee7693a0-8a55-22e3-8507-1f26fdd6e3f3\"\n" + ",\n" + " \"conceptMapType\": \"sece2323fa-0fa0-461f-9b59-6765997d84\"\n" + ",\n" + " \"drug\": \"8e2323fa-0fa0-461f-9b59-6765997d849d\"\n" + "}"; Drug drug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> maps = drug.getDrugReferenceMaps(); Assert.assertEquals(1, maps.size()); MockHttpServletRequest req = newPostRequest(getURI(), JSON); Set<DrugReferenceMap> updatedMaps = drug.getDrugReferenceMaps(); SimpleObject result = deserialize(handle(req)); Assert.assertEquals(2, updatedMaps.size()); Assert.assertEquals(RestTestConstants1_10.CONCEPT_REF_TERM_UUID, Util.getByPath(result, "conceptReferenceTerm/uuid")); Assert.assertEquals(RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID, Util.getByPath(result, "conceptMapType/uuid")); Assert.assertEquals(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID, Util.getByPath(result, "drug/uuid")); Assert.assertEquals("Panadol - concept_map_type2", Util.getByPath(result, "display")); }

Target:
public void shouldCreateNewDruReferenceMap() throws Exception { final String JSON = "{\n" + " \"conceptReferenceTerm\":\"" + RestTestConstants1_10.CONCEPT_REF_TERM_UUID + "\"\n" + ",\n" + " \"conceptMapType\": \"" + RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID + "\"\n" + ",\n" + " \"drug\": \"" + RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID + "\"\n" + "}"; Drug drug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> maps = drug.getDrugReferenceMaps(); Assert.assertEquals(1, maps.size()); MockHttpServletRequest req = newPostRequest(getURI(), JSON); MockHttpServletResponse resp = handle(req); Drug updatedDrug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> updatedMaps = updatedDrug.getDrugReferenceMaps(); Assert.assertEquals(2, updatedMaps.size()); SimpleObject result = deserialize(resp); Assert.assertEquals(RestTestConstants1_10.CONCEPT_REF_TERM_UUID, Util.getByPath(result, "conceptReferenceTerm/uuid")); Assert.assertEquals(RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID, Util.getByPath(result, "conceptMapType/uuid")); Assert.assertEquals(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID, Util.getByPath(result, "drug/uuid")); Assert.assertEquals("Panadol - concept_map_type2", Util.getByPath(result, "display")); }
Source:
public VelocityAdminMode(final HttpServletRequest request, final HttpServletResponse response, final IHTMLPage htmlPage, final Host host) { super(request, response, htmlPage, host); }

Target:
protected VelocityAdminMode(final HttpServletRequest request, final HttpServletResponse response, final IHTMLPage htmlPage, final Host host) { super(request, response, htmlPage, host); }
Source:
private Engine.IndexResult index(Engine engine, Engine.Index index) throws IOException { active.set(true); final Engine.IndexResult result; index = indexingOperationListeners.preIndex(shardId, index); try { if (logger.isTraceEnabled()) { logger.trace( "index [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin()); } result = engine.index(index); if (logger.isTraceEnabled()) { logger.trace( "index-done [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin " + "result-seq# result-term failure [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin(), result.getSeqNo(), result.getTerm(), result.getFailure()); } } catch (Exception e) { if (logger.isTraceEnabled()) { logger.trace(new ParameterizedMessage( "index-fail [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin() ), e); } indexingOperationListeners.postIndex(shardId, index, e); throw e; } indexingOperationListeners.postIndex(shardId, index, result); return result; }

Target:
private Engine.IndexResult index(Engine engine, Engine.Index index) throws IOException { active.set(true); final Engine.IndexResult result; index = indexingOperationListeners.preIndex(shardId, index); boolean traceEnabled = logger.isTraceEnabled(); try { if (traceEnabled) { logger.trace( "index [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin()); } result = engine.index(index); if (traceEnabled) { logger.trace( "index-done [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin " + "result-seq# result-term failure [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin(), result.getSeqNo(), result.getTerm(), result.getFailure()); } } catch (Exception e) { if (traceEnabled) { logger.trace(new ParameterizedMessage( "index-fail [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin() ), e); } indexingOperationListeners.postIndex(shardId, index, e); throw e; } indexingOperationListeners.postIndex(shardId, index, result); return result; }
Source:
public void getDataContext() { final String key1 = "Key1"; final String value1 = "first-value"; Context context = new Context(key1, value1); Optional<Object> optionalObject = context.getData(key1); System.out.printf("Key1 value : %s%n", optionalObject.get().toString()); END: com.azure.core.util.context.getData#object }

Target:
public void getDataContext() { final String key1 = "Key1"; final String value1 = "first-value"; Context context = new Context(key1, value1); Optional<Object> optionalObject = context.getData(key1); if (optionalObject.isPresent()) { System.out.printf("Key1 value: %s%n", optionalObject.get()); } else { System.out.println("Key1 does not exist or have data."); } END: com.azure.core.util.context.getData#object }
Source:
public void onPrepareOptionsMenu(Menu menu) { ComposeCryptoStatus currentCryptoStatus = getCurrentCachedCryptoStatus(); boolean isCryptoConfigured = currentCryptoStatus != null && currentCryptoStatus.isProviderStateOk(); if (isCryptoConfigured) { boolean isEncrypting = currentCryptoStatus.isEncryptionEnabled(); menu.findItem(R.id.openpgp_encrypt_enable).setVisible(!isEncrypting); menu.findItem(R.id.openpgp_encrypt_disable).setVisible(isEncrypting); boolean hideSignOnly = account.getPgpHideSignOnly(); boolean isSignOnly = currentCryptoStatus.isSignOnly(); menu.findItem(R.id.openpgp_sign_only).setVisible(!hideSignOnly && !isSignOnly); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(!hideSignOnly && isSignOnly); boolean pgpInlineModeEnabled = currentCryptoStatus.isPgpInlineModeEnabled(); boolean showPgpInlineEnable = (isEncrypting || isSignOnly) && !pgpInlineModeEnabled; menu.findItem(R.id.openpgp_inline_enable).setVisible(showPgpInlineEnable); menu.findItem(R.id.openpgp_inline_disable).setVisible(pgpInlineModeEnabled); } else { menu.findItem(R.id.openpgp_inline_enable).setVisible(false); menu.findItem(R.id.openpgp_inline_disable).setVisible(false); menu.findItem(R.id.openpgp_encrypt_enable).setVisible(false); menu.findItem(R.id.openpgp_encrypt_disable).setVisible(false); menu.findItem(R.id.openpgp_sign_only).setVisible(false); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(false); } boolean noContactPickerAvailable = !hasContactPicker(); if (noContactPickerAvailable) { menu.findItem(R.id.add_from_contacts).setVisible(false); } }

Target:
public void onPrepareOptionsMenu(Menu menu) { ComposeCryptoStatus currentCryptoStatus = getCurrentCachedCryptoStatus(); boolean isCryptoConfigured = currentCryptoStatus != null && currentCryptoStatus.isProviderStateOk(); if (isCryptoConfigured) { boolean isEncrypting = currentCryptoStatus.isEncryptionEnabled(); menu.findItem(R.id.openpgp_encrypt_enable).setVisible(!isEncrypting); menu.findItem(R.id.openpgp_encrypt_disable).setVisible(isEncrypting); boolean showSignOnly = !account.getOpenPgpHideSignOnly(); boolean isSignOnly = currentCryptoStatus.isSignOnly(); menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly); boolean pgpInlineModeEnabled = currentCryptoStatus.isPgpInlineModeEnabled(); boolean showPgpInlineEnable = (isEncrypting || isSignOnly) && !pgpInlineModeEnabled; menu.findItem(R.id.openpgp_inline_enable).setVisible(showPgpInlineEnable); menu.findItem(R.id.openpgp_inline_disable).setVisible(pgpInlineModeEnabled); } else { menu.findItem(R.id.openpgp_inline_enable).setVisible(false); menu.findItem(R.id.openpgp_inline_disable).setVisible(false); menu.findItem(R.id.openpgp_encrypt_enable).setVisible(false); menu.findItem(R.id.openpgp_encrypt_disable).setVisible(false); menu.findItem(R.id.openpgp_sign_only).setVisible(false); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(false); } boolean noContactPickerAvailable = !hasContactPicker(); if (noContactPickerAvailable) { menu.findItem(R.id.add_from_contacts).setVisible(false); } }
Source:
private static void getInput(SqlNode node, ArrayList<String> inputSource) { if (node instanceof SqlJoin) { SqlJoin joinNode = (SqlJoin) node; ArrayList<String> inputsLeft = new ArrayList<>(); ArrayList<String> inputsRight = new ArrayList<>(); getInput(joinNode.getLeft(), inputsLeft); getInput(joinNode.getRight(), inputsRight); if (!inputsLeft.isEmpty() && !inputsRight.isEmpty()) { throw new SamzaException("Joins on two entities are not supported yet"); } inputSource.addAll(inputsLeft); inputSource.addAll(inputsRight); } else if (node instanceof SqlIdentifier) { inputSource.add(node.toString()); } else if (node instanceof SqlBasicCall) { SqlBasicCall basicCall = ((SqlBasicCall) node); if (basicCall.getOperator() instanceof SqlAsOperator) { getInput(basicCall.operand(0), inputSource); } } }

Target:
private static void getInput(SqlNode node, ArrayList<String> inputSource) { if (node instanceof SqlJoin) { SqlJoin joinNode = (SqlJoin) node; ArrayList<String> inputsLeft = new ArrayList<>(); ArrayList<String> inputsRight = new ArrayList<>(); getInput(joinNode.getLeft(), inputsLeft); getInput(joinNode.getRight(), inputsRight); if (!inputsLeft.isEmpty() && !inputsRight.isEmpty()) { throw new SamzaException("Joins on two entities are not supported yet"); } inputSource.addAll(inputsLeft); inputSource.addAll(inputsRight); } else if (node instanceof SqlIdentifier) { inputSource.add(node.toString()); } else if (node instanceof SqlBasicCall) { SqlBasicCall basicCall = ((SqlBasicCall) node); if (basicCall.getOperator() instanceof SqlAsOperator) { getInput(basicCall.operand(0), inputSource); } else if (basicCall.getOperator() instanceof SqlUnnestOperator && basicCall.operand(0) instanceof SqlSelect) { inputSource.add(getInputFromSelectQuery(basicCall.operand(0))); return; } } else if (node instanceof SqlSelect) { getInput(((SqlSelect) node).getFrom(), inputSource); } }
Source:
public void testCloseFailedChunkedInput() { Exception error = new Exception("Unable to produce a chunk"); ThrowingChunkedInput input = new ThrowingChunkedInput(error); EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler()); try { ch.writeAndFlush(input).sync(); fail("Exception expected"); } catch (Exception e) { assertEquals(error, e); } assertTrue(input.closed); }

Target:
public void testCloseFailedChunkedInput() { Exception error = new Exception("Unable to produce a chunk"); ThrowingChunkedInput input = new ThrowingChunkedInput(error); EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler()); try { ch.writeOutbound(input); fail("Exception expected"); } catch (Exception e) { assertEquals(error, e); } assertTrue(input.isClosed()); assertFalse(ch.finish()); }
Source:
public void ignoreConstraintAnnotationsOnParameter(Member member, int index) { if ( annotationIgnoresForMethodParameter.get( member ) == null ) { List<Integer> tmpList = new ArrayList<Integer>(); tmpList.add( index ); annotationIgnoresForMethodParameter.put( member, tmpList ); } else { annotationIgnoresForMethodParameter.get( member ).add( index ); } }

Target:
public void ignoreConstraintAnnotationsOnParameter(Member member, int index) { if ( annotationIgnoresForMethodParameter.get( member ) == null ) { List<Integer> tmpList = newArrayList(); tmpList.add( index ); annotationIgnoresForMethodParameter.put( member, tmpList ); } else { annotationIgnoresForMethodParameter.get( member ).add( index ); } }
Source:
private boolean isEventCrfCompleted(EventCrf eventCrf) { if(eventCrf.getStatusId() == EventCRFStatus.INITIAL_DATA_ENTRY_COMPLETE.getCode()) { return true; }else if(eventCrf.getStatusId() == EventCRFStatus.DOUBLE_DATA_ENTRY_COMPLETE.getCode()) { return true; }else if(eventCrf.getStatusId() == 2) { return true; }else { return false; } }

Target:
private boolean isEventCrfCompleted(EventCrf eventCrf) { if(eventCrf.getStatusId() == Status.UNAVAILABLE.getCode()) { return true; }else { return false; } }
Source:
public TurboIssueEventTests() { sampleEvents = new ArrayList<>(); sampleEvents.add( new TurboIssueEvent( new User().setLogin("A"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0).getTime()) .setLabelName("A1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("A"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 2, 0).getTime()) .setLabelName("A2")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 0, 30).getTime()) .setLabelName("B1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0).getTime()) .setLabelName("B2")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 1, 31).getTime()) .setLabelName("B1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("C"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 2, 30, 15).getTime()) .setLabelName("C1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("D"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 3, 20, 59).getTime()) .setLabelName("D1")); }

Target:
public TurboIssueEventTests() { sampleEvents = new ArrayList<>(); sampleEvents.add( createLabelUpdateEvent("A", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0), "A1")); sampleEvents.add( createLabelUpdateEvent("A", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 2, 0), "A2")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 0, 30), "B1")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0), "B2")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 1, 31), "B1")); sampleEvents.add( createLabelUpdateEvent("C", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 2, 30, 15), "C1")); sampleEvents.add( createLabelUpdateEvent("D", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 3, 20, 59), "D1")); }
Source:
private void addFieldMapping(JsonObject payload, EntityIndexBinding descriptor, DocumentFieldMetadata fieldMetadata) { String simpleFieldName = FieldHelper.getEmbeddedFieldPropertyName( fieldMetadata.getName() ); JsonObject field = new JsonObject(); String fieldType = getFieldType( descriptor, fieldMetadata ); if ( fieldType == null ) { LOG.debug( "Not adding a mapping for field " + fieldMetadata.getFieldName() + " as its type could not be determined" ); return; } field.addProperty( "type", fieldType ); field.addProperty( "store", fieldMetadata.getStore() == Store.NO ? false : true ); String index = getIndex( descriptor, fieldMetadata ); field.addProperty( "index", index ); if ( "no".equals( index ) && FieldHelper.isSortableField(descriptor, fieldMetadata.getFieldName()) ) { field.addProperty( "doc_values", true ); } String analyzerName = getAnalyzerName( descriptor, fieldMetadata, index ); if ( analyzerName != null ) { field.addProperty( "analyzer", analyzerName ); } if ( fieldMetadata.getBoost() != null ) { field.addProperty( "boost", fieldMetadata.getBoost() ); } if ( fieldMetadata.indexNullAs() != null ) { field.addProperty( "null_value", fieldMetadata.indexNullAs() ); } getOrCreateProperties( payload, fieldMetadata.getName() ).add( simpleFieldName, field ); for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) { if ( !facetMetadata.getFacetName().equals( fieldMetadata.getFieldName() ) ) { addFieldMapping( payload, facetMetadata ); } } }

Target:
private void addFieldMapping(JsonObject payload, EntityIndexBinding descriptor, DocumentFieldMetadata fieldMetadata) { String simpleFieldName = FieldHelper.getEmbeddedFieldPropertyName( fieldMetadata.getName() ); JsonObject field = new JsonObject(); String fieldType = getFieldType( descriptor, fieldMetadata ); if ( fieldType == null ) { LOG.debug( "Not adding a mapping for field " + fieldMetadata.getFieldName() + " as its type could not be determined" ); return; } field.addProperty( "type", fieldType ); field.addProperty( "store", fieldMetadata.getStore() == Store.NO ? false : true ); addIndexOptions( field, descriptor, fieldMetadata.getName(), fieldType, fieldMetadata.getIndex(), fieldMetadata.getAnalyzerReference() ); if ( fieldMetadata.getBoost() != null ) { field.addProperty( "boost", fieldMetadata.getBoost() ); } if ( fieldMetadata.indexNullAs() != null ) { field.addProperty( "null_value", fieldMetadata.indexNullAs() ); } getOrCreateProperties( payload, fieldMetadata.getName() ).add( simpleFieldName, field ); for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) { if ( !facetMetadata.getFacetName().equals( fieldMetadata.getFieldName() ) ) { addFieldMapping( payload, facetMetadata ); } } }
Source:
public void testTimedInterface() { final IDummy dummy = TimedInterface.newProxy(IDummy.class, new DummyImpl(), "id"); DefaultMonitorRegistry.getInstance().register((CompositeMonitor)dummy); for (int i = 0; i < 42; i++) { dummy.method1(); if (i % 2 == 0) { dummy.method2(i); } } final CompositeMonitor<Long> compositeMonitor = (CompositeMonitor<Long>) dummy; final List<Monitor<?>> monitors = compositeMonitor.getMonitors(); assertEquals(monitors.size(), 2); assertEquals(compositeMonitor.getValue().longValue(), 2L); final TagList tagList = BasicTagList.of( TimedInterface.CLASS_TAG, "DummyImpl", TimedInterface.INTERFACE_TAG, "IDummy", TimedInterface.ID_TAG, "id"); final MonitorConfig expectedConfig = MonitorConfig.builder(TimedInterface.TIMED_INTERFACE) .withTags(tagList).build(); assertEquals(compositeMonitor.getConfig(), expectedConfig); for (Monitor<?> monitor: monitors) { final MonitorConfig config = monitor.getConfig(); final String method = config.getName(); final MonitorConfig expected = MonitorConfig.builder(method).withTags(tagList).build(); assertEquals(config, expected); if (method.equals("method1")) { long value = ((Monitor<Long>) monitor).getValue() - 5; assertTrue(value >= 0 && value <= 4); } else { assertEquals(method, "method2"); long value = ((Monitor<Long>) monitor).getValue() - 15; assertTrue(value >= 0 && value <= 4); } } }

Target:
public void testTimedInterface() { final IDummy dummy = TimedInterface.newProxy(IDummy.class, new DummyImpl(), "id"); DefaultMonitorRegistry.getInstance().register((CompositeMonitor)dummy); for (int i = 0; i < 42; i++) { dummy.method1(); if (i % 2 == 0) { dummy.method2(i); } } final CompositeMonitor<Long> compositeMonitor = (CompositeMonitor<Long>) dummy; final List<Monitor<?>> monitors = compositeMonitor.getMonitors(); assertEquals(monitors.size(), 2); assertEquals(compositeMonitor.getValue().longValue(), 2L); final TagList tagList = BasicTagList.of( TimedInterface.CLASS_TAG, "DummyImpl", TimedInterface.INTERFACE_TAG, "IDummy", TimedInterface.ID_TAG, "id"); final MonitorConfig expectedConfig = MonitorConfig.builder(TimedInterface.TIMED_INTERFACE) .withTags(tagList).build(); assertEquals(compositeMonitor.getConfig(), expectedConfig); for (Monitor<?> monitor: monitors) { final MonitorConfig config = monitor.getConfig(); final String method = config.getName(); final MonitorConfig expected = MonitorConfig.builder(method).withTags(tagList).build(); assertEquals(config, expected); if (method.equals("method1")) { long value = ((Monitor<Long>) monitor).getValue() - 20; assertTrue(value >= 0 && value <= 9); } else { assertEquals(method, "method2"); long value = ((Monitor<Long>) monitor).getValue() - 40; assertTrue(value >= 0 && value <= 9); } } }
Source:
public ServerAddressMacroRegistrar( EventBus eventBus, Provider<MacroRegistry> macroRegistryProvider, AppContext appContext, WsAgentServerUtil wsAgentServerUtil) { this.macroRegistryProvider = macroRegistryProvider; this.appContext = appContext; this.wsAgentServerUtil = wsAgentServerUtil; eventBus.addHandler( BasicIDEInitializedEvent.TYPE, e -> { if (appContext.getWorkspace().getStatus() == RUNNING) { registerMacros(); } }); eventBus.addHandler(WorkspaceRunningEvent.TYPE, e -> registerMacros()); eventBus.addHandler( WorkspaceStoppedEvent.TYPE, e -> { if (macros != null) { macros.forEach(macro -> macroRegistryProvider.get().unregister(macro)); macros.clear(); } }); }

Target:
public ServerAddressMacroRegistrar( EventBus eventBus, Provider<MacroRegistry> macroRegistryProvider, AppContext appContext, WsAgentServerUtil wsAgentServerUtil) { this.macroRegistryProvider = macroRegistryProvider; this.appContext = appContext; this.wsAgentServerUtil = wsAgentServerUtil; eventBus.addHandler( BasicIDEInitializedEvent.TYPE, e -> { if (appContext.getWorkspace().getStatus() == RUNNING) { registerMacros(); } }); eventBus.addHandler(WorkspaceRunningEvent.TYPE, e -> registerMacros()); eventBus.addHandler( WorkspaceStoppedEvent.TYPE, e -> { macros.forEach(macro -> macroRegistryProvider.get().unregister(macro)); macros.clear(); }); }
Source:
MessageQueue(boolean singleReaderMode, int publishHighwaterMark) { this.queue = new LinkedBlockingQueue<NatsMessage>(); this.running = new AtomicInteger(RUNNING); this.sizeInBytes = new AtomicLong(0); this.length = new AtomicLong(0); this.poisonPill = new NatsMessage("_poison", null, NatsConnection.EMPTY_BODY, false); this.filterLock = new ReentrantLock(); this.singleThreadedReader = singleReaderMode; }

Target:
MessageQueue(boolean singleReaderMode, int publishHighwaterMark) { this.queue = publishHighwaterMark > 0 ? new LinkedBlockingQueue<NatsMessage>(publishHighwaterMark) : new LinkedBlockingQueue<NatsMessage>(); this.running = new AtomicInteger(RUNNING); this.sizeInBytes = new AtomicLong(0); this.length = new AtomicLong(0); this.poisonPill = new NatsMessage("_poison", null, NatsConnection.EMPTY_BODY, false); this.filterLock = new ReentrantLock(); this.singleThreadedReader = singleReaderMode; }
Source:
private void assertWarehouseLocationModel(DefaultStructuredMetadataModel warehouselocationModel) { Assert.assertThat(warehouselocationModel.getFields().size(), CoreMatchers.is(2)); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(0).getName(), CoreMatchers.is("latitude")); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(1).getName(), CoreMatchers.is("longitude")); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); }

Target:
private void assertWarehouseLocationModel(DefaultStructuredMetadataModel warehouselocationModel) { Assert.assertThat(warehouselocationModel.getFields(), IsCollectionWithSize.hasSize(2)); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(0).getName(), CoreMatchers.is("latitude")); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(1).getName(), CoreMatchers.is("longitude")); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); }
Source:
private StorageServiceMBean newStorageService() { return (StorageServiceMBean) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{StorageServiceMBean.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); switch (name) { case "takeSnapshot": invocations.add("takeSnapshot"); return null; case "clearSnapshot": invocations.add("clearSnapshot"); return null; case "truncate": invocations.add("truncate"); return null; case "getAllDataFileLocations": return new String[]{dataDir}; default: throw new UnsupportedOperationException(name); } } }); }

Target:
private StorageServiceMBean newStorageService() { return (StorageServiceMBean) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{StorageServiceMBean.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); switch (name) { case "takeSnapshot": invocations.add("takeSnapshot"); return null; case "clearSnapshot": invocations.add("clearSnapshot"); return null; case "getAllDataFileLocations": return new String[]{dataDir}; default: throw new UnsupportedOperationException(name); } } }); }
Source:
public Object inject(Object instance) throws InjectionProviderException { return instance; }

Target:
public Object inject(Object instance) throws InjectionProviderException { return null; }
Source:
private void checkStripeExecutorView(StripedExecutor execSvc, String viewName, String poolName) throws Exception { CountDownLatch latch = new CountDownLatch(1); execSvc.execute(0, new SystemViewSelfTest.TestRunnable(latch, 0)); execSvc.execute(0, new SystemViewSelfTest.TestRunnable(latch, 1)); execSvc.execute(1, new SystemViewSelfTest.TestRunnable(latch, 2)); execSvc.execute(1, new SystemViewSelfTest.TestRunnable(latch, 3)); try { boolean res = waitForCondition(() -> systemView(viewName).size() == 2, 5_000); assertTrue(res); TabularDataSupport view = systemView(viewName); CompositeData row0 = view.get(new Object[] {0}); assertEquals(0, row0.get("stripeIndex")); assertEquals(SystemViewSelfTest.TestRunnable.class.getSimpleName() + '1', row0.get("description")); assertEquals(poolName + "-stripe-0", row0.get("threadName")); assertEquals(SystemViewSelfTest.TestRunnable.class.getName(), row0.get("taskName")); CompositeData row1 = view.get(new Object[] {1}); assertEquals(1, row1.get("stripeIndex")); assertEquals(SystemViewSelfTest.TestRunnable.class.getSimpleName() + '3', row1.get("description")); assertEquals(poolName + "-stripe-1", row1.get("threadName")); assertEquals(SystemViewSelfTest.TestRunnable.class.getName(), row1.get("taskName")); } finally { latch.countDown(); } }

Target:
private void checkStripeExecutorView(StripedExecutor execSvc, String viewName, String poolName) throws Exception { CountDownLatch latch = new CountDownLatch(1); execSvc.execute(0, new TestRunnable(latch, 0)); execSvc.execute(0, new TestRunnable(latch, 1)); execSvc.execute(1, new TestRunnable(latch, 2)); execSvc.execute(1, new TestRunnable(latch, 3)); try { boolean res = waitForCondition(() -> systemView(viewName).size() == 2, 5_000); assertTrue(res); TabularDataSupport view = systemView(viewName); CompositeData row0 = view.get(new Object[] {0}); assertEquals(0, row0.get("stripeIndex")); assertEquals(TestRunnable.class.getSimpleName() + '1', row0.get("description")); assertEquals(poolName + "-stripe-0", row0.get("threadName")); assertEquals(TestRunnable.class.getName(), row0.get("taskName")); CompositeData row1 = view.get(new Object[] {1}); assertEquals(1, row1.get("stripeIndex")); assertEquals(TestRunnable.class.getSimpleName() + '3', row1.get("description")); assertEquals(poolName + "-stripe-1", row1.get("threadName")); assertEquals(TestRunnable.class.getName(), row1.get("taskName")); } finally { latch.countDown(); } }
Source:
private void loadChapterOrganizers(Directory directory) { if (Strings.isNullOrEmpty(serializedOrganizers)) { return; } String[] organizers = serializedOrganizers.split(ID_SEPARATOR_FOR_SPLIT); for (String organizerId : organizers) { Chapter organizerChapter = null; for (Chapter chapter : directory.getGroups()) { if (chapter.getOrganizers().contains(organizerId)) { organizerChapter = chapter; break; } } if (organizerChapter != null) { final Organizer organizer = new Organizer(); organizer.setPlusId(organizerId); organizer.setChapterName(organizerChapter.getName()); organizer.setChapterId(organizerChapter.getGplusId()); Plus.PeopleApi.load(getGoogleApiClient(), organizer.getPlusId()) .setResultCallback(new ResultCallback<People.LoadPeopleResult>() { @Override public void onResult(People.LoadPeopleResult loadPeopleResult) { organizer.setResolved(loadPeopleResult.getPersonBuffer().get(0)); adapter.add(organizer); adapter.notifyDataSetChanged(); } }); } } }

Target:
private void loadChapterOrganizers(Directory directory) { if (TextUtils.isEmpty(serializedOrganizers)) { return; } String[] organizers = serializedOrganizers.split(ID_SEPARATOR_FOR_SPLIT); for (String organizerId : organizers) { Chapter organizerChapter = null; for (Chapter chapter : directory.getGroups()) { if (chapter.getOrganizers().contains(organizerId)) { organizerChapter = chapter; break; } } if (organizerChapter != null) { final Organizer organizer = new Organizer(); organizer.setPlusId(organizerId); organizer.setChapterName(organizerChapter.getName()); organizer.setChapterId(organizerChapter.getGplusId()); Plus.PeopleApi.load(getGoogleApiClient(), organizer.getPlusId()) .setResultCallback(new ResultCallback<People.LoadPeopleResult>() { @Override public void onResult(People.LoadPeopleResult loadPeopleResult) { organizer.setResolved(loadPeopleResult.getPersonBuffer().get(0)); adapter.add(organizer); adapter.notifyDataSetChanged(); } }); } } }
Source:
void handleBatch(final PlanContext planContext) { final BatchBuilder<K, T> batchBuilder = _batches.remove(planContext.getId()); if (batchBuilder != null) { final Batch<K, T> batch = batchBuilder.build(); if (batch.size() > 0) { try { final Map<G, Batch<K, T>> batches = split(batch); if (batches.size() > 0) { taskForBatches(batches.entrySet()).forEach(task -> new ContextImpl(planContext, task).runTask()); } } catch (Throwable t) { batch.failAllRemaining(t); } } } }

Target:
void handleBatch(final PlanContext planContext) { final BatchBuilder<K, T> batchBuilder = _batches.remove(planContext.getId()); if (batchBuilder != null) { final Batch<K, T> batch = batchBuilder.build(); if (batch.size() > 0) { try { final Map<G, Batch<K, T>> batches = split(batch); if (batches.size() > 0) { taskForBatches(batches.entrySet()).forEach(task -> new ContextImpl(planContext, task).runTask()); } } catch (Throwable t) { batch.failAll(t); } } } }
Source:
public void testSimpleSendAndReceive() throws Exception { final AtomicBoolean messageReceived = new AtomicBoolean(false); final CountDownLatch latch = new CountDownLatch(1); final QueueChannel channel = new QueueChannel(); ExecutorService exec = Executors.newSingleThreadExecutor(); exec.execute(() -> { Message<?> message = channel.receive(); if (message != null) { messageReceived.set(true); latch.countDown(); } }); assertFalse(messageReceived.get()); channel.send(new GenericMessage<String>("testing")); latch.await(10000, TimeUnit.MILLISECONDS); assertTrue(messageReceived.get()); exec.shutdownNow(); }

Target:
public void testSimpleSendAndReceive() throws Exception { final CountDownLatch latch = new CountDownLatch(1); final QueueChannel channel = new QueueChannel(); ExecutorService exec = Executors.newSingleThreadExecutor(); exec.execute(() -> { Message<?> message = channel.receive(); if (message != null) { latch.countDown(); } }); channel.send(new GenericMessage<String>("testing")); assertTrue(latch.await(10000, TimeUnit.MILLISECONDS)); exec.shutdownNow(); }