auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private URI endSessionEndpoint(OAuth2AuthenticationToken token) { String registrationId = token.getAuthorizedClientRegistrationId(); <START> ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId(registrationId); <END> Object endSessionEndpoint = clientRegistration.getProviderDetails().getConfigurationMetadata().get("end_session_endpoint"); URI result = null; if (endSessionEndpoint != null) { result = URI.create(endSessionEndpoint.toString()); } return result; }</code><technical_language>clientRegistration null. Please add a null check here</technical_language>

Target:
private URI endSessionEndpoint(OAuth2AuthenticationToken token) { String registrationId = token.getAuthorizedClientRegistrationId(); ClientRegistration clientRegistration = this.clientRegistrationRepository.findByRegistrationId(registrationId); URI result = null; if (clientRegistration != null) { Object endSessionEndpoint = clientRegistration.getProviderDetails().getConfigurationMetadata().get("end_session_endpoint"); if (endSessionEndpoint != null) { result = URI.create(endSessionEndpoint.toString()); } } return result; }
Source:
<code>public Set<String> getTags() { <START> return UnmodifiableSet.decorate(tags); <END> }</code><technical_language>apache-commons, java.util.Collections.unmodifiableSet(Set<? extends T>)</technical_language>

Target:
public Set<String> getTags() { return Collections.unmodifiableSet(tags); }
Source:
<code>public List<Task<? extends Serializable>> handle(Context context) throws SemanticException { String actualDbName; String actualTblName; <START> if (context.dmd.getDumpType() == DumpType.EVENT_DROP_TABLE) { <END> AlterTableMessage msg = deserializer.getAlterTableMessage(context.dmd.getPayload()); actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; actualTblName = msg.getTable(); } else { DropTableMessage msg = deserializer.getDropTableMessage(context.dmd.getPayload()); actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; actualTblName = msg.getTable(); } DropTableDesc dropTableDesc = new DropTableDesc( actualDbName + "." + actualTblName, null, true, true, context.eventOnlyReplicationSpec(), false ); Task<DDLWork2> dropTableTask = TaskFactory.get( new DDLWork2(readEntitySet, writeEntitySet, dropTableDesc), context.hiveConf ); context.log.debug( "Added drop tbl task : {}:{}", dropTableTask.getId(), dropTableDesc.getTableName() ); updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, null, null); return Collections.singletonList(dropTableTask); }</code><technical_language>I think, if flow is for EVENT_RENAME_DROP_TABLE else flow for EVENT_DROP_TABLE. incorrect here</technical_language>

Target:
public List<Task<? extends Serializable>> handle(Context context) throws SemanticException { String actualDbName; String actualTblName; if (context.dmd.getDumpType() == DumpType.EVENT_RENAME_DROP_TABLE) { AlterTableMessage msg = deserializer.getAlterTableMessage(context.dmd.getPayload()); actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; actualTblName = msg.getTable(); } else { DropTableMessage msg = deserializer.getDropTableMessage(context.dmd.getPayload()); actualDbName = context.isDbNameEmpty() ? msg.getDB() : context.dbName; actualTblName = msg.getTable(); } DropTableDesc dropTableDesc = new DropTableDesc( actualDbName + "." + actualTblName, null, true, true, context.eventOnlyReplicationSpec(), false ); Task<DDLWork> dropTableTask = TaskFactory.get( new DDLWork(readEntitySet, writeEntitySet, dropTableDesc), context.hiveConf ); context.log.debug( "Added drop tbl task : {}:{}", dropTableTask.getId(), dropTableDesc.getTableName() ); updatedMetadata.set(context.dmd.getEventTo().toString(), actualDbName, null, null); return Collections.singletonList(dropTableTask); }
Source:
<code>public synchronized PendingStatus uninstall() { ensureStarted(); <START> changeStatusToFrom(UNINSTALL_IN_PROGRESS, UNINSTALL_IN_PROGRESS, NONE); <END> this.pendingInstallationStatus = UNINSTALL_IN_PROGRESS; this.pendingEditionKey = null; this.pendingLicense = null; persistProperties(); return this.pendingInstallationStatus; }</code><technical_language>I state allow uninstall called twice. WS need support it</technical_language>

Target:
public synchronized PendingStatus uninstall() { ensureStarted(); changeStatusToFrom(UNINSTALL_IN_PROGRESS, UNINSTALL_IN_PROGRESS, NONE); checkState(currentEditionKey != null, "There is no edition currently installed"); this.pendingInstallationStatus = UNINSTALL_IN_PROGRESS; this.pendingEditionKey = null; this.pendingLicense = null; persistProperties(); return this.pendingInstallationStatus; }
Source:
<code><START> private void saveScriptAsFile(String path, Script<?> script, TaskContext taskContext) throws Throwable { <END> if (!path.contains(".")) { ScriptEngineFactory factory = new ScriptEngineManager().getEngineByName(script.getEngineName()) .getFactory(); String extension = factory.getExtensions().get(0); path = path + "." + extension; } String code = script.fetchScript().trim(); Path p = Paths.get(path); boolean isAbsolute = p.isAbsolute(); if (isAbsolute) { try (FileWriter fw = new FileWriter(new File(path))) { fw.write(code); } catch (IOException e) { throw new TaskException("Error writing script as file: " + path, e.getCause()); } } else { String uri = taskContext.getNodeDataSpaceURIs().getScratchURI(); try (FileWriter fw = new FileWriter(new File(uri, path))) { fw.write(code); } catch (IOException e) { throw new TaskException("Error writing script as file: " + path, e.getCause()); } } }</code><technical_language>![MAJOR](<LINK_0> 'Severity: MAJOR') Define throw a dedicated exception instead of a generic one. [![rule](<LINK_1>](<LINK_2></technical_language>

Target:
private void saveScriptAsFile(String path, Script<?> script, TaskContext taskContext) throws Throwable { if (!path.contains(".")) { ScriptEngineFactory factory = new ScriptEngineManager().getEngineByName(script.getEngineName()) .getFactory(); String extension = factory.getExtensions().get(0); path = path + "." + extension; } String code = script.fetchScript().trim(); Path p = Paths.get(path); boolean isAbsolute = p.isAbsolute(); if (isAbsolute) { try (FileWriter fw = new FileWriter(new File(path))) { fw.write(code); } catch (IOException e) { throw new TaskException("Error writing script as file: " + path, e); } } else { String uri = taskContext.getNodeDataSpaceURIs().getScratchURI(); try (FileWriter fw = new FileWriter(new File(uri, path))) { fw.write(code); } catch (IOException e) { throw new TaskException("Error writing script as file: " + path, e); } } }
Source:
<code>public void run() { try { logger.trace("Starting replica thread on Local node: " + dataNodeId + " Thread name: " + threadName); List<List<RemoteReplicaInfo>> replicasToReplicate = <START> new ArrayList<List<RemoteReplicaInfo>>(replicasToReplicateGroupedByNode.size()); <END> for (Map.Entry<DataNodeId, List<RemoteReplicaInfo>> replicasToReplicateEntry : replicasToReplicateGroupedByNode.entrySet()) { logger.info("Remote node: " + replicasToReplicateEntry.getKey() + " Thread name: " + threadName + " ReplicasToReplicate: " + replicasToReplicateEntry.getValue()); replicasToReplicate.add(replicasToReplicateEntry.getValue()); } logger.info("Begin iteration for thread " + threadName); while (running) { replicate(replicasToReplicate); lock.lock(); try { if (running && allDisabled) { pauseCondition.await(); } } catch (Exception e) { logger.error("Received interrupted exception during pause", e); } finally { lock.unlock(); } } } finally { running = false; shutdownLatch.countDown(); } }</code><technical_language>this line Java8 style editing this line</technical_language>

Target:
public void run() { try { logger.trace("Starting replica thread on Local node: " + dataNodeId + " Thread name: " + threadName); List<List<RemoteReplicaInfo>> replicasToReplicate = new ArrayList<>(replicasToReplicateGroupedByNode.size()); for (Map.Entry<DataNodeId, List<RemoteReplicaInfo>> replicasToReplicateEntry : replicasToReplicateGroupedByNode.entrySet()) { logger.info("Remote node: " + replicasToReplicateEntry.getKey() + " Thread name: " + threadName + " ReplicasToReplicate: " + replicasToReplicateEntry.getValue()); replicasToReplicate.add(replicasToReplicateEntry.getValue()); } logger.info("Begin iteration for thread " + threadName); while (running) { replicate(replicasToReplicate); lock.lock(); try { if (running && allDisabled) { pauseCondition.await(); } } catch (Exception e) { logger.error("Received interrupted exception during pause", e); } finally { lock.unlock(); } } } finally { running = false; shutdownLatch.countDown(); } }
Source:
<code><START> public void test_PFS() { <END> CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver(); s.add(new SearchKeywordResolver() { @Override public void resolve(SearchKeywordContext searchKeywordContext, UIComponent previous, String command) { } @Override public boolean matchKeyword(SearchExpressionContext searchExpressionContext, String command) { return command.startsWith("(") && command.endsWith(")"); } @Override public boolean isPassthrough(SearchExpressionContext searchExpressionContext, String command) { return true; } @Override public boolean isLeaf(SearchExpressionContext searchExpressionContext, String command) { return true; } }); UIComponent root = new UIPanel(); FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root); assertEquals("@(.myPanel #id)", resolveClientId(root, " @(.myPanel #id)")); SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null); Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id)")); Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id):test")); }</code><technical_language>I :)</technical_language>

Target:
public void test_PFS() { CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver(); s.add(new SearchKeywordResolver() { @Override public void resolve(SearchKeywordContext searchKeywordContext, UIComponent previous, String keyword) { } @Override public boolean isResolverForKeyword(SearchExpressionContext searchExpressionContext, String keyword) { return keyword.startsWith("(") && keyword.endsWith(")"); } @Override public boolean isPassthrough(SearchExpressionContext searchExpressionContext, String keyword) { return true; } @Override public boolean isLeaf(SearchExpressionContext searchExpressionContext, String keyword) { return true; } }); UIComponent root = new UIPanel(); FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root); assertEquals("@(.myPanel #id)", resolveClientId(root, " @(.myPanel #id)")); SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler(); SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null); Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id)")); Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id):test")); }
Source:
<code>public void testAUserCanCreateMeetingIfRoomIsAvailable() { HomeTabletPage home = new HomeTabletPage(); <START> home.clickScheduleBtn(); <END> schedule.createMeeting(organizer, subject, startTime, endTime, attendee, body, password); Assert.assertTrue(schedule.isMessageMeetingCreatedDisplayed()); }</code><technical_language>schedulePage = ho...</technical_language>

Target:
public void testAUserCanCreateMeetingIfRoomIsAvailable() { String startTime = meetingData.get(0).get("Start time"); String endTime = meetingData.get(0).get("End time"); String attendee = meetingData.get(0).get("Attendee"); String body = meetingData.get(0).get("Body"); HomeTabletPage homePage = new HomeTabletPage(); SchedulePage schedulePage = homePage.clickScheduleBtn(); schedulePage.createMeeting(organizer, subject, startTime, endTime, attendee, body, password); Assert.assertTrue(schedulePage.isMessageMeetingCreatedDisplayed()); }
Source:
<code>public void testGetVerifiedNegotiatedProposalWithUnrecogTransform() throws Exception { byte[] inputPacket = TestUtils.hexStringToByteArray(PROPOSAL_RAW_PACKET); mValidNegotiatedTransformSet[0] = new UnrecognizedTransform(-1, 1, new LinkedList<>()); Proposal.sTransformDecoder = new TransformDecoder() { <START> @Override public Transform[] decodeTransforms(int count, ByteBuffer inputBuffer) throws IkeException { byte[] temp = new byte[inputBuffer.remaining()]; inputBuffer.get(temp); return mValidNegotiatedTransformSet; } <END> }; IkeSaPayload respPayload = new IkeSaPayload(false, true, inputPacket); IkeSaPayload reqPayload = makeSaRequestPayload(); try { respPayload.getVerifiedNegotiatedProposal(reqPayload); fail("Expected to fail because negotiated proposal has unrecognized Transform."); } catch (NoValidProposalChosenException expected) { } }</code><technical_language>If this multiple times, worth considering a generator: TransformDecoder getDummyDecoder(Transform[] result){ return new TransformDecoder(){ ... return result; } };</technical_language>

Target:
public void testGetVerifiedNegotiatedProposalWithUnrecogTransform() throws Exception { byte[] inputPacket = TestUtils.hexStringToByteArray(PROPOSAL_RAW_PACKET); Transform[] negotiatedTransformSet = Arrays.copyOfRange( mValidNegotiatedTransformSet, 0, mValidNegotiatedTransformSet.length); negotiatedTransformSet[0] = new UnrecognizedTransform(-1, 1, new LinkedList<>()); Proposal.sTransformDecoder = getDummyTransformDecoder(negotiatedTransformSet); IkeSaPayload respPayload = new IkeSaPayload(false, true, inputPacket); IkeSaPayload reqPayload = makeSaRequestPayload(); try { respPayload.getVerifiedNegotiatedProposal(reqPayload); fail("Expected to fail because negotiated proposal has unrecognized Transform."); } catch (NoValidProposalChosenException expected) { } }
Source:
<code>private void initiateDataCopyTasks() throws SemanticException { TaskTracker taskTracker = new TaskTracker(conf.getIntVar(HiveConf.ConfVars.REPL_APPROX_MAX_LOAD_TASKS)); List<Task<?>> childTasks = new ArrayList<>(); childTasks.addAll(work.externalTableCopyTasks(taskTracker, conf)); childTasks.addAll(work.managedTableCopyTasks(taskTracker, conf)); if (childTasks.isEmpty()) { finishRemainingTasks(); } else { DAGTraversal.traverse(childTasks, new AddDependencyToLeaves(TaskFactory.get(work, conf))); <START> if (this.childTasks.isEmpty()) { <END> this.childTasks = childTasks; } else { this.childTasks.addAll(childTasks); } } }</code><technical_language>this.childTask null defualt? If so, ranger repl is configured, this lead NPE</technical_language>

Target:
private void initiateDataCopyTasks() throws SemanticException { TaskTracker taskTracker = new TaskTracker(conf.getIntVar(HiveConf.ConfVars.REPL_APPROX_MAX_LOAD_TASKS)); if (childTasks == null) { childTasks = new ArrayList<>(); } childTasks.addAll(work.externalTableCopyTasks(taskTracker, conf)); childTasks.addAll(work.managedTableCopyTasks(taskTracker, conf)); if (childTasks.isEmpty()) { finishRemainingTasks(); } else { DAGTraversal.traverse(childTasks, new AddDependencyToLeaves(TaskFactory.get(work, conf))); } }
Source:
<code>public void createUser(String userName) { try { DocumentModel userModel = userManager.getBareUserModel(); userModel.setProperty("user", "username", userName); <START> userModel.setProperty("user", "password", userName); <END> userManager.createUser(userModel); } catch (UserAlreadyExistsException e) { log.trace("User already exists", e); } }</code><technical_language>need password it</technical_language>

Target:
public void createUser(String userName) { try { DocumentModel userModel = userManager.getBareUserModel(); userModel.setProperty("user", "username", userName); userManager.createUser(userModel); } catch (UserAlreadyExistsException e) { log.trace("User already exists", e); } }
Source:
<code>public T getResource(){ <START> return super.getProperties().toObject(itemClassType); <END> }</code><technical_language>this result in double serialization (which fixed prior this PR)</technical_language>

Target:
public T getResource(){ return Utils.parse(responseBodyString, itemClassType); }
Source:
<code>public void testOnCallDisconnectCauseChangedWithoutPermission() throws Throwable { assertHasActiveSubcriptionId(); assertThat(mOnCallDisconnectCauseChangedCalled).isFalse(); mHandler.post(() -> { mListener = new TestPhoneStateListener(); try { <START> ShellIdentityUtils.invokeMethodWithShellPermissionsNoReturn(mTelephonyManager, (tm) -> tm.listen(mListener, PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES), "" ); <END> fail("SecurityException should throw."); } catch (SecurityException expected) { synchronized (mLock) { mSecurityExceptionThrown = true; mLock.notify(); } } }); synchronized (mLock) { if (!mSecurityExceptionThrown) { mLock.wait(WAIT_TIME); } } assertThat(mSecurityExceptionThrown).isTrue(); assertThat(mOnCallDisconnectCauseChangedCalled).isFalse(); }</code><technical_language>TelephonyManager directly? Shell is adopted a workaround for calling system API</technical_language>

Target:
public void testOnCallDisconnectCauseChangedWithoutPermission() throws Throwable { assertHasActiveSubcriptionId(); assertThat(mOnCallDisconnectCauseChangedCalled).isFalse(); mHandler.post(() -> { mListener = new TestPhoneStateListener(); try { mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES); fail("SecurityException should throw."); } catch (SecurityException expected) { synchronized (mLock) { mSecurityExceptionThrown = true; mLock.notify(); } } }); synchronized (mLock) { if (!mSecurityExceptionThrown) { mLock.wait(WAIT_TIME); } } assertThat(mSecurityExceptionThrown).isTrue(); assertThat(mOnCallDisconnectCauseChangedCalled).isFalse(); }
Source:
<code>@Test void testFieldOnNonStructExpression() { final RelBuilder builder = RelBuilder.create(config().build()); IllegalStateException ex = assertThrows(IllegalStateException.class, () -> { builder.scan("EMP") .project( builder.field(builder.field("EMPNO"), "abc")) .build(); }, "Field should fail since we are trying access a field on expression with non-struct type"); assertThat(ex.getMessage(), allOf(containsString("Trying to access field"), <START> containsString("in a type with no fields"))); <END> }</code><technical_language>is purpose split containsString</technical_language>

Target:
@Test void testFieldOnNonStructExpression() { final RelBuilder builder = RelBuilder.create(config().build()); IllegalStateException ex = assertThrows(IllegalStateException.class, () -> { builder.scan("EMP") .project( builder.field(builder.field("EMPNO"), "abc")) .build(); }, "Field should fail since we are trying access a field on expression with non-struct type"); assertThat(ex.getMessage(), is("Trying to access field abc in a type with no fields: SMALLINT")); }
Source:
<code>public void testCreateUserListInSpinner() { onBrickAtPosition(brickPosition).onVariableSpinner(R.id.insert_item_into_userlist_spinner) <START> .performNewVariableInitial(newList); <END> onBrickAtPosition(brickPosition).onVariableSpinner(R.id.insert_item_into_userlist_spinner) .checkShowsText(newList); }</code><technical_language>need address element twice, perform multiple checks operations in series: onBrickAtPosition(brickPosition).onVariableSpinner(R.id.insert_item_into_userlist_spinner) .performNewVariableInitial(newList); .checkShowsText(newList);</technical_language>

Target:
public void testCreateUserListInSpinner() { onBrickAtPosition(brickPosition).onVariableSpinner(R.id.insert_item_into_userlist_spinner) .performNewVariableInitial(newList) .checkShowsText(newList); }
Source:
<code>public void testScanConsumer() throws Exception { Scan scan = new Scan(); scan.setRowPrefixFilter(Bytes.toBytes(prefix)); SettableFuture<Integer> lock = SettableFuture.create(); getDefaultAsyncTable(executor).scan(scan, new ScanResultConsumer() { int count = 0; @Override public boolean onNext(Result result) { try { verify(result); count++; return true; } catch (Exception e) { lock.setException(e); return false; } } @Override public void onError(Throwable e) { lock.setException(e); } @Override public void onComplete() { lock.set(count); } }); <START> Assert.assertEquals(2, lock.get().intValue()); <END> }</code><technical_language>please rowKeys.length clearer 2 is coming</technical_language>

Target:
public void testScanConsumer() throws Exception { Scan scan = new Scan(); scan.setRowPrefixFilter(Bytes.toBytes(prefix)); SettableFuture<Integer> lock = SettableFuture.create(); getDefaultAsyncTable(executor).scan(scan, new ScanResultConsumer() { int count = 0; @Override public boolean onNext(Result result) { try { verify(result); count++; return true; } catch (Exception e) { lock.setException(e); return false; } } @Override public void onError(Throwable e) { lock.setException(e); } @Override public void onComplete() { lock.set(count); } }); Assert.assertEquals(rowKeys.length, lock.get().intValue()); }
Source:
<code>public void testInclusive() { InclusiveGateway gateway = new InclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); <START> Node<View<BaseGateway>, ?> node = mockNode(UUID, gateway); <END> when(propertyWriterFactory.of(any(org.eclipse.bpmn2.InclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); }</code><technical_language>need mock</technical_language>

Target:
public void testInclusive() { InclusiveGateway gateway = new InclusiveGateway(); gateway.getGeneral().getName().setValue(NAME); gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION); gateway.getExecutionSet().getDefaultRoute().setValue(DEFAULT_ROUTE); Node<View<BaseGateway>, ?> node = newNode(UUID, gateway); when(propertyWriterFactory.of(any(org.eclipse.bpmn2.InclusiveGateway.class))).thenReturn(gatewayPropertyWriter); assertEquals(gatewayPropertyWriter, converter.toFlowElement(node)); verifyCommonValues(gatewayPropertyWriter, node); verify(gatewayPropertyWriter).setDefaultRoute(DEFAULT_ROUTE); verify(gatewayPropertyWriter).setGatewayDirection(node); }
Source:
<code>public KafkaConsumerProxy(Consumer<K, V> kafkaConsumer, String systemName, String clientId, KafkaSystemConsumer.KafkaConsumerMessageSink messageSink, KafkaSystemConsumerMetrics samzaConsumerMetrics, String metricName) { <START> this.kafkaConsumer = kafkaConsumer; <END> this.systemName = systemName; this.sink = messageSink; this.kafkaConsumerMetrics = samzaConsumerMetrics; this.metricName = metricName; this.clientId = clientId; this.kafkaConsumerMetrics.registerClientProxy(metricName); consumerPollThread = new Thread(createProxyThreadRunnable()); consumerPollThread.setDaemon(true); consumerPollThread.setName( "Samza KafkaConsumerProxy Poll " + consumerPollThread.getName() + " - " + systemName); }</code><technical_language>Minor: Do add non-null Precondition checks for some arguments here</technical_language>

Target:
KafkaConsumerProxy(Consumer<K, V> kafkaConsumer, String systemName, String clientId, KafkaSystemConsumer.KafkaConsumerMessageSink messageSink, KafkaSystemConsumerMetrics samzaConsumerMetrics, String metricName) { this.kafkaConsumer = kafkaConsumer; this.systemName = systemName; this.sink = messageSink; this.kafkaConsumerMetrics = samzaConsumerMetrics; this.metricName = metricName; this.clientId = clientId; this.kafkaConsumerMetrics.registerClientProxy(metricName); consumerPollThread = new Thread(createProxyThreadRunnable()); consumerPollThread.setDaemon(true); consumerPollThread.setName( "Samza KafkaConsumerProxy Poll " + consumerPollThread.getName() + " - " + systemName); }
Source:
<code>public void query_processing_error_707() throws Exception { FindRequest fr=new FindRequest(); fr.setQuery(query("{'$and':["+ " {'$or':["+ " {'field':'field1','op':'=','rvalue':'f1value'},"+ " {'array':'refchild.*.array','elemMatch':{"+ " '$and':["+ " {'field':'field1','op':'=','rvalue':'value1'},"+ " {'field':'field2','regex':'value2'}"+ " ]"+ " }"+ " }"+ " ]},"+ " {'field':'refchild.*.refparent.*.field2','op':'=','rvalue':true}"+ "]}")); fr.setProjection(projection("[{'field':'*'},{'field':'refchild'}]")); fr.setEntityVersion(new EntityVersion("root_loop","1.0.0.")); Response response=mediator.find(fr); <START> System.out.println(response.getEntityData()); <END> }</code><technical_language>assert here</technical_language>

Target:
public void query_processing_error_707() throws Exception { FindRequest fr=new FindRequest(); fr.setQuery(query("{'$and':["+ " {'$or':["+ " {'field':'field1','op':'=','rvalue':'f1value'},"+ " {'array':'refchild.*.array','elemMatch':{"+ " '$and':["+ " {'field':'field1','op':'=','rvalue':'value1'},"+ " {'field':'field2','regex':'value2'}"+ " ]"+ " }"+ " }"+ " ]},"+ " {'field':'refchild.*.refparent.*.field2','op':'=','rvalue':true}"+ "]}")); fr.setProjection(projection("[{'field':'*'},{'field':'refchild'}]")); fr.setEntityVersion(new EntityVersion("root_loop","1.0.0.")); Response response=mediator.find(fr); System.out.println(response.getEntityData()); Assert.assertEquals(5,response.getMatchCount()); }
Source:
<code>public PresenterWidget(boolean autoBind, EventBus eventBus, V view) { super(autoBind); <START> if (view == null) { <END> throw new IllegalArgumentException("view cannot be null"); } this.eventBus = eventBus; this.view = view; }</code><technical_language>this happen</technical_language>

Target:
public PresenterWidget(boolean autoBind, EventBus eventBus, V view) { super(autoBind); assert view != null : "presenter view cannot be null"; this.eventBus = eventBus; this.view = view; }
Source:
<code>private Button createAction(CarMenuItem item) { Context context = getContext(); Button button = new Button(context, null, 0, item.getStyleResId()); CharSequence title = item.getTitle(); button.setText(title); if (item.getIcon() != null) { Drawable icon = item.getIcon().loadDrawable(context); icon.setBounds(0, 0, mActionButtonIconBound, mActionButtonIconBound); button.setCompoundDrawables(icon, null, null, null); if <START> (title != null && <END> !TextUtils.isEmpty(title)) { button.setCompoundDrawablePadding(mActionButtonPadding); } } button.setEnabled(item.isEnabled()); button.setOnClickListener(v -> { CarMenuItem.OnClickListener onClickListener = item.getOnClickListener(); if (onClickListener != null) { onClickListener.onClick(item); } }); return button; }</code><technical_language>need this null check; isEmpty() perform this check</technical_language>

Target:
private Button createAction(CarMenuItem item) { Context context = getContext(); Button button = new Button(context, null, 0, item.getStyleResId()); CharSequence title = item.getTitle(); button.setText(title); if (item.getIcon() != null) { Drawable icon = item.getIcon().loadDrawable(context); icon.setBounds(0, 0, mActionButtonIconBound, mActionButtonIconBound); button.setCompoundDrawables(icon, null, null, null); if (!TextUtils.isEmpty(title)) { button.setCompoundDrawablePadding(mActionButtonPadding); } } button.setEnabled(item.isEnabled()); button.setOnClickListener(v -> { CarMenuItem.OnClickListener onClickListener = item.getOnClickListener(); if (onClickListener != null) { onClickListener.onClick(item); } }); return button; }
Source:
<code>public void addLacComplete(int rc, LedgerHandle lh, Object ctx) { if (rc != BKException.Code.OK) { <START> LOG.warn("LastAddConfirmedUpdate failed: " + BKException.getMessage(rc)); <END> } else { LOG.debug("Callback LAC Updated for: ", lh.getId()); } }</code><technical_language>'{}' '+'</technical_language>

Target:
public void addLacComplete(int rc, LedgerHandle lh, Object ctx) { if (rc != BKException.Code.OK) { LOG.warn("LastAddConfirmedUpdate failed: ", BKException.getMessage(rc)); } else { LOG.debug("Callback LAC Updated for: ", lh.getId()); } }
Source:
<code>private ReportMetadataInfo populateReportMetadataInfo(ReportMetadataJson reportResponse) { if (reportResponse == null) { return null; } ReportMetadataInfo reportMetadataInfo = new ReportMetadataInfo(); <START> reportMetadataInfo.setId(reportResponse.getId()); <END> reportMetadataInfo.setTitle(reportResponse.getTitle()); reportMetadataInfo.setColumns(reportResponse.getColumns()); reportMetadataInfo.setFilters(reportResponse.getFilters()); return reportMetadataInfo; }</code><technical_language>constructor</technical_language>

Target:
private ReportMetadataInfo populateReportMetadataInfo(ReportMetadataJson reportResponse) { ReportMetadataInfo reportMetadataInfo = null; if (reportResponse != null) { reportMetadataInfo = new ReportMetadataInfo(reportResponse.getId(), reportResponse.getTitle(), reportResponse.getColumns(), reportResponse.getFilters()); } return reportMetadataInfo; }
Source:
<code>public void testSomeUser2() { List<Integer> lightData = Lists.newArrayList(); final URL userCSVFile = Resources.getResource("insights/bedlightduration/lightDataUser2.csv"); try { final String csvString = Resources.toString(userCSVFile, Charsets.UTF_8); final String[] lightDataStringList = csvString.replaceAll("\\s+","").split(","); for (String lightDataString : lightDataStringList) { lightData.add(Integer.parseInt(lightDataString)); } <START> } catch (IOException ioexception) { <END> ioexception.printStackTrace(); } List<Long> timeStamps = Lists.newArrayList(); final URL timeStampCSVFile = Resources.getResource("insights/bedlightduration/timeStampUser2.csv"); try { final String csvString = Resources.toString(timeStampCSVFile, Charsets.UTF_8); final String[] timeStampStringList = csvString.replaceAll("\\s+","").replaceAll("L","").split(","); for (String timeStampString : timeStampStringList) { timeStamps.add(Long.parseLong(timeStampString)); } } catch (IOException ioexception) { ioexception.printStackTrace(); } final List<DeviceData> deviceData = Lists.newArrayList(); for (int i = 0; i < lightData.size(); i++) { final int myHour = new DateTime(timeStamps.get(i), DateTimeZone.forOffsetMillis(-25200000)).getHourOfDay(); if (myHour > 21 || myHour < 4) { deviceData.add(createNewDeviceData(lightData.get(i), new DateTime(timeStamps.get(i)))); } } final int avgLightOn = BedLightDuration.getInsightsHelper(deviceData); assertThat(avgLightOn, is(0)); }</code><technical_language>test method throw IOException instead of try catch</technical_language>

Target:
public void testSomeUser2() throws IOException{ final List<Integer> lightData = readLightData("insights/bedlightduration/lightDataUser2.csv"); final List<Long> timeStamps = readTimeStamps("insights/bedlightduration/timeStampUser2.csv"); final List<DeviceData> deviceData = Lists.newArrayList(); for (int i = 0; i < lightData.size(); i++) { final int myHour = new DateTime(timeStamps.get(i), DateTimeZone.forOffsetMillis(-25200000)).getHourOfDay(); if (myHour > 21 || myHour < 4) { deviceData.add(createNewDeviceData(lightData.get(i), new DateTime(timeStamps.get(i)))); } } final int avgLightOn = BedLightDuration.getInsightsHelper(deviceData); assertThat(avgLightOn, is(0)); }
Source:
<code>protected void updateSamples() { calculateProbes(samples, dynamicLatencyProbeInterval); if (!StorageService.instance.isGossipActive()) return; <START> schedulePings(samples); <END> }</code><technical_language>stick probes? name scheduleProbes</technical_language>

Target:
protected void updateSamples() { long updateIntervalMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastUpdateSamplesNanos); lastUpdateSamplesNanos = System.nanoTime(); calculateProbes(samples, updateIntervalMillis); if (!StorageService.instance.isGossipActive()) return; scheduleProbes(samples); }
Source:
<code>public ModelAndView registerUser(@ModelAttribute Users user) { <START> user.setUserStatus("A"); <END> java.util.Date date = Calendar.getInstance().getTime(); user.setLastModifieddate(date); user.setRegistrationDate(date); System.out.println("9999"+user.getUserpii()); user.setUserId(user.getUserpii().getUserId()); user.getUserpii().setDateOfBirth(date); userService.insertRow(user); return new ModelAndView("user_creation", "user", new Users()); }</code><technical_language>A active? want insert record for signup inactive approved set active user</technical_language>

Target:
public ModelAndView registerUser(@ModelAttribute Users user) { user.setUserStatus("Inactive"); java.util.Date date = Calendar.getInstance().getTime(); user.setLastModifieddate(date); user.setRegistrationDate(date); System.out.println("9999"+user.getUserpii()); user.setUserId(user.getUserpii().getUserId()); user.getUserpii().setDateOfBirth(date); userService.insertRow(user); return new ModelAndView("user_creation", "user", new Users()); }
Source:
<code>private Map<String, String> filterHeaders(Map<String, String> headers, Set<String> filteredHeaderNames) { if (filteredHeaderNames.isEmpty()) { return ImmutableMap.of(); } return headers.entrySet().stream() <START> .filter(e -> filteredHeaderNames.stream().anyMatch(h -> h.equalsIgnoreCase(e.getKey()))) <END> .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }</code><technical_language>filteredHeaderNames put a case insensitive TreeSet? this nested loop converted a contains</technical_language>

Target:
private Map<String, String> filterHeaders(Map<String, String> headers, Set<String> filteredHeaderNames) { if (filteredHeaderNames.isEmpty()) { return ImmutableMap.of(); } return headers.entrySet().stream() .filter(e -> filteredHeaderNames.contains(e.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
Source:
<code>private static String getObaRegionName() { String regionName = null; ObaRegion region = Application.get().getCurrentRegion(); if (region != null && region.getName() != null) { regionName = region.getName(); } else if (Application.get().getCustomApiUrl() != null) { MessageDigest digest = null; try { digest = MessageDigest.getInstance("SHA-1"); digest.update(Application.get().getCustomApiUrl().getBytes()); <START> regionName = Application.getHex(digest.digest()); <END> } catch (Exception e) { regionName = Application.get().getString(R.string.analytics_label_custom_url); } } else { regionName = Application.get().getString(R.string.analytics_label_custom_url); } return regionName; }</code><technical_language>I hashed custom API prefixed R.string.analytics_label_custom_url? This allow return a list (or count) of custom APIs seen. So, CUSTOM_URL=8nh2j02f.... Otherwise, if SHA-1 hash, need filter for custom API URLs region names, harder implement/maintain</technical_language>

Target:
private static String getObaRegionName() { String regionName = null; ObaRegion region = Application.get().getCurrentRegion(); if (region != null && region.getName() != null) { regionName = region.getName(); } else if (Application.get().getCustomApiUrl() != null) { MessageDigest digest = null; try { digest = MessageDigest.getInstance("SHA-1"); digest.update(Application.get().getCustomApiUrl().getBytes()); regionName = Application.get().getString(R.string.analytics_label_custom_url) + ": " + Application.getHex(digest.digest()); } catch (Exception e) { regionName = Application.get().getString(R.string.analytics_label_custom_url); } } else { regionName = Application.get().getString(R.string.analytics_label_custom_url); } return regionName; }
Source:
<code>public void close() { synchronized (this) { <START> closed.set(true); <END> if (currentLogWatch != null) { currentLogWatch.close(); } } }</code><technical_language>need AtomicBoolean</technical_language>

Target:
public void close() { synchronized (this) { closed = true; if (currentLogWatch != null) { currentLogWatch.close(); } } }
Source:
<code>public void removeNode(final @Nonnull Node node) throws IOException { if (node == nodes.get(node.getNodeName())) { Queue.withLock(new Runnable() { @Override public void run() { Computer c = node.toComputer(); if (c != null) { c.recordTermination(); c.disconnect(OfflineCause.create(hudson.model.Messages._Hudson_NodeBeingRemoved())); for(Executor executor: c.getAllExecutors()){ executor.interrupt(Result.ABORTED, new CauseOfInterruption() { @Override public String getShortDescription() { <START> return "Node was removed by " + User.current().getId(); <END> } }); } } if (node == nodes.remove(node.getNodeName())) { jenkins.updateComputerList(); jenkins.trimLabels(); } } }); Util.deleteRecursive(new File(getNodesDir(), node.getNodeName())); NodeListener.fireOnDeleted(node); } }</code><technical_language>NPE</technical_language>

Target:
public void removeNode(final @Nonnull Node node) throws IOException { if (node == nodes.get(node.getNodeName())) { Queue.withLock(new Runnable() { @Override public void run() { Computer c = node.toComputer(); if (c != null) { c.recordTermination(); c.disconnect(OfflineCause.create(hudson.model.Messages._Hudson_NodeBeingRemoved())); for(Executor executor: c.getAllExecutors()){ executor.interrupt(Result.ABORTED, new CauseOfInterruption() { @Override public String getShortDescription() { return "Node was removed by " + (User.current() == null ? "(no user)" : User.current().getId()); } }); } } if (node == nodes.remove(node.getNodeName())) { jenkins.updateComputerList(); jenkins.trimLabels(); } } }); Util.deleteRecursive(new File(getNodesDir(), node.getNodeName())); NodeListener.fireOnDeleted(node); } }
Source:
<code>private void setupListener(AbstractMessageListenerContainer container, String queue) { Listeners listenersForQueue = this.listeners.get(queue); <START> if (listenersForQueue == null) { <END> this.listeners.put(queue, new Listeners(container.getMessageListener())); } else { listenersForQueue.listeners.add(container.getMessageListener()); } }</code><technical_language>A more functional way: computeIfAbsent(...).listeners.add(...)</technical_language>

Target:
private void setupListener(AbstractMessageListenerContainer container, String queue) { this.listeners.computeIfAbsent(queue, v -> new Listeners()).listeners.add(container.getMessageListener()); }
Source:
<code><START> Class getInputClass() { <END> return inputClass; }</code><technical_language>This is giving a raw-type generics warning. Suggest replacing Class Class<? extends InputKind>. This create some ripple effects a tricky... this is SDK-internal for now, leave annotate this type fully</technical_language>

Target:
Class<? extends Input> getInputClass() { return inputClass; }
Source:
<code>public List<BinaryContent> transform( Metacard metacard, String transformerId, Map<String, Serializable> requestProperties) throws CatalogTransformerException { if (metacard == null) { throw new IllegalArgumentException("Metacard is null."); } List<MultiMetacardTransformer> multiMetacardTransformers = frameworkProperties .getTransformerLocator() <START> .findMultiMetacardTransformersByFilter( <END> "(|" + "(" + Constants.SERVICE_SHORTNAME + "=" + transformerId + ")" + "(" + Constants.SERVICE_ID + "=" + transformerId + ")" + ")"); if (CollectionUtils.isEmpty(multiMetacardTransformers)) { throw new IllegalArgumentException("Transformer " + transformerId + " not found"); } return multiMetacardTransformers .get(0) .transform(Collections.singletonList(metacard), requestProperties); }</code><technical_language>find ID method logic. SERVICE_SHORTNAME is of registering a transformer SERVICE_ID is new way. able remove find filter this</technical_language>

Target:
public List<BinaryContent> transform( Metacard metacard, String transformerId, Map<String, Serializable> requestProperties) throws CatalogTransformerException { return frameworkProperties .getTransform() .transform(Collections.singletonList(metacard), transformerId, requestProperties); }
Source:
<code>public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if (viewType == TYPE_PARENT) { return onCreateParentViewHolder(viewGroup); } else if (viewType == TYPE_CHILD) { return onCreateChildViewHolder(viewGroup); } else { <START> return null; END> } }</code><technical_language>If get here, throw: throw new IllegalStateException() some such</technical_language>

Target:
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { if (viewType == TYPE_PARENT) { return onCreateParentViewHolder(viewGroup); } else if (viewType == TYPE_CHILD) { return onCreateChildViewHolder(viewGroup); } else { throw new IllegalStateException("Incorrect ViewType found"); } }
Source:
<code><START> public Boolean checkThatServerExists(String serverName) { <END> List<WebElement> webElements = loadPageDriverWait.until( visibilityOfAllElementsLocatedBy( By.xpath(" for (WebElement we : webElements) { if (we.getText().equals(serverName)) { return true; } } return false; }</code><technical_language>Do need Boolean here? primitive type boolean enough</technical_language>

Target:
public boolean checkThatServerExists(String serverName) { List<WebElement> webElements = loadPageDriverWait.until( visibilityOfAllElementsLocatedBy( By.xpath(" for (WebElement we : webElements) { if (we.getText().equals(serverName)) { return true; } } return false; }
Source:
<code>public int compare(Object obj1, Object obj2) { ItemType type1 = ItemTypeHelper.getOrderByItemType(obj1); ItemType type2 = ItemTypeHelper.getOrderByItemType(obj2); int cmp = Integer.compare(type1.getVal(), type2.getVal()); if (cmp != 0) { return cmp; } switch (type1) { case NoValue: case Null: return 0; case Boolean: return Boolean.compare((Boolean) obj1, (Boolean) obj2); case Number: return Double.compare(((Number) obj1).doubleValue(), ((Number) obj2).doubleValue()); case String: return ((String) obj1).compareTo((String) obj2); case ArrayNode: case ObjectNode: try{ UInt128 hash1 = DistinctHash.getHash(obj1); UInt128 hash2 = DistinctHash.getHash(obj2); return hash1.compareTo(hash2); } catch (IOException e) { <START> throw new IllegalStateException(String.format("Exception for getting has %s", e)); <END> } default: throw new ClassCastException(String.format("Unexpected type: %s", type1.toString())); } }</code><technical_language>exception message is correct passing arg need String.format %s</technical_language>

Target:
public int compare(Object obj1, Object obj2) { ItemType type1 = ItemTypeHelper.getOrderByItemType(obj1); ItemType type2 = ItemTypeHelper.getOrderByItemType(obj2); int cmp = Integer.compare(type1.getVal(), type2.getVal()); if (cmp != 0) { return cmp; } switch (type1) { case NoValue: case Null: return 0; case Boolean: return Boolean.compare((Boolean) obj1, (Boolean) obj2); case Number: return Double.compare(((Number) obj1).doubleValue(), ((Number) obj2).doubleValue()); case String: return ((String) obj1).compareTo((String) obj2); case ArrayNode: case ObjectNode: try{ UInt128 hash1 = DistinctHash.getHash(obj1); UInt128 hash2 = DistinctHash.getHash(obj2); return hash1.compareTo(hash2); } catch (IOException e) { throw new IllegalStateException(String.format("Getting hash exception for type %s ", type1.toString()), e); } default: throw new ClassCastException(String.format("Unexpected type: %s", type1.toString())); } }
Source:
<code>public static Deferred<TSMeta> parseFromColumn(final TSDB tsdb, final KeyValue column, final boolean load_uidmetas) { if (column.value() == null || column.value().length < 1) { throw new IllegalArgumentException("Empty column value"); } <START> final TSMeta parsedMeta = JSON.parseToObject(column.value(), TSMeta.class); <END> if (parsedMeta.tsuid == null || parsedMeta.tsuid.isEmpty()) { parsedMeta.tsuid = UniqueId.uidToString(column.key()); } Deferred<TSMeta> meta = getFromStorage(tsdb, UniqueId.stringToUid(parsedMeta.tsuid)); if (!load_uidmetas) { return meta; } return meta.addCallbackDeferring(new LoadUIDs(tsdb, parsedMeta.tsuid)); }</code><technical_language>Minor nitpick, parsed_meta :)</technical_language>

Target:
public static Deferred<TSMeta> parseFromColumn(final TSDB tsdb, final KeyValue column, final boolean load_uidmetas) { if (column.value() == null || column.value().length < 1) { throw new IllegalArgumentException("Empty column value"); } final TSMeta parsed_meta = JSON.parseToObject(column.value(), TSMeta.class); if (parsed_meta.tsuid == null || parsed_meta.tsuid.isEmpty()) { parsed_meta.tsuid = UniqueId.uidToString(column.key()); } Deferred<TSMeta> meta = getFromStorage(tsdb, UniqueId.stringToUid(parsed_meta.tsuid)); if (!load_uidmetas) { return meta; } return meta.addCallbackDeferring(new LoadUIDs(tsdb, parsed_meta.tsuid)); }
Source:
<code>public static PGType get(DataType type) { if (type instanceof CollectionType) { DataType<?> innerType = ((CollectionType) type).innerType(); if (innerType instanceof CollectionType) { return JsonType.INSTANCE; } else if (innerType.id() == ObjectType.ID) { <START> return PGArray.JSON_ARRAY; <END> } } else if (type.id() == ObjectType.ID) { return JsonType.INSTANCE; } PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; }</code><technical_language>this part for added a breaking changes entry in master</technical_language>

Target:
public static PGType get(DataType type) { if (type instanceof CollectionType) { DataType<?> innerType = ((CollectionType) type).innerType(); if (DataTypes.isCollectionType(innerType) || innerType.id() == ObjectType.ID) { return JsonType.INSTANCE; } } else if (type.id() == ObjectType.ID) { return JsonType.INSTANCE; } PGType pgType = CRATE_TO_PG_TYPES.get(type); if (pgType == null) { throw new IllegalArgumentException( String.format(Locale.ENGLISH, "No type mapping from '%s' to pg_type", type.getName())); } return pgType; }
Source:
<code>private static CorfuRuntime getRuntimeAndConnect(String configurationString) { return CorfuRuntime.fromParameters(CorfuRuntime.CorfuRuntimeParameters.builder() .useFastLoader(false) .cacheDisabled(true) .tlsEnabled(true) <START> .keyStore("/config/cluster-manager/corfu/private/keystore.jks") .ksPasswordFile("/config/cluster-manager/corfu/private/keystore.password") .trustStore("/config/cluster-manager/corfu/public/truststore.jks") .tsPasswordFile("/config/cluster-manager/corfu/public/truststore.password") <END> .build()) .parseConfigurationString(configurationString) .connect(); }</code><technical_language>files paths instead of a local file in resource folder</technical_language>

Target:
private static CorfuRuntime getRuntimeAndConnect(String configurationString) { return CorfuRuntime.fromParameters(CorfuRuntime.CorfuRuntimeParameters.builder() .useFastLoader(false) .cacheDisabled(true) .tlsEnabled(false) .build()) .parseConfigurationString(configurationString) .connect(); }
Source:
<code><START> public static void main( String[] args ) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException <END> { if (args.length == 0) { SelectMethod(); } else if (args.length == 1) { RunMethod(args[0]); return; } else { ShowUsage(); } System.out.println(""); System.out.print("Press <Return> to finish ..."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ int i = Integer.parseInt(br.readLine()); }catch(Exception ex) { } }</code><technical_language>This change is unacceptable. break existing Travis CI flows</technical_language>

Target:
public static void main( String[] args ) { if (args.length == 0) { SelectMethod(); } else if (args.length == 1) { RunMethod(args[0]); return; } else { ShowUsage(); } System.out.println(""); System.out.print("Press <Return> to finish ..."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ int i = Integer.parseInt(br.readLine()); }catch(Exception ex) { } }