auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private static <E> boolean isSatisfied(List<E>[] satisfiedElementsLists, int begin) { if (begin == satisfiedElementsLists.length) return true; <START> if (satisfiedElementsLists[begin].size() == 0) return false; END> for (E element : satisfiedElementsLists[begin]) { List<Integer> indeces = newArrayList(); for (int i = begin + 1; i < satisfiedElementsLists.length; i++) { if (satisfiedElementsLists[i].contains(element)) { indeces.add(i); satisfiedElementsLists[i].remove(element); } } if (isSatisfied(satisfiedElementsLists, begin + 1)) return true; for (int i : indeces) satisfiedElementsLists[i].add(element); } return false; }</code><technical_language>isEmpty() more readable here? suggestion if (satisfiedElementsLists[begin].isEmpty()) return false; // satisfied element for consumers[begin]</technical_language>

Target:
private static <E> boolean isSatisfied(List<E>[] satisfiedElementsLists, int begin) { if (begin == satisfiedElementsLists.length) return true; if (satisfiedElementsLists[begin].isEmpty()) return false; for (E element : satisfiedElementsLists[begin]) { List<Integer> removedElementRowIndices = newArrayList(); for (int i = begin + 1; i < satisfiedElementsLists.length; i++) { if (satisfiedElementsLists[i].remove(element)) { removedElementRowIndices.add(i); } } if (isSatisfied(satisfiedElementsLists, begin + 1)) return true; for (int i : removedElementRowIndices) { satisfiedElementsLists[i].add(element); } } return false; }
Source:
<code>public static void replaceUserDataInRequest( HttpMessage msg, Map<String, String> userDataMap, UnaryOperator<String> bodyEncoder) { try { Map<String, String> kvMap = new HashMap<>(userDataMap.size()); for (Entry<String, String> userdata : userDataMap.entrySet()) { kvMap.put( URLEncoder.encode(userdata.getKey(), StandardCharsets.UTF_8.name()), userdata.getValue()); } String uri = AuthenticationHelper.replaceUserData( msg.getRequestHeader().getURI().toString(), kvMap, PostBasedAuthenticationMethodType::encodeParameter); msg.getRequestHeader().setURI(new URI(uri, true)); } catch (Exception e) { <START> log.error(e.getMessage(), e); <END> } if (msg.getRequestBody().length() > 0) { msg.setRequestBody( AuthenticationHelper.replaceUserData( msg.getRequestBody().toString(), userDataMap, bodyEncoder)); msg.getRequestHeader().setContentLength(msg.getRequestBody().length()); } }</code><technical_language>Worth adding a message failed done</technical_language>

Target:
public static void replaceUserDataInRequest( HttpMessage msg, Map<String, String> userDataMap, UnaryOperator<String> bodyEncoder) { try { Map<String, String> kvMap = new HashMap<>(userDataMap.size()); for (Entry<String, String> userdata : userDataMap.entrySet()) { kvMap.put( URLEncoder.encode(userdata.getKey(), StandardCharsets.UTF_8.name()), userdata.getValue()); } String uri = AuthenticationHelper.replaceUserData( msg.getRequestHeader().getURI().toString(), kvMap, PostBasedAuthenticationMethodType::encodeParameter); msg.getRequestHeader().setURI(new URI(uri, true)); } catch (Exception e) { log.error( "Failed to replace user data in request " + msg.getRequestHeader().getURI(), e); } if (msg.getRequestBody().length() > 0) { msg.setRequestBody( AuthenticationHelper.replaceUserData( msg.getRequestBody().toString(), userDataMap, bodyEncoder)); msg.getRequestHeader().setContentLength(msg.getRequestBody().length()); } }
Source:
<code>protected void doStart() { try { this.main.start(); } catch (Throwable exc) { <START> LOG.error("Got unexpected exception while starting AutoRecoveryMain", exc); <END> if (uncaughtExceptionHandler != null) { LOG.error("Calling uncaughtExceptionHandler"); uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), exc); } else { throw new RuntimeException("Failed to start AutoRecoveryMain", exc); } } }</code><technical_language>Lets move this AbstractLifecycle#start() method, exceptions happen in component start</technical_language>

Target:
protected void doStart() { this.main.start(); }
Source:
<code>public ExecutionResult executeInVR(String routerIP, String script, String args) { <START> return executeInVR(routerIP, script, args, Duration.standardSeconds(120L)); <END> }</code><technical_language>Please consider extracting Duration.standardSeconds(120L) a constant clarify intent</technical_language>

Target:
public ExecutionResult executeInVR(String routerIP, String script, String args) { return executeInVR(routerIP, script, args, VRScripts.VR_SCRIPT_EXEC_TIMEOUT); }
Source:
<code>public Response getDeviceOrganizationIsGateway(@PathParam("deviceId") String deviceId) { if (deviceId == null) { String errorMessage = "The parameter of the device organization ID is empty."; return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); } int result; DeviceOrganizationProviderService dops = new DeviceOrganizationProviderServiceImpl(); try { result = dops.getDeviceOrganizationIsGateway(deviceId); if (result == -1) { String msg = "Device with ID: " + deviceId + " not found."; log.error(msg); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } return Response.status(Response.Status.OK).entity(result).build(); } catch (DeviceOrganizationException e) { String msg = "Error occurred while retrieving id device with ID:" + deviceId + " is gateway in Device Organization "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (InvalidConfigurationException e) { log.error("failed to add operation", e); <START> return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); <END> } }</code><technical_language>Please add message entity describing error</technical_language>

Target:
public Response getDeviceOrganizationIsGateway(@PathParam("deviceId") String deviceId) { if (deviceId == null) { String errorMessage = "The parameter of the device organization ID is empty."; return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); } int result; DeviceOrganizationProviderService dops = new DeviceOrganizationProviderServiceImpl(); try { result = dops.getDeviceOrganizationIsGateway(deviceId); if (result == -1) { String msg = "Device with ID: " + deviceId + " not found."; if (log.isDebugEnabled()) { log.debug(msg); } return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } return Response.status(Response.Status.OK).entity(result).build(); } catch (DeviceOrganizationException e) { String msg = "Error occurred while retrieving device with ID:" + deviceId + " is gateway in Device " + "Organization "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (InvalidConfigurationException e) { String msg = "failed to add operation"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } }
Source:
<code>public void bztSmokeTests() throws Exception { String path = getClass().getResource("/performanceTest.yml").getPath(); final String bztParams = path + ' ' + "-o modules.jmeter.plugins=[] -o services=[] -o modules.jmeter.version=3.1 -o modules.jmeter.path="; story.addStep(new Statement() { public void evaluate() throws Throwable { DumbSlave s = story.j.createOnlineSlave(); s.setLabelString("test performance test "); WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo"); <START> p.setDefinition(new CpsFlowDefinition( <END> "node{ bzt '" + bztParams + "' + pwd() }", true)); WorkflowRun r = p.scheduleBuild2(0).waitForStart(); story.j.assertBuildStatusSuccess(story.j.waitForCompletion(r)); story.j.assertLogContains("File aggregate-results.xml reported 0.0% of errors [SUCCESS].", r); } }); }</code><technical_language>For fix tests Jenkins need create project directory, PerformanceTestBuildTest#testFlow#L38</technical_language>

Target:
public void bztSmokeTests() throws Exception { String path = getClass().getResource("/performanceTest.yml").getPath(); final String bztParams = path + ' ' + "-o modules.jmeter.plugins=[] -o services=[] -o modules.jmeter.version=3.1 -o modules.jmeter.path="; story.addStep(new Statement() { public void evaluate() throws Throwable { DumbSlave s = story.j.createOnlineSlave(); s.setLabelString("test performance test "); WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo"); p.setDefinition(new CpsFlowDefinition( "node('master'){ bzt(params: '" + bztParams + "' + pwd(), useSystemSitePackages: false, printDebugOutput: true) }", true)); p.getRootDir().mkdirs(); WorkflowRun r = p.scheduleBuild2(0).waitForStart(); story.j.assertBuildStatusSuccess(story.j.waitForCompletion(r)); story.j.assertLogContains("File aggregate-results.xml reported 0.0% of errors [SUCCESS].", r); } }); }
Source:
<code>private boolean updateTables() { synchronized (db) { final List<String> tables; try { <START> tables = JdbcUtils.getTables(db,table_types); <END> } catch (SQLException e) { log.error("Error while trying to get updated table list, ignoring and waiting for next " + "table poll interval", e); return false; } final List<String> filteredTables; if (whitelist != null) { filteredTables = new ArrayList<>(tables.size()); for (String table : tables) { if (whitelist.contains(table)) { filteredTables.add(table); } } } else if (blacklist != null) { filteredTables = new ArrayList<>(tables.size()); for (String table : tables) { if (!blacklist.contains(table)) { filteredTables.add(table); } } } else { filteredTables = tables; } if (!filteredTables.equals(this.tables)) { List<String> previousTables = this.tables; this.tables = filteredTables; db.notifyAll(); return previousTables != null; } return false; } }</code><technical_language>If allow setting this, support empty list types? This require a small change JdbcUtils.getTables(), simple support</technical_language>

Target:
private boolean updateTables() { synchronized (db) { final List<String> tables; try { tables = JdbcUtils.getTables(db, tableTypes); log.debug("Got the following tables: " + Arrays.toString(tables.toArray())); } catch (SQLException e) { log.error("Error while trying to get updated table list, ignoring and waiting for next " + "table poll interval", e); return false; } final List<String> filteredTables; if (whitelist != null) { filteredTables = new ArrayList<>(tables.size()); for (String table : tables) { if (whitelist.contains(table)) { filteredTables.add(table); } } } else if (blacklist != null) { filteredTables = new ArrayList<>(tables.size()); for (String table : tables) { if (!blacklist.contains(table)) { filteredTables.add(table); } } } else { filteredTables = tables; } if (!filteredTables.equals(this.tables)) { log.debug("After filtering we got tables: " + Arrays.toString(filteredTables.toArray())); List<String> previousTables = this.tables; this.tables = filteredTables; db.notifyAll(); return previousTables != null; } return false; } }
Source:
<code>public TryBodyVisitor(VariableTree catchTree) { this.secondaryLocation = Collections.singletonList(new JavaFileScannerContext.Location( <START> "This parameter will catch the AssertionError thrown by fail()", <END> catchTree.type())); }</code><technical_language>thrown fail() fail()</technical_language>

Target:
public TryBodyVisitor(VariableTree catchTree) { this.secondaryLocation = Collections.singletonList(new JavaFileScannerContext.Location( "This parameter will catch the AssertionError", catchTree.type())); }
Source:
<code>public void testTagsAreClearedEachRun() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final FileContents contents = new FileContents("filename", " contents.reportSingleLineComment(1, 0); final TreeWalkerAuditEvent dummyEvent = new TreeWalkerAuditEvent(contents, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent); final FileContents contents2 = new FileContents("filename2", "some line", " contents2.reportSingleLineComment(2, 0); final TreeWalkerAuditEvent dummyEvent2 = new TreeWalkerAuditEvent(contents2, "filename", new LocalizedMessage(1, null, null, null, null, Object.class, null), null); suppressionCommentFilter.accept(dummyEvent2); <START> final List tags = Whitebox.getInternalState(suppressionCommentFilter, "tags"); <END> assertEquals("Invalid tags size", 1, tags.size()); }</code><technical_language>is <LINK_0></technical_language>

Target:
public void testTagsAreClearedEachRun() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final List<?> tags1 = getTagsAfterExecution(suppressionCommentFilter, "filename1", " assertEquals("Invalid tags size", 1, tags1.size()); final List<?> tags2 = getTagsAfterExecution(suppressionCommentFilter, "filename2", "No comments in this file"); assertEquals("Invalid tags size", 0, tags2.size()); }
Source:
<code>public void testPrintXpathInvalidXpath() throws Exception { exit.expectSystemExitWithStatus(-2); exit.checkAssertionAfterwards(() -> { final String exceptionFirstLine = "com.puppycrawl.tools.checkstyle.api." + "CheckstyleException: Error during xpath evaluation" + EOL; assertTrue("Unexpected system error log", systemErr.getLog().startsWith(exceptionFirstLine)); <START> }); <END> Main.main("--tree-branch-for-xpath", "\\/CLASS_DEF[./IDENT[@text='Two']] getPath("InputMainXPath.java")); }</code><technical_language>assertThat</technical_language>

Target:
public void testPrintXpathInvalidXpath() throws Exception { final String invalidXpath = "\\/CLASS_DEF[./IDENT[@text='Two']] final String filePath = getFilePath("InputMainXPath.java"); exit.expectSystemExitWithStatus(-2); exit.checkAssertionAfterwards(() -> { final String exceptionFirstLine = "com.puppycrawl.tools.checkstyle.api." + "CheckstyleException: Error during evaluation for xpath: " + invalidXpath + ", file: " + filePath + EOL; assertThat("Unexpected system error log", systemErr.getLog().startsWith(exceptionFirstLine), is(true)); }); Main.main("--branch-matching-xpath", invalidXpath, filePath); }
Source:
<code>public NewPacketFormat(BasePeerNode pn, int ourInitialMsgID, int theirInitialMsgID) { this.pn = pn; <START> startedByPrio = new ArrayList(DMT.NUM_PRIORITIES); <END> for(int i = 0; i < DMT.NUM_PRIORITIES; i++) { startedByPrio.add(new HashMap()); } ourInitialMsgID = (ourInitialMsgID & 0x7FFFFFFF) % NUM_MESSAGE_IDS; theirInitialMsgID = (theirInitialMsgID & 0x7FFFFFFF) % NUM_MESSAGE_IDS; nextMessageID = ourInitialMsgID; messageWindowPtrAcked = ourInitialMsgID; messageWindowPtrReceived = theirInitialMsgID; }</code><technical_language>This (and next one) completely missing type parameters</technical_language>

Target:
NewPacketFormat(BasePeerNode pn, int ourInitialMsgID, int theirInitialMsgID) { this.pn = pn; startedByPrio = new ArrayList<>(DMT.NUM_PRIORITIES); for(int i = 0; i < DMT.NUM_PRIORITIES; i++) { startedByPrio.add(new HashMap<Integer, MessageWrapper>()); } ourInitialMsgID = (ourInitialMsgID & 0x7FFFFFFF) % NUM_MESSAGE_IDS; theirInitialMsgID = (theirInitialMsgID & 0x7FFFFFFF) % NUM_MESSAGE_IDS; nextMessageID = ourInitialMsgID; messageWindowPtrAcked = ourInitialMsgID; messageWindowPtrReceived = theirInitialMsgID; }
Source:
<code>public ChangePackage getFragment(String proxyId, int fragmentIndex) { final List<AbstractChangePackage> fragments = proxyIdToChangePackageFragments.get(proxyId); if (fragments == null) { <START> throw new IllegalStateException(Messages.ChangePackageFragmentProviderAdapter_NoFragmentsFound); <END> } final AbstractChangePackage abstractChangePackage = fragments.get(fragmentIndex); if (FileBasedChangePackage.class.isInstance(abstractChangePackage)) { final FileBasedChangePackage cp = (FileBasedChangePackage) abstractChangePackage; return cp.toInMemoryChangePackage(); } return (ChangePackage) abstractChangePackage; }</code><technical_language>ESExceptions</technical_language>

Target:
public List<AbstractOperation> getFragment(String proxyId, int fragmentIndex) throws ESException { final Map<Integer, List<AbstractOperation>> fragments = proxyIdToChangePackageFragments.get(proxyId); if (fragments == null) { throw new ESException(Messages.ChangePackageFragmentProviderAdapter_NoFragmentsFound); } return fragments.get(fragmentIndex); }
Source:
<code>public Collection<String> getProductSearchName() { if (aias != null) { return ActionableItems.getNames(aias); } <START> return new ArrayList<String>(); <END> }</code><technical_language>Collections.emptyList();</technical_language>

Target:
public Collection<String> getProductSearchName() { if (aias != null) { return ActionableItems.getNames(aias); } return Collections.emptyList(); }
Source:
<code>public void setup() { functionManager = createTestMetadataManager().getFunctionManager(); <START> subfieldExtractor = new SubfieldExtractor(new FunctionResolution(functionManager), new NoopExpressionOptimizer(), TestingSession.SESSION); <END> }</code><technical_language>a lambda here: (rowExpression, level, session) -> rowExpression</technical_language>

Target:
public void setup() { functionManager = createTestMetadataManager().getFunctionManager(); subfieldExtractor = new SubfieldExtractor( new FunctionResolution(functionManager), (rowExpression, level, session) -> rowExpression, TestingSession.SESSION); }
Source:
<code>private void setTvSubTitle() { <START> Log.d("gouri", "setTvSubTitle: in uploadfragments"); <END> final Activity activity = getActivity(); if (activity instanceof UploadActivity) { final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleItemSelected(); if (!isMultipleFileSelected) { tvSubTitle.setVisibility(View.GONE); } } }</code><technical_language>needed I guess</technical_language>

Target:
private void setTvSubTitle() { final Activity activity = getActivity(); if (activity instanceof UploadActivity) { final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleFilesSelected(); if (!isMultipleFileSelected) { tvSubTitle.setVisibility(View.GONE); } } }
Source:
<code>public Optional<ReplicaView> select(TopicPartition topicPartition, ClientMetadata clientMetadata, PartitionView partitionView) { if (clientMetadata.rackId != null && !clientMetadata.rackId.isEmpty()) { Set<ReplicaView> sameRackReplicas = partitionView.replicas().stream() .filter(replicaInfo -> clientMetadata.rackId.equalsIgnoreCase(replicaInfo.endpoint().rack())) .collect(Collectors.toSet()); if (sameRackReplicas.isEmpty()) { return partitionView.leader(); } else { Optional<ReplicaView> leader = partitionView.leader().filter(sameRackReplicas::contains); if (leader.isPresent()) { return leader; } else { PartitionView sameRackPartition = new PartitionView() { @Override public Set<ReplicaView> replicas() { return sameRackReplicas; } @Override public Optional<ReplicaView> leader() { return partitionView.leader(); } }; <START> return tieBreaker.select(topicPartition, clientMetadata, sameRackPartition); <END> } } } else { return partitionView.leader(); } }</code><technical_language>This return a replica is arbitrarily leader. I suggested in KIP limit selection ISR. discussed fetch offset account. totally fine return out-of-sync replica long requested offset. I this idea ensured get redirection loops consumer is switching leader follower. Potentially broker do this filtering passing replicas selector avoid extra api noise</technical_language>

Target:
public Optional<ReplicaView> select(TopicPartition topicPartition, ClientMetadata clientMetadata, PartitionView partitionView) { if (clientMetadata.rackId() != null && !clientMetadata.rackId().isEmpty()) { Set<ReplicaView> sameRackReplicas = partitionView.replicas().stream() .filter(replicaInfo -> clientMetadata.rackId().equals(replicaInfo.endpoint().rack())) .collect(Collectors.toSet()); if (sameRackReplicas.isEmpty()) { return Optional.of(partitionView.leader()); } else { if (sameRackReplicas.contains(partitionView.leader())) { return Optional.of(partitionView.leader()); } else { return sameRackReplicas.stream().max(ReplicaView.comparator()); } } } else { return Optional.of(partitionView.leader()); } }
Source:
<code>public void execute(IProgressMonitor monitor) throws CoreException { Git repoTree; <START> if (resources == null) { <END> throw new CoreException(new Status(IStatus.ERROR, Activator .getPluginId(), CoreText.OperationAlreadyExecuted)); } if (resources.length > 0) { if (paths != null) { for (IResource res : resources) { repoTree = new Git(getRepository(res)); repoTree.clean().setPaths(paths).call(); } } else { for (IResource res : resources) { repoTree = new Git(getRepository(res)); repoTree.clean().call(); } } } }</code><technical_language>this is checked in CleanActionHandler (actually org.eclipse.egit.ui.internal.actions.RepositoryActionHandler.getSelectedResources(ExecutionEvent) return null)</technical_language>

Target:
public void execute(IProgressMonitor monitor) throws CoreException { Git repoTree; Repository repo = getRepository(res); if (repo == null) continue; repoTree = new Git(repo); if (paths != null) { repoTree.clean().setPaths(paths).call(); } else { repoTree.clean().call(); } }
Source:
<code>default String getApiVersion() { final Class<? extends HasMetadata> clazz = getClass(); final ApiGroup group = clazz.getAnnotation(ApiGroup.class); if (group != null) { final ApiVersion version = clazz.getAnnotation(ApiVersion.class); return group.value() + "/" + version.value(); } <START> return null; <END> }</code><technical_language>I version.value() produce NullPointerEception in case ApiGroup annotation is provided</technical_language>

Target:
default String getApiVersion() { return getApiVersion(getClass()); }
Source:
<code>private void collectPluginCapabilities(Map<String, CapabilityInfo> output) { for (String pluginName : pluginCapabilities.plugins()) { if (!isPluginNameSane(pluginName)) { <START> log.warn(String.format("Plugin name is not sane: <%s> " + "dropping all plugin owned capabilities; " + "consider changing the plugin filename.", pluginName)); <END> continue; } for (Map.Entry<String, Provider<CapabilityDefinition>> entry : pluginCapabilities.byPlugin(pluginName).entrySet()) { String id = String.format("%s-%s", pluginName, entry.getKey()); output.put(id, new CapabilityInfo( id, entry.getValue().get().getDescription())); } } }</code><technical_language>instead say: log.warn(String.format( "Plugin name %s match [A-Za-z0-9-]+ capabilities;" + " rename plugin", pluginName));</technical_language>

Target:
private void collectPluginCapabilities(Map<String, CapabilityInfo> output) { for (String pluginName : pluginCapabilities.plugins()) { if (!isPluginNameSane(pluginName)) { log.warn(String.format( "Plugin name %s must match [A-Za-z0-9-]+ to use capabilities;" + " rename the plugin", pluginName)); continue; } for (Map.Entry<String, Provider<CapabilityDefinition>> entry : pluginCapabilities.byPlugin(pluginName).entrySet()) { String id = String.format("%s-%s", pluginName, entry.getKey()); output.put(id, new CapabilityInfo( id, entry.getValue().get().getDescription())); } } }
Source:
<code>public Set<String> getAddOns() { <START> return addOns; <END> }</code><technical_language>this return a SetView of addons collection</technical_language>

Target:
public SetView<String> getAddOns() { return this.addOns != null ? new SetView<>(this.addOns) : null; }
Source:
<code>public void setFactors(List<String> factors) throws Throwable { if ((sourceImmutablePolicy == null) || !(sourceImmutablePolicy instanceof FactorsPolicy)) { <START> throw new Throwable("Source Policy is not of type factors policy cannot add factors"); <END> } boolean inherence = false; boolean possession = false; boolean knowledge = false; for (String factor : factors) { if (factor.equals("KNOWLEDGE")) { knowledge = true; } if (factor.equals("INHERENCE")) { inherence = true; } if (factor.equals("POSSESSION")) { possession = true; } } sourceImmutablePolicy = new FactorsPolicy(sourceImmutablePolicy.getDenyRootedJailbroken(), sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), inherence, knowledge, possession); }</code><technical_language>Source Policy is of type "factors" policy add factors</technical_language>

Target:
public void setFactors(List<String> factors) throws Throwable { if ((sourceImmutablePolicy == null) || !(sourceImmutablePolicy instanceof FactorsPolicy)) { throw new Throwable("Source Policy is not of type factors policy and thus cannot add factors"); } boolean inherence = false; boolean possession = false; boolean knowledge = false; for (String factor : factors) { if (factor.equals("KNOWLEDGE")) { knowledge = true; } if (factor.equals("INHERENCE")) { inherence = true; } if (factor.equals("POSSESSION")) { possession = true; } } sourceImmutablePolicy = new FactorsPolicy(sourceImmutablePolicy.getDenyRootedJailbroken(), sourceImmutablePolicy.getDenyEmulatorSimulator(), sourceImmutablePolicy.getFences(), inherence, knowledge, possession); }
Source:
<code>public SCryptPasswordEncoder() { <START> this(new String(KeyGenerators.secureRandom().generateKey()), 16384, 8, 1); <END> }</code><technical_language>get default values? do imply (i.e. memory is used, time CPU, etc)</technical_language>

Target:
public SCryptPasswordEncoder() { this(16384, 8, 1, 32, 64); }
Source:
<code>public boolean equals(Plane a){ <START> if((this.name).equals(a.name) && (this.airport).equals(a.airport)){ <END> return true; } else return false; }</code><technical_language>returning result? java return this.name.equals(a.name) && this.airport.equals(a.airport);</technical_language>

Target:
public boolean equals(Plane a){ return (this.name).equals(a.name) && (this.airport).equals(a.airport); }
Source:
<code>protected void configure() { <START> System.out.println("TestGuiceModule binder"); <END> newSetBinder(binder(), TestRunner.class); newSetBinder(binder(), TestClasspathProvider.class); bind(TestingService.class); }</code><technical_language>logger if need log</technical_language>

Target:
protected void configure() { newSetBinder(binder(), TestRunner.class); newSetBinder(binder(), TestClasspathProvider.class); bind(TestingService.class); }
Source:
<code>public static ClassLoadingStrategy<?> resolveClassLoadingStrategy(Class<?> originalClass) { if ( ClassInjector.UsingLookup.isAvailable() ) { Object lookup; Method privateLookupIn; try { Class<?> methodHandles = Class.forName( "java.lang.invoke.MethodHandles" ); lookup = methodHandles.getMethod( "lookup" ).invoke( null ); privateLookupIn = methodHandles.getMethod( "privateLookupIn", Class.class, Class.forName( "java.lang.invoke.MethodHandles$Lookup" ) ); } catch (Exception e) { throw new HibernateException( LOG.bytecodeEnhancementFailed( originalClass.getName() ), e ); } Object privateLookup; try { try { privateLookup = privateLookupIn.invoke( null, originalClass, lookup ); } catch (InvocationTargetException exception) { if ( exception.getCause() instanceof IllegalAccessException ) { return new ClassLoadingStrategy.ForUnsafeInjection( originalClass.getProtectionDomain() ); } else { throw new HibernateException( LOG.bytecodeEnhancementFailed( originalClass.getName() ), exception.getCause() ); } } return ClassLoadingStrategy.UsingLookup.of( privateLookup ); } catch (Throwable e) { throw new HibernateException( LOG.bytecodeEnhancementFailedUnableToGetPrivateLookupFor( originalClass.getName() ), e ); } } else { <START> return new ClassLoadingStrategy.ForUnsafeInjection( originalClass.getProtectionDomain() ); <END> } }</code><technical_language>this new error message some specific advice users. catching Throwable . confident this suggestion open packages misleading, e.g. some other error is happening? I rephrase error mention solution (among many) - ideally specific catching</technical_language>

Target:
public static ClassLoadingStrategy<?> resolveClassLoadingStrategy(Class<?> originalClass) { if ( ClassInjector.UsingLookup.isAvailable() ) { Method privateLookupIn; try { privateLookupIn = MethodHandles.class.getMethod( "privateLookupIn", Class.class, MethodHandles.Lookup.class ); } catch (Exception e) { throw new HibernateException( LOG.bytecodeEnhancementFailed( originalClass.getName() ), e ); } try { Object privateLookup; try { privateLookup = privateLookupIn.invoke( null, originalClass, LOOKUP ); } catch (InvocationTargetException exception) { if ( exception.getCause() instanceof IllegalAccessException ) { return new ClassLoadingStrategy.ForUnsafeInjection( originalClass.getProtectionDomain() ); } else { throw new HibernateException( LOG.bytecodeEnhancementFailed( originalClass.getName() ), exception.getCause() ); } } return ClassLoadingStrategy.UsingLookup.of( privateLookup ); } catch (Throwable e) { throw new HibernateException( LOG.bytecodeEnhancementFailedUnableToGetPrivateLookupFor( originalClass.getName() ), e ); } } else { return new ClassLoadingStrategy.ForUnsafeInjection( originalClass.getProtectionDomain() ); } }
Source:
<code>protected IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { ProcessingStepHandler handler = new ProcessingStepHandler(); <START> List<ChecksumVerifier> checksumVerifiers = ChecksumUtilities.getChecksumVerifiers(descriptor); <END> for (ChecksumVerifier checksumVerifier : checksumVerifiers) { destination = handler.link(new ProcessingStep[] {checksumVerifier}, destination, monitor); } return getSourceRepository().getRawArtifact(descriptor, destination, monitor); }</code><technical_language>checksum</technical_language>

Target:
protected IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { ProcessingStepHandler handler = new ProcessingStepHandler(); Iterable<ChecksumVerifier> checksumVerifiers = ChecksumUtilities.getChecksumVerifiers(descriptor); for (ChecksumVerifier checksumVerifier : checksumVerifiers) { destination = handler.link(new ProcessingStep[] {checksumVerifier}, destination, monitor); } return getSourceRepository().getRawArtifact(descriptor, destination, monitor); }
Source:
<code>public QuantityType<T> offset(QuantityType<T> offset, Unit<T> unit) { List<Quantity<T>> list = new ArrayList<>(); list.add(quantity); list.add(offset.quantity); <START> final Quantity<T> sum = list.stream().reduce(QuantityFunctions.sum(unit)).get(); <END> return new QuantityType<T>(sum); }</code><technical_language>This Arrays.asList(quantity, offset.quantity).stream().reduce(QuantityFunctions.sum(unit)).get();</technical_language>

Target:
public QuantityType<T> offset(QuantityType<T> offset, Unit<T> unit) { final Quantity<T> sum = Arrays.asList(quantity, offset.quantity).stream().reduce(QuantityFunctions.sum(unit)) .get(); return new QuantityType<T>(sum); }
Source:
<code>public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) { if(!par2World.isRemote) { InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); for(int i = 0; i < baubles.getSizeInventory(); i++) if(baubles.getStackInSlot(i) == null && baubles.isItemValidForSlot(i, par1ItemStack)) { baubles.setInventorySlotContents(i, par1ItemStack.copy()); if(!par3EntityPlayer.capabilities.isCreativeMode){ par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null); } onEquipped(par1ItemStack, par3EntityPlayer); break; } } <START> return new ActionResult<ItemStack>(EnumActionResult.PASS, par1ItemStack); <END> }</code><technical_language>want SUCCESS here... Or, return success instead of breaking loop, return pass here. way, is right now, putting a bauble trigger hand item</technical_language>

Target:
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) { if(!par2World.isRemote) { InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(par3EntityPlayer); for(int i = 0; i < baubles.getSizeInventory(); i++) if(baubles.getStackInSlot(i) == null && baubles.isItemValidForSlot(i, par1ItemStack)) { baubles.setInventorySlotContents(i, par1ItemStack.copy()); if(!par3EntityPlayer.capabilities.isCreativeMode){ par3EntityPlayer.inventory.setInventorySlotContents(par3EntityPlayer.inventory.currentItem, null); } onEquipped(par1ItemStack, par3EntityPlayer); break; } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, par1ItemStack); }
Source:
<code>public KV<Object, Object> apply(SamzaSqlRelMessage message) { if (!message.hasMetadata()) { LOG.warn("Output message with no Metadata: " + message); <START> message.setSamzaSqlRelMsgMetadata(new SamzaSqlRelMsgMetadata(Instant.now().toString())); <END> } KV<Object, Object> retKV = this.samzaMsgConverter.convertToSamzaMessage(message); updateMetrics(message.getSamzaSqlRelMsgMetadata().getEventTime(), Instant.now()); return retKV; }</code><technical_language>If agree SamzaSqlRelMessage is created, event time current time is set, add this code. is place this determination of event time current time needs done is in Rel converter in convertToRelMessage API implementation. other places SamzaSqlRelMessage is created (like ProjectTranslator, Join QueryTranslator outputfunction), get time input rel message</technical_language>

Target:
public KV<Object, Object> apply(SamzaSqlRelMessage message) { Instant beginProcessing = Instant.now(); KV<Object, Object> retKV = this.samzaMsgConverter.convertToSamzaMessage(message); updateMetrics(beginProcessing, Instant.now(), message.getSamzaSqlRelMsgMetadata()); return retKV; }
Source:
<code>public static void main(String[] args) throws InterruptedException { Microservices seed = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .startAwait(); Microservices.builder() .discovery( serviceEndpoint -> new ScalecubeServiceDiscovery(serviceEndpoint) .options(opts -> opts.seedMembers(toAddress(seed.discovery().address())))) .transport(ServiceTransports::rsocketServiceTransport) .services(new BidiGreetingImpl()) .startAwait(); BidiGreetingService service = seed.call().api(BidiGreetingService.class); service .greeting(Flux.fromArray(new String[] {"joe", "dan", "roni"})) .doOnNext(onNext -> System.out.println(onNext)) .blockLast(); <START> Thread.currentThread().join(); <END> }</code><technical_language>Get a reference Microservices call .onShutdown().block()</technical_language>

Target:
public static void main(String[] args) { Microservices seed = Microservices.builder() .discovery(ScalecubeServiceDiscovery::new) .transport(ServiceTransports::rsocketServiceTransport) .startAwait(); Microservices ms = Microservices.builder() .discovery( serviceEndpoint -> new ScalecubeServiceDiscovery(serviceEndpoint) .options(opts -> opts.seedMembers(toAddress(seed.discovery().address())))) .transport(ServiceTransports::rsocketServiceTransport) .services(new BidiGreetingImpl()) .startAwait(); BidiGreetingService service = seed.call().api(BidiGreetingService.class); service .greeting(Flux.fromArray(new String[] {"joe", "dan", "roni"})) .doOnNext(onNext -> System.out.println(onNext)) .blockLast(); seed.onShutdown().block(); ms.onShutdown().block(); }
Source:
<code>public SnomedQueryBuilder statedParent(Long id) { <START> return addToQuery(SnomedMappings.parent(Concepts.STATED_RELATIONSHIP), id); <END> }</code><technical_language>addToQuery(SnomedMappings.statedParent(), id) work here</technical_language>

Target:
public SnomedQueryBuilder statedParent(Long id) { return addToQuery(SnomedMappings.statedParent(), id); }
Source:
<code>public void init() { Map<String, Class<? extends Check>> checks = new HashMap<>(); checks.put("allow all", Book.class); <START> checks.put("allow all", Author.class); <END> dictionary = new EntityDictionary(checks); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Pseudonym.class); dictionary.bindEntity(Address.class); }</code><technical_language>This check class</technical_language>

Target:
public void init() { Map<String, Class<? extends Check>> checks = new HashMap<>(); checks.put("allow all", com.yahoo.elide.security.checks.prefab.Role.ALL.class); checks.put("allow all", com.yahoo.elide.security.checks.prefab.Role.ALL.class); dictionary = new EntityDictionary(checks); dictionary.bindEntity(Book.class); dictionary.bindEntity(Author.class); dictionary.bindEntity(Publisher.class); dictionary.bindEntity(Pseudonym.class); dictionary.bindEntity(Address.class); }
Source:
<code>protected void setProxy() { if (Configuration.useProxy()) { Proxy proxyServer = new Proxy(); if ("true".equals(Configuration.useZap())) { String zapProxyAddress = String.format("%s:%s", XMLReader.getValue("zap_proxy.address"), Integer .parseInt(XMLReader.getValue("zap_proxy.port"))); proxyServer.setHttpProxy(zapProxyAddress); proxyServer.setSslProxy(zapProxyAddress); } else { server = new NetworkTrafficInterceptor(); server.setTrustAllServers(true); server.setConnectTimeout(90, TimeUnit.SECONDS); server.setTrustSource(TrustSource.defaultTrustSource()); server.setMitmDisabled(!Boolean.parseBoolean(Configuration.useMITM())); server.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS); server.setUseEcc(true); <START> proxyServer = server.startBrowserMobProxyServer(); <END> } caps.setCapability(CapabilityType.PROXY, proxyServer); } }</code><technical_language>Revert request timeout</technical_language>

Target:
protected void setProxy() { if (Configuration.useProxy()) { Proxy proxyServer = new Proxy(); if ("true".equals(Configuration.useZap())) { String zapProxyAddress = String.format("%s:%s", XMLReader.getValue("zap_proxy.address"), Integer .parseInt(XMLReader.getValue("zap_proxy.port"))); proxyServer.setHttpProxy(zapProxyAddress); proxyServer.setSslProxy(zapProxyAddress); } else { server = new NetworkTrafficInterceptor(); server.setTrustAllServers(true); server.setConnectTimeout(90, TimeUnit.SECONDS); server.setTrustSource(TrustSource.defaultTrustSource()); server.setMitmDisabled(!Boolean.parseBoolean(Configuration.useMITM())); server.setRequestTimeout(90, TimeUnit.SECONDS); server.enableHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_HEADERS); server.setUseEcc(true); proxyServer = server.startBrowserMobProxyServer(); } caps.setCapability(CapabilityType.PROXY, proxyServer); } }
Source:
<code>public void testIsVerificationSuccessful() { ______TS("null or empty response"); assertFalse(RecaptchaVerifier.isVerificationSuccessful(null)); assertFalse(RecaptchaVerifier.isVerificationSuccessful("")); ______TS("any other key"); <START> assertTrue(RecaptchaVerifier.isVerificationSuccessful("testResponseKey")); <END> assertTrue(RecaptchaVerifier.isVerificationSuccessful(".#?")); }</code><technical_language>i missed this out. Personally i m writing unit tests for service is dependent party servers. for this test, pls write a surrogate for party server mimic behavior e.g. sending strings get json responses for scenarios</technical_language>

Target:
public void testIsVerificationSuccessful() { ______TS("null or empty CAPTCHA response"); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful(null, "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("", "testKey")); ______TS("empty CAPTCHA secret key"); assertTrue(new RecaptchaVerifierStub().isVerificationSuccessful("empty secret key", null)); ______TS("Successful verification"); assertTrue(new RecaptchaVerifierStub().isVerificationSuccessful("success", "testKey")); ______TS("reCAPTCHA error codes that can occur during the API request execution"); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("missing recaptcha params", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("invalid recaptcha secret key", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("invalid recaptcha response", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("invalid recaptcha request", "testKey")); ______TS("Exceptions that can occur during the API request execution"); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("null response", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("invalid uri", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("http protocol error", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("i/o exception", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("timeout exception", "testKey")); assertFalse(new RecaptchaVerifierStub().isVerificationSuccessful("non 2xx http response", "testKey")); }
Source:
<code>private void fillValues(final Repository repository) throws IOException { gitDir.setText(repository.getDirectory().getAbsolutePath()); branch.setText(repository.getBranch()); workDir.setText(repository.getWorkTree().getAbsolutePath()); state.setText(repository.getRepositoryState().getDescription()); final ObjectId objectId = repository .resolve(repository.getFullBranch()); if (objectId == null) { if (repository.getAllRefs().size() == 0) headLink.setText(UIText.GitProjectPropertyPage_ValueEmptyRepository); else headLink.setText(UIText.GitProjectPropertyPage_ValueUnbornBranch); } else { headLink.setText(objectId.name()); headLink.setUnderlined(true); headLink.setFont(JFaceResources.getDialogFont()); headLink.setForeground(JFaceColors.getHyperlinkText(headLink .getDisplay())); headLink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { <START> CommitEditor.openQuiet(getCommit(repository, objectId)); <END> } }); } }</code><technical_language>CommitEditor.openQuiet called getCommit returns null</technical_language>

Target:
private void fillValues(final Repository repository) throws IOException { gitDir.setText(repository.getDirectory().getAbsolutePath()); branch.setText(repository.getBranch()); workDir.setText(repository.getWorkTree().getAbsolutePath()); state.setText(repository.getRepositoryState().getDescription()); final ObjectId objectId = repository .resolve(repository.getFullBranch()); if (objectId == null) { if (repository.getAllRefs().size() == 0) headLink.setText(UIText.GitProjectPropertyPage_ValueEmptyRepository); else headLink.setText(UIText.GitProjectPropertyPage_ValueUnbornBranch); } else { headLink.setText(objectId.name()); headLink.setUnderlined(true); headLink.setFont(JFaceResources.getDialogFont()); headLink.setForeground(JFaceColors.getHyperlinkText(headLink .getDisplay())); headLink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { RepositoryCommit commit = getCommit(repository, objectId); if(commit != null) { CommitEditor.openQuiet(commit); } } }); } }
Source:
<code>public byte[] readFromCopy() throws SQLException { <START> byte[] result = buf; <END> try { if (isBufAvailable()) { if (curPosition > 0 || len < buf.length) { byte[] ba = new byte[len - curPosition]; for (int i = curPosition; i < len; i++) { ba[i - curPosition] = buf[i]; } result = ba; } curPosition = len; } else { result = null; } } catch (IOException ioe) { throw new PSQLException(GT.tr("Read from copy failed."), PSQLState.CONNECTION_FAILURE); } return result; }</code><technical_language>is this assigned here? is assigned else below</technical_language>

Target:
public byte[] readFromCopy() throws SQLException { final byte[] result; try { if (isBufAvailable()) { if (curPosition == 0 && len == bytes.length) { result = bytes; } else { result = Arrays.copyOfRange(bytes, curPosition, len); } curPosition = len; } else { result = null; } } catch (IOException ioe) { throw new PSQLException(GT.tr("Read from copy failed."), PSQLState.CONNECTION_FAILURE); } return result; }
Source:
<code>private void editToolbarItems() { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { <START> IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage page = window.getActivePage(); IViewPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW); ConsoleView view = (ConsoleView)part; <END> if (view != null) { IToolBarManager tbm = view.getViewSite().getActionBars().getToolBarManager(); IContributionItem items= tbm.getItems(); GenieOpenConsoleAction openConsoleAction = new GenieOpenConsoleAction(); tbm.insertBefore(WARNING_CHECKBOX_ID, openConsoleAction); List<ActionContributionItem> itemsToRemove = Arrays.stream(items).filter(item->(item instanceof ActionContributionItem)) .map(item->(ActionContributionItem)item) .filter(item-> item.getAction().toString().contains("PinConsole")|| item.getAction() instanceof OpenConsoleAction) .collect(Collectors.toList()); itemsToRemove.forEach(action -> tbm.remove(action)); view.getViewSite().getActionBars().updateActionBars(); } } }); }</code><technical_language>pull this getConsoleView method, a bit more obvious on</technical_language>

Target:
private void editToolbarItems() { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { ConsoleView view = getConsoleView(); if (view != null) { IToolBarManager tbm = view.getViewSite().getActionBars().getToolBarManager(); IContributionItem items= tbm.getItems(); GenieOpenConsoleAction openConsoleAction = new GenieOpenConsoleAction(); tbm.insertBefore(CLEAR_CONSOLE_ID, openConsoleAction); List<ActionContributionItem> itemsToRemove = Arrays.stream(items).filter(item->(item instanceof ActionContributionItem)) .map(item->(ActionContributionItem)item) .filter(item-> item.getAction().toString().contains("PinConsole")|| item.getAction() instanceof OpenConsoleAction) .collect(Collectors.toList()); itemsToRemove.forEach(action -> tbm.remove(action)); view.getViewSite().getActionBars().updateActionBars(); } } }); }
Source:
<code>private void sendIPDataAsyncImpl(Inet4Address ipAddress, int destPort, IPProtocol protocol, boolean closeSocket, byte[] data) throws XBeeException { if (ipAddress == null) throw new NullPointerException("IP address cannot be null"); if (data == null) <START> throw new NullPointerException("Data cannot be null"); <END> if (destPort < 0 || destPort > 65535) throw new IllegalArgumentException("Destination port must be between 0 and 65535."); if (isRemote()) throw new OperationNotSupportedException("Cannot send IP data from a remote device."); int sourcePort = this.sourcePort; if (protocol != IPProtocol.UDP) sourcePort = 0; logger.debug(toString() + "Sending IP data asynchronously to {}:{} >> {}.", ipAddress, destPort, HexUtils.prettyHexString(data)); XBeePacket xbeePacket = new TXIPv4Packet(getNextFrameID(), ipAddress, destPort, sourcePort, protocol, closeSocket ? TXIPv4Packet.OPTIONS_CLOSE_SOCKET: TXIPv4Packet.OPTIONS_LEAVE_SOCKET_OPEN, data); sendAndCheckXBeePacket(xbeePacket, true); }</code><technical_language>above. Throw NullPointerException if protocol is null</technical_language>

Target:
private void sendIPDataAsyncImpl(Inet4Address ipAddress, int destPort, IPProtocol protocol, boolean closeSocket, byte[] data) throws XBeeException { if (ipAddress == null) throw new NullPointerException("IP address cannot be null"); if (protocol == null) throw new NullPointerException("Protocol cannot be null"); if (data == null) throw new NullPointerException("Data cannot be null"); if (destPort < 0 || destPort > 65535) throw new IllegalArgumentException("Destination port must be between 0 and 65535."); if (isRemote()) throw new OperationNotSupportedException("Cannot send IP data from a remote device."); int sourcePort = this.sourcePort; if (protocol != IPProtocol.UDP) sourcePort = 0; logger.debug(toString() + "Sending IP data asynchronously to {}:{} >> {}.", ipAddress, destPort, HexUtils.prettyHexString(data)); XBeePacket xbeePacket = new TXIPv4Packet(getNextFrameID(), ipAddress, destPort, sourcePort, protocol, closeSocket ? TXIPv4Packet.OPTIONS_CLOSE_SOCKET: TXIPv4Packet.OPTIONS_LEAVE_SOCKET_OPEN, data); sendAndCheckXBeePacket(xbeePacket, true); }