auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testNull() throws Throwable { byte[] b = new byte[8]; for (PDataType type : PDataType.values()) { try { type.toBytes(null); type.toBytes(null, b, 0); type.toObject(new byte[0],0,0); type.toObject(new byte[0],0,0, type); } catch (ConstraintViolationException e) { <START> if(type.isArrayType()) { <END> } else if (! (type.isFixedWidth() && e.getMessage().contains("may not be null"))) { fail(type + ":" + e); } } } }</code><technical_language>arrays declared fixed width right now? need change this, in phase 2. this a bit. need change logic in a places (as discovered!)</technical_language>

Target:
public void testNull() throws Throwable { byte[] b = new byte[8]; for (PDataType type : PDataType.values()) { try { if (!type.isArrayType()) { type.toBytes(null); type.toBytes(null, b, 0); type.toObject(new byte[0], 0, 0); type.toObject(new byte[0], 0, 0, type); } else { type.toBytes(new PhoenixArray()); type.toBytes(new PhoenixArray(), b, 0); type.toObject(new byte[0], 0, 0); type.toObject(new byte[0], 0, 0, type); } } catch (ConstraintViolationException e) { if (!type.isArrayType() && ! ( type.isFixedWidth() && e.getMessage().contains("may not be null"))) { fail(type + ":" + e); } } } }
Source:
<code>public void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo) { TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo); for (TmfFixedArray<String> path : paths) <START> ++(getOrCreate(path).getValue().nbEventsInTimeRange); <END> paths = getTypePaths(event, extraInfo); for (TmfFixedArray<String> path : paths) ++(getOrCreate(path).getValue().nbEventsInTimeRange); }</code><technical_language>Hmm, this I like, a getter for writing a value. add .incrementValue() method something</technical_language>

Target:
public void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo) { TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo); for (TmfFixedArray<String> path : paths) { ++(getOrCreate(path).getValue().nbEventsInTimeRange); } paths = getTypePaths(event, extraInfo); for (TmfFixedArray<String> path : paths) { ++(getOrCreate(path).getValue().nbEventsInTimeRange); } }
Source:
<code>private void invokeListener(Byte plc, GridMessageListener lsnr, UUID nodeId, Object msg, UUID secSubjId) { Byte oldPlc = CUR_PLC.get(); boolean change = !F.eq(oldPlc, plc); if (change) CUR_PLC.set(plc); <START> UUID curSecSubjId = secSubjId != null ? secSubjId : nodeId; <END> try(SecurityContextHolder s = ctx.security().replaceContext(curSecSubjId)) { lsnr.onMessage(nodeId, msg, plc); } finally { if (change) CUR_PLC.set(oldPlc); } }</code><technical_language>naming is confusing. This variable newSecSubjId. rename it, please</technical_language>

Target:
private void invokeListener(Byte plc, GridMessageListener lsnr, UUID nodeId, Object msg, UUID secSubjId) { Byte oldPlc = CUR_PLC.get(); boolean change = !F.eq(oldPlc, plc); if (change) CUR_PLC.set(plc); UUID newSecSubjId = secSubjId != null ? secSubjId : nodeId; try(OperationSecurityContext s = ctx.security().withContext(newSecSubjId)) { lsnr.onMessage(nodeId, msg, plc); } finally { if (change) CUR_PLC.set(oldPlc); } }
Source:
<code>public void editJdbcStoreDatasource() throws Exception { page.navigate(); page.switchToStore(); final String datasource = createDatasource(); try { new ConfigChecker.Builder(client, TRANSACTIONS_ADDRESS) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.TEXT, JDBC_STATE_STORE_TABLE_PREFIX, datasource) .verifyFormSaved() .verifyAttribute(JDBC_STATE_STORE_TABLE_PREFIX, datasource); } finally { <START> client.apply(new RemoveDataSource(datasource)); <END> } }</code><technical_language>I suggest removing datasource is in configuration</technical_language>

Target:
public void editJdbcStoreDatasource() throws Exception { page.navigate(); page.switchToStore(); final String datasource = createDatasource(); new ConfigChecker.Builder(client, TRANSACTIONS_ADDRESS) .configFragment(page.getConfigFragment()) .editAndSave(ConfigChecker.InputType.TEXT, JDBC_STORE_DATASOURCE, datasource) .verifyFormSaved() .verifyAttribute(JDBC_STORE_DATASOURCE, datasource); }
Source:
<code>public void testPush() throws Exception { ObjectApi objectApi = EasyMock.createStrictMock(ObjectApi.class); EasyMock.expect(objectApi.put(EasyMock.anyString(), EasyMock.<Payload>anyObject())).andReturn(null).atLeastOnce(); EasyMock.replay(objectApi); CloudFilesApi api = EasyMock.createStrictMock(CloudFilesApi.class); EasyMock.expect(api.getObjectApi(EasyMock.anyString(), EasyMock.anyString())) .andReturn(objectApi) .atLeastOnce(); EasyMock.replay(api); CloudFilesDataSegmentPusherConfig config = new CloudFilesDataSegmentPusherConfig(); config.region = "region"; config.container = "container"; config.basePath = "basePath"; CloudFilesDataSegmentPusher pusher = new CloudFilesDataSegmentPusher(api, config, new DefaultObjectMapper()); <START> File tmpDir = Files.createTempDir(); <END> tmpDir.deleteOnExit(); File tmp = new File(tmpDir, "version.bin"); tmp.deleteOnExit(); final byte[] data = new byte[]{0x0, 0x0, 0x0, 0x1}; Files.write(data, tmp); final long size = data.length; DataSegment segmentToPush = new DataSegment( "foo", new Interval("2015/2016"), "0", Maps.<String, Object>newHashMap(), Lists.<String>newArrayList(), Lists.<String>newArrayList(), new NoneShardSpec(), 0, size ); DataSegment segment = pusher.push(tmpDir, segmentToPush); EasyMock.verify(api); }</code><technical_language>create TemporaryFolder</technical_language>

Target:
public void testPush() throws Exception { ObjectApi objectApi = EasyMock.createStrictMock(ObjectApi.class); EasyMock.expect(objectApi.put(EasyMock.anyString(), EasyMock.<Payload>anyObject())).andReturn(null).atLeastOnce(); EasyMock.replay(objectApi); CloudFilesApi api = EasyMock.createStrictMock(CloudFilesApi.class); EasyMock.expect(api.getObjectApi(EasyMock.anyString(), EasyMock.anyString())) .andReturn(objectApi) .atLeastOnce(); EasyMock.replay(api); CloudFilesDataSegmentPusherConfig config = new CloudFilesDataSegmentPusherConfig(); config.setRegion("region"); config.setContainer("container"); config.setBasePath("basePath"); CloudFilesDataSegmentPusher pusher = new CloudFilesDataSegmentPusher(api, config, new DefaultObjectMapper()); File tmp = tempFolder.newFile("version.bin"); final byte[] data = new byte[]{0x0, 0x0, 0x0, 0x1}; Files.write(data, tmp); final long size = data.length; DataSegment segmentToPush = new DataSegment( "foo", new Interval("2015/2016"), "0", Maps.<String, Object>newHashMap(), Lists.<String>newArrayList(), Lists.<String>newArrayList(), new NoneShardSpec(), 0, size ); DataSegment segment = pusher.push(tempFolder.getRoot(), segmentToPush); Assert.assertEquals(segmentToPush.getSize(), segment.getSize()); EasyMock.verify(api); }
Source:
<code>public Transaction beginTransaction(MuleContext muleContext) throws TransactionException { <START> return null; <END> }</code><technical_language>delegate new method</technical_language>

Target:
public Transaction beginTransaction(MuleContext muleContext) { try { return beginTransaction(muleContext.getConfiguration().getId(), ((MuleContextWithRegistry) muleContext).getRegistry().lookupObject(NotificationDispatcher.class), muleContext.getTransactionFactoryManager(), muleContext.getTransactionManager(), mockTransaction.getTimeout()); } catch (Exception e) { throw new RuntimeException(); } }
Source:
<code>public void testCreateTopicsPartialResponse() throws Exception { try (AdminClientUnitTestEnv env = mockClientEnv()) { env.kafkaClient().setNodeApiVersions(NodeApiVersions.create()); env.kafkaClient().prepareResponse(body -> body instanceof CreateTopicsRequest, prepareCreateTopicsResponse("myTopic", Errors.NONE)); CreateTopicsResult topicsResult = env.adminClient().createTopics( asList(new NewTopic("myTopic", Collections.singletonMap(0, asList(0, 1, 2))), <START> new NewTopic("myTopic2", Collections.singletonMap(0, asList(0, 1, 2)))), <END> new CreateTopicsOptions().timeoutMs(10000)); topicsResult.values().get("myTopic").get(); try { topicsResult.values().get("myTopic2").get(); fail("Expected an exception."); } catch (ExecutionException e) { assertTrue("Expected an ExecutionException wrapping an ApiException, but got " + Utils.stackTrace(e), e.getCause() instanceof ApiException); } } }</code><technical_language>nit: align new above</technical_language>

Target:
public void testCreateTopicsPartialResponse() throws Exception { try (AdminClientUnitTestEnv env = mockClientEnv()) { env.kafkaClient().setNodeApiVersions(NodeApiVersions.create()); env.kafkaClient().prepareResponse(body -> body instanceof CreateTopicsRequest, prepareCreateTopicsResponse("myTopic", Errors.NONE)); CreateTopicsResult topicsResult = env.adminClient().createTopics( asList(new NewTopic("myTopic", Collections.singletonMap(0, asList(0, 1, 2))), new NewTopic("myTopic2", Collections.singletonMap(0, asList(0, 1, 2)))), new CreateTopicsOptions().timeoutMs(10000)); topicsResult.values().get("myTopic").get(); TestUtils.assertFutureThrows(topicsResult.values().get("myTopic2"), ApiException.class); } }
Source:
<code>private void copyAllMemoryImages(Guid containerId) { for (String memoryVolumes : MemoryUtils.getMemoryVolumesFromSnapshots(getVm().getSnapshots())) { List<Guid> guids = Guid.createGuidListFromString(memoryVolumes); ActionReturnValue vdcRetValue = runInternalActionWithTasksContext( ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage( containerId, guids.get(0), guids.get(2), guids.get(3))); if (!vdcRetValue.getSucceeded()) { throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy memory image"); } <START> getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList()); <END> vdcRetValue = runInternalActionWithTasksContext( ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryConfImage( containerId, guids.get(0), guids.get(4), guids.get(5))); if (!vdcRetValue.getSucceeded()) { throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy metadata image"); } getReturnValue().getVdsmTaskIdList().addAll(vdcRetValue.getInternalVdsmTaskIdList()); } }</code><technical_language>I assume behavior ExportVmCommand. Do need this</technical_language>

Target:
private void copyAllMemoryImages(Guid containerId) { for (String memoryVolumes : MemoryUtils.getMemoryVolumesFromSnapshots(getVm().getSnapshots())) { List<Guid> guids = Guid.createGuidListFromString(memoryVolumes); ActionReturnValue vdcRetValue = runInternalActionWithTasksContext( ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryDumpImage( containerId, guids.get(0), guids.get(2), guids.get(3))); if (!vdcRetValue.getSucceeded()) { throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy memory image"); } getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList()); vdcRetValue = runInternalActionWithTasksContext( ActionType.CopyImageGroup, buildMoveOrCopyImageGroupParametersForMemoryConfImage( containerId, guids.get(0), guids.get(4), guids.get(5))); if (!vdcRetValue.getSucceeded()) { throw new EngineException(vdcRetValue.getFault().getError(), "Failed to copy metadata image"); } getTaskIdList().addAll(vdcRetValue.getVdsmTaskIdList()); } }
Source:
<code>public void afterSend(long start, boolean result) { if (start > 0) { <START> long now = System.currentTimeMillis(); <END> long elapsed = now - start; if (result && this.fullStatsEnabled) { sendSuccessRatio.success(); sendDuration.append(elapsed); } else { if (this.fullStatsEnabled) { sendSuccessRatio.failure(); sendErrorCount.incrementAndGet(); } sendErrorRate.increment(); } if (logger.isTraceEnabled()) { logger.trace("Elapsed: " + this.name + ": " + elapsed); } } }</code><technical_language>this withing if (result && this.fullStatsEnabled) well</technical_language>

Target:
public void afterSend(long start, boolean result) { if (start > 0) { long now = System.currentTimeMillis(); long elapsed = now - start; if (result && this.fullStatsEnabled) { sendSuccessRatio.success(now); sendDuration.append(elapsed); } else { if (this.fullStatsEnabled) { sendSuccessRatio.failure(now); sendErrorCount.incrementAndGet(); } sendErrorRate.increment(); } if (logger.isTraceEnabled()) { logger.trace("Elapsed: " + this.name + ": " + elapsed); } } }
Source:
<code><START> ClassPathWriteToFileArg(BuildTarget target, String prefix, Arg delegate) { <END> super(target, prefix, delegate); }</code><technical_language>Changes in this file unrelated, revert them</technical_language>

Target:
public ClassPathWriteToFileArg(BuildTarget target, String prefix, Arg delegate) { super(target, prefix, delegate); }
Source:
<code>public ExpressionsUpdateEtagTrigger() { <START> super("portal.expressions_etags", 9); <END> }</code><technical_language>9</technical_language>

Target:
public ExpressionsUpdateEtagTrigger() { super(ExpressionEtags::incrementEtag, 9); }
Source:
<code>public static int convert(String num) { <START> if (num == null) { <END> return 1; } switch (num) { case "I": return 1; case "II": return 2; case "III": return 3; default: throw new RuntimeException("unknown roman numeral \"" + num + "\""); } }</code><technical_language>null case happen, a chapter indicator there, please remove this</technical_language>

Target:
public static int convert(String num) { switch (num) { case "I": return 1; case "II": return 2; case "III": return 3; default: throw new RuntimeException("unknown roman numeral \"" + num + "\""); } }
Source:
<code>public void add(double value, double weight) { checkArgument(!isNaN(value), "value is NaN"); checkArgument(!isNaN(weight), "weight is NaN"); <START> if (centroidCount == means.length) { <END> if (means.length < maxSize) { ensureCapacity(Math.min(means.length * 2, maxSize)); } else { merge(internalCompressionFactor(compression)); } } means[centroidCount] = value; weights[centroidCount] = weight; centroidCount++; totalWeight += weight; min = Math.min(value, min); max = Math.max(value, max); needsMerge = true; }</code><technical_language>Do want allow infinity for these</technical_language>

Target:
public void add(double value, double weight) { checkArgument(!isNaN(value), "value is NaN"); checkArgument(!isNaN(weight), "weight is NaN"); checkArgument(!isInfinite(value), "value must be finite"); checkArgument(!isInfinite(weight), "weight must be finite"); if (centroidCount == means.length) { if (means.length < maxSize) { ensureCapacity(Math.min(means.length * 2, maxSize)); } else { merge(internalCompressionFactor(compression)); } } means[centroidCount] = value; weights[centroidCount] = weight; centroidCount++; totalWeight += weight; min = Math.min(value, min); max = Math.max(value, max); needsMerge = true; }
Source:
<code>public static RexNode removeCast(RexNode e) { for (;;) { switch (e.getKind()) { case CAST: RelDataType destType = e.getType(); e = ((RexCall) e).operands.get(0); if (!SqlTypeUtil.canCastFrom(destType, e.getType(), true)) { <START> throw new UnsupportedOperationException( <END> String.format( Locale.ROOT, "Cannot cast %s to %s", e.getType().getSqlTypeName(), destType.getSqlTypeName())); } break; default: return e; } } }</code><technical_language>AFAIK, removeCast remove redundant casts, remove casts, i add a SqlTypeUtil.canCastFrom check throws exception. is invoker apply rules</technical_language>

Target:
public static RexNode removeCast(RexNode e) { for (;;) { switch (e.getKind()) { case CAST: e = ((RexCall) e).operands.get(0); break; default: return e; } } }
Source:
<code>public final GraphFactory<V> getFactory(final String graphLibrary) { <START> if ("JGraphT".equalsIgnoreCase(graphLibrary)) { <END> return new JGraphTGraphFactory<V>(); } throw new IllegalArgumentException(); }</code><technical_language>constant</technical_language>

Target:
public static <V extends Comparable<V>> GraphFactory<V> getFactory( final String graphLibrary) { if (JGRAPHT.equalsIgnoreCase(graphLibrary)) { return new JGraphTGraphFactory<V>(); } throw new IllegalArgumentException(); }
Source:
<code>public void validateSystemTag(String resourceUuid, String resourceType, String tag) { boolean checked = false; for (SystemTag stag : systemTags) { if (stag.isMatch(tag)) { checked = true; stag.validate(resourceUuid, resourceTypeClassMap.get(resourceType), tag); } } if (!checked) { throw new ApiMessageInterceptionException(errf.stringToInvalidArgumentError( String.format("no system tag matches %s", tag) )); } <START> queryDbValidate(resourceUuid, resourceType); <END> }</code><technical_language>checkIfResoruceHasThisTagType</technical_language>

Target:
public void validateSystemTag(String resourceUuid, String resourceType, String tag) { boolean checked = false; for (SystemTag stag : systemTags) { if (stag.isMatch(tag)) { checked = true; stag.validate(resourceUuid, resourceTypeClassMap.get(resourceType), tag); } } if (!checked) { throw new ApiMessageInterceptionException(errf.stringToInvalidArgumentError( String.format("no system tag matches %s", tag) )); } checkIfResourceHasThisTagType(resourceUuid, resourceType); }
Source:
<code>public void removeConnection(final INode nodeToRemove) { if (nodeToRemove.equals(this.node)) { <START> throw new IllegalArgumentException("Cant remove yourself!"); <END> } notifyPlayerRemoval(nodeToRemove); final SocketChannel channel = nodeToChannel.remove(nodeToRemove); if (channel == null) { log.warning("Could not find node to remove: " + nodeToRemove); return; } channelToNode.remove(channel); nioSocket.close(channel); notifyConnectionsChanged(false, nodeToRemove); log.info("Connection removed:" + nodeToRemove); }</code><technical_language>suggestion throw new IllegalArgumentException("Can't remove yourself!");</technical_language>

Target:
public void removeConnection(final INode nodeToRemove) { if (nodeToRemove.equals(this.node)) { throw new IllegalArgumentException("Can't remove yourself!"); } notifyPlayerRemoval(nodeToRemove); final SocketChannel channel = nodeToChannel.remove(nodeToRemove); if (channel == null) { log.warning("Could not find node to remove: " + nodeToRemove); return; } channelToNode.remove(channel); nioSocket.close(channel); notifyConnectionsChanged(false, nodeToRemove); log.info("Connection removed:" + nodeToRemove); }
Source:
<code>private void submitIfAssigned(Committee[][] committees) { Committee.Index index = scanCommittees(validatorIdx, committees); if (index.isEmpty()) return; if (index.getCommitteeIdx() > 0) return; <START> long slotNumber = calcNextProposingSlot(proposer.getSlotNumber(System.currentTimeMillis()), <END> index.getSlotOffset()); if (slotNumber % index.getCommitteeSize() == index.getValidatorIdx()) { this.submit(slotNumber); } }</code><technical_language>move System.currentTimeMillis() source, sharding logic is dependant of time need some accuracy tweaks for in future whatever</technical_language>

Target:
private void submitIfAssigned(Committee[][] committees) { Committee.Index index = scanCommittees(validatorIdx, committees); if (index.isEmpty()) return; if (index.getCommitteeIdx() > 0) return; long slotNumber = calcNextProposingSlot(getCurrentSlotNumber(), index.getSlotOffset()); if (slotNumber % index.getCommitteeSize() == index.getValidatorIdx()) { this.submit(slotNumber); } }
Source:
<code>private void checkForCommonErrors(Type type) { final Class<?> clazz = toClass(type); if (clazz == null) { return; } if (clazz == Row.class) { throw extractionError( "Cannot extract a data type from a pure '%s' class. " + "Please use annotations to define field names and field types.", Row.class.getName()); } else if (clazz == Object.class) { throw extractionError( "Cannot extract a data type from a pure '%s' class. " + "Usually, this indicates that class information is missing or got lost. " + "Please specify a more concrete class or treat it as a RAW type.", Object.class.getName()); } else if (INTERNAL_DATA_STRUCTURES.contains(clazz)) { throw extractionError( <START> "Cannot extract a data type from a pure internal '%s' class. " + <END> "Please use annotations to define the logical type.", clazz.getName()); } else if (clazz.getName().startsWith("scala.Tuple")) { throw extractionError( "Scala tuples are not supported. Use case classes or '%s' instead.", Row.class.getName()); } else if (clazz.getName().startsWith("scala.collection")) { throw extractionError( "Scala collections are not supported. " + "See the documentation for supported classes or treat them as RAW types."); } }</code><technical_language>nit: parameterized types "pure internal"</technical_language>

Target:
private void checkForCommonErrors(Type type) { final Class<?> clazz = toClass(type); if (clazz == null) { return; } if (clazz == Row.class) { throw extractionError( "Cannot extract a data type from a pure '%s' class. " + "Please use annotations to define field names and field types.", Row.class.getName()); } else if (clazz == Object.class) { throw extractionError( "Cannot extract a data type from a pure '%s' class. " + "Usually, this indicates that class information is missing or got lost. " + "Please specify a more concrete class or treat it as a RAW type.", Object.class.getName()); } else if (INTERNAL_DATA_STRUCTURES.contains(clazz)) { throw extractionError( "Cannot extract a data type from an internal '%s' class without further information. " + "Please use annotations to define the full logical type.", clazz.getName()); } else if (clazz.getName().startsWith("scala.Tuple")) { throw extractionError( "Scala tuples are not supported. Use case classes or '%s' instead.", Row.class.getName()); } else if (clazz.getName().startsWith("scala.collection")) { throw extractionError( "Scala collections are not supported. " + "See the documentation for supported classes or treat them as RAW types."); } }
Source:
<code>public void onCreate(final MediaSessionService2 service) { MediaSession2 session; synchronized (mLock) { session = mSession; } if (session == null) { session = service.onCreateSession(); synchronized (mLock) { mSession = session; } } final MediaNotificationHandler notificationHandler = new MediaNotificationHandler(service); <START> mNotificationHandler = <END> notificationHandler; session.getCallback().setOnHandleForegroundServiceListener( new MediaSession2.SessionCallback.OnHandleForegroundServiceListener() { @Override public void onHandleForegroundService(int state) { notificationHandler.onHandleForegroundService(state); } }); }</code><technical_language>do clean this up</technical_language>

Target:
public void onCreate(final MediaSessionService2 service) { MediaSession2 session; synchronized (mLock) { session = mSession; } if (session == null) { session = service.onCreateSession(); if (session == null) { throw new RuntimeException("Session is null"); } synchronized (mLock) { mSession = session; } } mNotificationHandler = new MediaNotificationHandler(service); }
Source:
<code>public void testURLFormatter(){ String actual = Utils.urlConstructor(Utils.URL_CHUNK_ACCOUNTS, "12345"); assertEquals("<LINK_1>", actual); actual = Utils.urlConstructor(Utils.URL_CHUNK_COURSES, "45667"); <START> assertEquals("<LINK_2>",(actual)); <END> actual = Utils.urlConstructor(Utils.URL_CHUNK_COURSES,"34567",Utils.URL_CHUNK_COURSE_SIS_COURSE_ID,"cmmS12121"); assertEquals("<LINK_0>[sis_course_id]=cmmS12121",actual); }</code><technical_language>actual out parenthesis</technical_language>

Target:
public void testURLFormatter(){ String actual = Utils.urlConstructor(Utils.URL_CHUNK_ACCOUNTS, "12345"); assertEquals("<LINK_1>", actual); actual = Utils.urlConstructor(Utils.URL_CHUNK_COURSES, "45667"); assertEquals("<LINK_2>",actual); actual = Utils.urlConstructor(Utils.URL_CHUNK_COURSES,"34567",Utils.URL_CHUNK_COURSE_SIS_COURSE_ID,"cmmS12121"); assertEquals("<LINK_0>[sis_course_id]=cmmS12121",actual); }
Source:
<code>public String getColumnText(Object element, int columnIndex) { ControlFlowEntry entry = (ControlFlowEntry) element; <START> if (columnIndex == 0) { <END> return entry.getName(); } else if (columnIndex == 1) { return Integer.toString(entry.getThreadId()); } else if (columnIndex == 2) { if (entry.getParentThreadId() > 0) { return Integer.toString(entry.getParentThreadId()); } } else if (columnIndex == 3) { return Utils.formatTime(entry.getStartTime(), TimeFormat.CALENDAR, Resolution.NANOSEC); } else if (columnIndex == 4) { return entry.getTrace().getName(); } return ""; }</code><technical_language>static final variables instead of 0, 1, 2, 3, TID_COL, PTID_COL etc</technical_language>

Target:
public String getColumnText(Object element, int columnIndex) { ControlFlowEntry entry = (ControlFlowEntry) element; if (columnIndex == NAME_COL) { return entry.getName(); } else if (columnIndex == TID_COL) { return Integer.toString(entry.getThreadId()); } else if (columnIndex == PTID_COL) { if (entry.getParentThreadId() > 0) { return Integer.toString(entry.getParentThreadId()); } } else if (columnIndex == START_COL) { return Utils.formatTime(entry.getStartTime(), TimeFormat.CALENDAR, Resolution.NANOSEC); } else if (columnIndex == TRACE_COL) { return entry.getTrace().getName(); } return ""; }
Source:
<code>protected void createMainControl(Composite parent, IEEFFormContainer formContainer) { EEFWidgetFactory widgetFactory = formContainer.getWidgetFactory(); final int buttonWidth = 80; FormData buttonFormData = new FormData(); buttonFormData.left = new FormAttachment(0, LABEL_WIDTH); buttonFormData.width = buttonWidth; this.button = widgetFactory.createButton(parent, "DO IT", SWT.NONE); this.button.setLayoutData(buttonFormData); widgetFactory.paintBordersFor(parent); <START> if (!isEnabled()) { this.button.setEnabled(false); } <END> this.controller = new EEFControllersFactory().createButtonController(this.description, this.variableManager, this.interpreter, this.editingDomain); }</code><technical_language>this need done in refresh instead of creation of controls</technical_language>

Target:
protected void createMainControl(Composite parent, IEEFFormContainer formContainer) { EEFWidgetFactory widgetFactory = formContainer.getWidgetFactory(); final int buttonWidth = 80; FormData buttonFormData = new FormData(); buttonFormData.left = new FormAttachment(0, LABEL_WIDTH); buttonFormData.width = buttonWidth; this.button = widgetFactory.createButton(parent, "DO IT", SWT.NONE); this.button.setLayoutData(buttonFormData); widgetFactory.paintBordersFor(parent); this.controller = new EEFControllersFactory().createButtonController(this.description, this.variableManager, this.interpreter, this.editingDomain); }
Source:
<code>public Container next() { try { if (seekableStream.position() < (start >> 16)) { seekableStream.seek(start >> 16); } <START> if (seekableStream.position() > (end >> 16)) { <END> throw new RuntimeException("No more containers in this boundary."); } final long offset = seekableStream.position(); final Container c = ContainerIO.readContainer(cramHeader.getVersion(), seekableStream); c.offset = offset; return c; } catch (final IOException e) { throw new RuntimeIOException(e); } }</code><technical_language>I rework this if( !hasNext) { throw new NoSuchElementException("No more containers in this boundary") }</technical_language>

Target:
public Container next() { try { if (seekableStream.position() < (start >> 16)) { seekableStream.seek(start >> 16); } if (!hasNext()) { throw new RuntimeException("No more containers in this boundary."); } final long offset = seekableStream.position(); final Container c = ContainerIO.readContainer(cramHeader.getVersion(), seekableStream); c.offset = offset; return c; } catch (final IOException e) { throw new RuntimeIOException(e); } }
Source:
<code>private static void sortPending(List<PendingCert> pending) { Collections.sort(pending, new Comparator<PendingCert>() { @Override public int compare(PendingCert a, PendingCert b) { long c = a.ident.getWhen().getTime() - b.ident.getWhen().getTime(); <START> if (c == 0) { c = a.ident.getTimeZoneOffset() - b.ident.getTimeZoneOffset(); } <END> if (c > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } else if (c < Integer.MIN_VALUE) { return Integer.MIN_VALUE; } return (int) c; } }); }</code><technical_language>I rationale reason sort time zone offset</technical_language>

Target:
private static void sortPending(List<PendingCert> pending) { Collections.sort(pending, new Comparator<PendingCert>() { @Override public int compare(PendingCert a, PendingCert b) { return Long.signum( a.ident.getWhen().getTime() - b.ident.getWhen().getTime()); } }); }
Source:
<code>private static void createTableAndIndex() throws SQLException { schemaName = generateUniqueName(); dataTableName = generateUniqueName(); dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); <START> indexTableName = generateUniqueName(); <END> indexTableFullName = SchemaUtil.getTableName(schemaName, indexTableName); try (Connection conn = getConnection()) { incrementEdgeByOne(); conn.createStatement().execute(String.format(CREATE_TABLE_DDL, dataTableFullName)); conn.commit(); incrementEdgeByOne(); conn.createStatement().execute(String.format(CREATE_INDEX_DDL, indexTableName, dataTableFullName)); conn.commit(); } }</code><technical_language>nit: Add "I_" "D_" prefix</technical_language>

Target:
private static void createTableAndIndex() throws SQLException { schemaName = generateUniqueName(); dataTableName = "D_"+generateUniqueName(); dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); indexTableName = "I_"+generateUniqueName(); indexTableFullName = SchemaUtil.getTableName(schemaName, indexTableName); try (Connection conn = getConnection()) { incrementEdgeByOne(); conn.createStatement().execute(String.format(CREATE_TABLE_DDL, dataTableFullName)); conn.commit(); incrementEdgeByOne(); conn.createStatement().execute(String.format(CREATE_INDEX_DDL, indexTableName, dataTableFullName)); conn.commit(); } }
Source:
<code>public static <K> RocksDBKeyedStateBackendBuilder<K> builderForTestDefaults( File instanceBasePath, TypeSerializer<K> keySerializer) { final RocksDBResourceContainer optionsContainer = new RocksDBResourceContainer(); return new RocksDBKeyedStateBackendBuilder<>( "no-op", ClassLoader.getSystemClassLoader(), instanceBasePath, optionsContainer, stateName -> optionsContainer.getColumnOptions(), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), keySerializer, 2, new KeyGroupRange(0, 1), new ExecutionConfig(), TestLocalRecoveryConfig.disabled(), RocksDBStateBackend.PriorityQueueStateType.HEAP, TtlTimeProvider.DEFAULT, new UnregisteredMetricsGroup(), Collections.emptyList(), UncompressedStreamCompressionDecorator.INSTANCE, <START> new CloseableRegistry(), null); <END> }</code><technical_language>This change abandoned suggested refactor</technical_language>

Target:
public static <K> RocksDBKeyedStateBackendBuilder<K> builderForTestDefaults( File instanceBasePath, TypeSerializer<K> keySerializer) { final RocksDBResourceContainer optionsContainer = new RocksDBResourceContainer(); return new RocksDBKeyedStateBackendBuilder<>( "no-op", ClassLoader.getSystemClassLoader(), instanceBasePath, optionsContainer, stateName -> optionsContainer.getColumnOptions(), new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()), keySerializer, 2, new KeyGroupRange(0, 1), new ExecutionConfig(), TestLocalRecoveryConfig.disabled(), RocksDBStateBackend.PriorityQueueStateType.HEAP, TtlTimeProvider.DEFAULT, new UnregisteredMetricsGroup(), Collections.emptyList(), UncompressedStreamCompressionDecorator.INSTANCE, new CloseableRegistry()); }
Source:
<code>T focus() { <START> if (focusDelay > 0) { <END> focusDelayTimer.schedule(focusDelay); } else { focusDelayTimer.run(); } return cast(); }</code><technical_language>I notice elsewhere, if timer is running cancel first. need here</technical_language>

Target:
T focus() { cancelFocusTimer(); if (focusDelay > 0) { focusDelayTimer.schedule(focusDelay); } else { focusDelayTimer.run(); } return cast(); }
Source:
<code>public ListResponse listTags(final ListRequest request) throws ApiException { InfoResponse info = info(DtoFactory.getInstance() .createDto(InfoRequest.class) .withProjectPath(request.getProjectPath()) .withTarget(".") .withPassword(request.getPassword()) .withUsername(request.getUsername())); final List<String> args = defaultArgs(); args.add("list"); String repositoryRoot = getRepositoryRoot(info.getOutput()); String projectRelativeUrl = getRelativeUrl(info.getOutput()); String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl); String branchesPath = projectUri == null ? "^/tags" : (projectUri + "/tags"); final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(branchesPath), request.getUsername(), request.getPassword()); <START> return DtoFactory.getInstance().createDto(ListResponse.class) <END> .withCommand(result.getCommandLine().toString()) .withOutput(result.getStdout() .stream() .filter(s -> s.endsWith("/")) .map(s -> s.substring(0, s.length() - 1)) .collect(Collectors.toList())) .withErrorOutput(result.getStderr()); }</code><technical_language>DtoFactory.newDto(ListResponse)...</technical_language>

Target:
public ListResponse listTags(final ListRequest request) throws ApiException { InfoResponse info = info(newDto(InfoRequest.class).withProjectPath(request.getProjectPath()) .withTarget(".") .withPassword(request.getPassword()) .withUsername(request.getUsername())); final List<String> args = defaultArgs(); args.add("list"); String repositoryRoot = getRepositoryRoot(info.getOutput()); String projectRelativeUrl = getRelativeUrl(info.getOutput()); String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl); String branchesPath = projectUri == null ? "^/tags" : (projectUri + "/tags"); final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(branchesPath), request.getUsername(), request.getPassword()); return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()) .withOutput(result.getStdout() .stream() .filter(s -> s.endsWith("/")) .map(s -> s.substring(0, s.length() - 1)) .collect(Collectors.toList())) .withErrorOutput(result.getStderr()); }
Source:
<code>public SparkRemoteSourceOperatorFactory(int operatorId, PlanNodeId planNodeId, Iterator<PrestoSparkRow> iterator, List<Type> types) { this.operatorId = operatorId; this.planNodeId = requireNonNull(planNodeId, "planNodeId is null"); this.iterator = requireNonNull(iterator, "iterator is null"); <START> this.types = ImmutableList.copyOf(requireNonNull(types, "serde is null")); <END> }</code><technical_language>nit: types is null</technical_language>

Target:
public SparkRemoteSourceOperatorFactory(int operatorId, PlanNodeId planNodeId, Iterator<PrestoSparkRow> iterator, List<Type> types) { this.operatorId = operatorId; this.planNodeId = requireNonNull(planNodeId, "planNodeId is null"); this.iterator = requireNonNull(iterator, "iterator is null"); this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); }
Source:
<code>public void combineIngredients(State state, Domain domain, IngredientRecipe recipe, ObjectInstance container, String toswap) { Set<String> traits = new HashSet<String>(recipe.getTraits()); Set<String> ings = ContainerFactory.getContentNames(container); ObjectInstance new_ing = IngredientFactory.getNewComplexIngredientObjectInstance( domain.getObjectClass(IngredientFactory.ClassNameComplex), toswap, Recipe.NO_ATTRIBUTES, true, "",new TreeSet<String>(), new TreeSet<String>(), traits, ings); Set<ObjectInstance> hidden_copies = new HashSet<ObjectInstance>(); for (String name : ings) { ObjectInstance ob = state.getObject(name); hidden_copies.add(IngredientFactory.makeHiddenObjectCopy(state, domain, ob)); } ContainerFactory.removeContents(container); for (String name : ings) { state.removeObject(state.getObject(name)); } for (ObjectInstance ob : hidden_copies) { state.addObject(ob); } ContainerFactory.addIngredient(container, toswap); IngredientFactory.changeIngredientContainer(new_ing, container.getName()); ObjectInstance receivingSpace = state.getObject(ContainerFactory.getSpaceName(container)); if (SpaceFactory.isBaking(receivingSpace) && SpaceFactory.getOnOff(receivingSpace)) { IngredientFactory.bakeIngredient(new_ing); } else if (SpaceFactory.isHeating(receivingSpace) && SpaceFactory.getOnOff(receivingSpace)) { <START> IngredientFactory.heatIngredient(new_ing); <END> } state.addObject(new_ing); }</code><technical_language>camelCase</technical_language>

Target:
public void combineIngredients(State state, Domain domain, IngredientRecipe recipe, ObjectInstance container, String toswap) { Set<String> traits = new HashSet<String>(recipe.getTraits()); Set<String> ings = ContainerFactory.getContentNames(container); ObjectInstance newIng = IngredientFactory.getNewComplexIngredientObjectInstance( domain.getObjectClass(IngredientFactory.ClassNameComplex), toswap, Recipe.NO_ATTRIBUTES, true, "",new TreeSet<String>(), new TreeSet<String>(), traits, ings); Set<ObjectInstance> hiddenCopies = new HashSet<ObjectInstance>(); for (String name : ings) { ObjectInstance ob = state.getObject(name); hiddenCopies.add(IngredientFactory.makeHiddenObjectCopy(state, domain, ob)); } ContainerFactory.removeContents(container); for (String name : ings) { state.removeObject(state.getObject(name)); } for (ObjectInstance ob : hiddenCopies) { state.addObject(ob); } ContainerFactory.addIngredient(container, toswap); IngredientFactory.changeIngredientContainer(newIng, container.getName()); ObjectInstance receivingSpace = state.getObject(ContainerFactory.getSpaceName(container)); if (SpaceFactory.isBaking(receivingSpace) && SpaceFactory.getOnOff(receivingSpace)) { IngredientFactory.bakeIngredient(newIng); } else if (SpaceFactory.isHeating(receivingSpace) && SpaceFactory.getOnOff(receivingSpace)) { IngredientFactory.heatIngredient(newIng); } state.addObject(newIng); }
Source:
<code>private static Map<Locale, Set<String>> emailsByLocale(Set<PersistentGroup> groups, Predicate<String> emailValidator) { Map<Locale, Set<String>> emails = new HashMap<Locale, Set<String>>(); <START> Locale defLocale = I18N.getLocale(); <END> for (PersistentGroup group : groups) { for (User u : group.getMembers()) { UserProfile profile = u.getProfile(); Locale l = profile.getPreferredLocale(); if (l == null) { l = defLocale; } String email = profile.getEmail(); if (emailValidator.test(email)) { Set<String> localeEmails = emails.get(l); if (localeEmails == null) { localeEmails = new HashSet<>(); emails.put(l, localeEmails); } localeEmails.add(email); } } } return emails; }</code><technical_language>I this Locale.getDefault() instead. thinking assumes if a user preferred locale, he/she is satisfied default, such, in message is sent, in sender is currently in</technical_language>

Target:
private static Map<Locale, Set<String>> emailsByLocale(Set<PersistentGroup> groups, Predicate<String> emailValidator) { Map<Locale, Set<String>> emails = new HashMap<Locale, Set<String>>(); Locale defLocale = Locale.getDefault(); for (PersistentGroup group : groups) { for (User u : group.getMembers()) { UserProfile profile = u.getProfile(); Locale l = profile.getPreferredLocale(); if (l == null) { l = defLocale; } String email = profile.getEmail(); if (emailValidator.test(email)) { emails.computeIfAbsent(l, k -> new HashSet<>()).add(email); } } } return emails; }
Source:
<code>protected static final BenchmarksService createClient() { return AtlasDbFeignTargetFactory.createProxyWithFailover( Optional.empty(), ImmutableSet.of(BENCHMARK_SERVER), <START> 10_000, <END> 1_000_000, 1_000, BenchmarksService.class, "benchmarks"); }</code><technical_language>ugly magic numbers :(</technical_language>

Target:
protected static final BenchmarksService createClient() { return AtlasDbFeignTargetFactory.createProxyWithFailover( Optional.empty(), Optional.empty(), ImmutableSet.of(BENCHMARK_SERVER), 10_000, 1_000_000, 1_000, BenchmarksService.class, "benchmarks"); }
Source:
<code>private void deactivateThroughClient() throws Exception { GridClientConfiguration clientCfg = new GridClientConfiguration(); clientCfg.setServers(Collections.singletonList("127.0.0.1:11211")); try (GridClient client = GridClientFactory.start(clientCfg)) { GridClientClusterState state = client.state(); log.info(">>> Try to deactivate ..."); <START> state.state(ClusterState.INACTIVE, true); <END> } }</code><technical_language>static import used? previuos test</technical_language>

Target:
private void deactivateThroughClient() throws Exception { GridClientConfiguration clientCfg = new GridClientConfiguration(); clientCfg.setServers(Collections.singletonList("127.0.0.1:11211")); try (GridClient client = GridClientFactory.start(clientCfg)) { GridClientClusterState state = client.state(); log.info(">>> Try to deactivate ..."); state.state(INACTIVE, true); } }
Source:
<code>private RestResponse addCounter(RestRequest request) { try { String counterName = request.variables().get("counterName"); NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder(); CounterConfiguration configuration = counterManager.getConfiguration(counterName); if (configuration == null) { return responseBuilder.status(HttpResponseStatus.NOT_FOUND.code()).entity("Counter not found").build(); } else { ContentSource contents = request.contents(); long delta; if (contents == null) { delta = 1; } else { String s = contents.asString(); delta = Long.parseLong(s); } switch (configuration.type()) { case WEAK: <START> counterManager.getWeakCounter(counterName).add(delta); <END> break; case BOUNDED_STRONG: case UNBOUNDED_STRONG: long value = counterManager.getStrongCounter(counterName).addAndGet(delta).get(1, TimeUnit.MINUTES); responseBuilder.entity(Long.toString(value)); break; } return responseBuilder.header(HttpHeaderNames.CACHE_CONTROL.toString(), CacheControl.noCache()).build(); } } catch (Exception e) { throw new RestResponseException(e); } }</code><technical_language>I wait for add() complete. exception..</technical_language>

Target:
private RestResponse addCounter(RestRequest request) { try { String counterName = request.variables().get("counterName"); NettyRestResponse.Builder responseBuilder = new NettyRestResponse.Builder(); CounterConfiguration configuration = counterManager.getConfiguration(counterName); if (configuration == null) { return responseBuilder.status(HttpResponseStatus.NOT_FOUND.code()).entity("Counter not found").build(); } else { ContentSource contents = request.contents(); long delta; if (contents == null) { delta = 1; } else { String s = contents.asString(); delta = Long.parseLong(s); } switch (configuration.type()) { case WEAK: counterManager.getWeakCounter(counterName).add(delta).get(1, TimeUnit.MINUTES); break; case BOUNDED_STRONG: case UNBOUNDED_STRONG: long value = counterManager.getStrongCounter(counterName).addAndGet(delta).get(1, TimeUnit.MINUTES); responseBuilder.entity(Long.toString(value)); break; } return responseBuilder.header(HttpHeaderNames.CACHE_CONTROL.toString(), CacheControl.noCache()).build(); } } catch (Exception e) { throw new RestResponseException(e); } }
Source:
<code>public void setDynamicMdcFieldType(String fieldPattern, String type) { <START> final Pattern pattern = Pattern.compile(fieldPattern); <END> dynamicMdcFieldTypes.put(pattern, type); }</code><technical_language>Nit: need for final</technical_language>

Target:
public void setDynamicMdcFieldType(String fieldPattern, String type) { Pattern pattern = Pattern.compile(fieldPattern); setDynamicMdcFieldType(pattern, type); }
Source:
<code>public SubscriberIterator() { this.notifications = new LinkedBlockingQueue<Notification<? extends T>>(); <START> this.buf = null; <END> }</code><technical_language>Setting variables default construction is a no-op semantically instructions executed construction of object longer</technical_language>

Target:
public SubscriberIterator() { this.notifications = new LinkedBlockingQueue<Notification<? extends T>>(); }
Source:
<code>protected void verify_internal_effects() { <START> verify(strings).assertDoesNotContainIgnoringCase(getInfo(assertions), getActual(assertions), Arrays.array("od", "do")); <END> }</code><technical_language>static import array</technical_language>

Target:
protected void verify_internal_effects() { verify(strings).assertDoesNotContainIgnoringCase(getInfo(assertions), getActual(assertions), array("od", "do")); }
Source:
<code>protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); final ModelNode bufferSizeModel = BUFFER_SIZE.resolveModelAttribute(context, model); final ModelNode bufferPerSliceModel = BUFFER_PER_SLICE.resolveModelAttribute(context, model); final ModelNode directModel = DIRECT_BUFFERS.resolveModelAttribute(context, model); final int bufferSize = bufferSizeModel.isDefined() ? bufferSizeModel.asInt() : defaultBufferSize; final int bufferPerSlice = bufferPerSliceModel.isDefined() ? bufferPerSliceModel.asInt() : defaultBuffersPerRegion; final boolean direct = directModel.isDefined() ? directModel.asBoolean() : defaultDirectBuffers; final BufferPoolService service = new BufferPoolService(bufferSize, bufferPerSlice, direct); context.getCapabilityServiceTarget().addCapability(IO_POOL_RUNTIME_CAPABILITY, service) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); ByteBufferPoolService poolService = new ByteBufferPoolService(); context.getCapabilityServiceTarget().addCapability(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY, poolService) .addCapabilityRequirement(IO_POOL_RUNTIME_CAPABILITY.getDynamicName(address), Pool.class, poolService.bufferPool) <START> .setInitialMode(ServiceController.Mode.ACTIVE) <END> .install(); }</code><technical_language>this ON_DEMAND? question for existing one</technical_language>

Target:
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); final ModelNode bufferSizeModel = BUFFER_SIZE.resolveModelAttribute(context, model); final ModelNode bufferPerSliceModel = BUFFER_PER_SLICE.resolveModelAttribute(context, model); final ModelNode directModel = DIRECT_BUFFERS.resolveModelAttribute(context, model); final int bufferSize = bufferSizeModel.isDefined() ? bufferSizeModel.asInt() : defaultBufferSize; final int bufferPerSlice = bufferPerSliceModel.isDefined() ? bufferPerSliceModel.asInt() : defaultBuffersPerRegion; final boolean direct = directModel.isDefined() ? directModel.asBoolean() : defaultDirectBuffers; final BufferPoolService service = new BufferPoolService(bufferSize, bufferPerSlice, direct); context.getCapabilityServiceTarget().addCapability(IO_POOL_RUNTIME_CAPABILITY, service) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install(); ByteBufferPoolService poolService = new ByteBufferPoolService(); context.getCapabilityServiceTarget().addCapability(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY, poolService) .addCapabilityRequirement(IO_POOL_RUNTIME_CAPABILITY.getDynamicName(address), Pool.class, poolService.bufferPool) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install(); }