auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void goToCorrectStart(RandomAccessFile rafile) throws IOException { if (rafile.readLine().startsWith("{\"data\":")) { rafile.seek(0); int data = 0; for (int nbBracket = 0; nbBracket < 2; nbBracket++) { data = rafile.read(); while (data != '[') { data = rafile.read(); if (data == -1) { return; } <START> } <END> } } else { rafile.seek(0); } }</code><technical_language>this char '[', is OK</technical_language>

Target:
public void goToCorrectStart(RandomAccessFile rafile) throws IOException { StringBuilder sb = new StringBuilder(); int val = rafile.read(); Set<Integer> skipList = new HashSet<>(); skipList.add((int) ':'); skipList.add((int) '\t'); skipList.add((int) '\n'); skipList.add((int) '\r'); skipList.add((int) ' '); skipList.add((int) '\b'); skipList.add((int) '\f'); while (val != -1 && val != ':' && sb.length() < 46) { if (!skipList.contains(val)) { sb.append((char) val); } val = rafile.read(); } if (sb.toString().startsWith("{\"data\"")) { int data = 0; for (int nbBracket = 0; nbBracket < 2 && data != -1; nbBracket++) { data = rafile.read(); while (data != '[' && data != -1) { data = rafile.read(); } } } else { rafile.seek(0); } }
Source:
<code>public int execute() throws HiveException { List<String> databases = null; if (ddlDesc.getPattern() != null) { LOG.debug("pattern: {}", ddlDesc.getPattern()); databases = db.getDatabasesByPattern(ddlDesc.getPattern()); } else { databases = db.getAllDatabases(); } LOG.info("Found database(s) matching the SHOW DATABASES statement.", databases.size()); DataOutputStream outStream = getOutputStream(ddlDesc.getResFile()); try { <START> formatter.showDatabases(outStream, databases); <END> } catch (Exception e) { throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show databases"); } finally { IOUtils.closeStream(outStream); } return 0; }</code><technical_language>a formatter for of operations; I guess formatter operations; I formatters "find" a new home</technical_language>

Target:
public int execute() throws HiveException { List<String> databases = null; if (desc.getPattern() != null) { LOG.debug("pattern: {}", desc.getPattern()); databases = context.getDb().getDatabasesByPattern(desc.getPattern()); } else { databases = context.getDb().getAllDatabases(); } LOG.info("Found database(s) matching the SHOW DATABASES statement.", databases.size()); DataOutputStream outStream = getOutputStream(new Path(desc.getResFile())); try { context.getFormatter().showDatabases(outStream, databases); } catch (Exception e) { throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show databases"); } finally { IOUtils.closeStream(outStream); } return 0; }
Source:
<code>public void visit(ModuleBuild moduleBuild) { SortedMap<String, Meter> meters = metricRegistry.getMeters(); <START> meters.get(moduleBuild.getClass().getName() + "." + moduleBuild.getState().toString().toLowerCase()).mark(); <END> }</code><technical_language>I prefer name() toString() for this in case overrides toString(). need pre-register meters, do metricRegistry.meter(metricName).mark() this method remove pre-registration form constructor</technical_language>

Target:
public void visit(ModuleBuild moduleBuild) { SortedMap<String, Meter> meters = metricRegistry.getMeters(); meters.get(makeMetricName(ModuleBuild.class, moduleBuild.getState())).mark(); }
Source:
<code>private boolean isNetworkUp(long accountId) { Service networkDriverService = null; List<Service> networkDriverServices = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId, SERVICE.REMOVED, null, SERVICE.KIND, ServiceConstants.KIND_NETWORK_DRIVER_SERVICE); for(Service service : networkDriverServices) { if(invalidStates.contains(service.getState())) { continue; <START> } else { <END> networkDriverService = service; } } if (networkDriverService == null) { return true; } List<Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId, SERVICE.REMOVED, null, SERVICE.STACK_ID, networkDriverService.getStackId()); for (Service service : services) { if (!(service.getState().equals(CommonStatesConstants.ACTIVE) && service.getHealthState().equals(HealthcheckConstants.HEALTH_STATE_HEALTHY))) { return false; } } return true; }</code><technical_language>nit: need for else clause</technical_language>

Target:
private boolean isNetworkUp(long accountId) { Service networkDriverService = null; List<Service> networkDriverServices = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId, SERVICE.REMOVED, null, SERVICE.KIND, ServiceConstants.KIND_NETWORK_DRIVER_SERVICE); for(Service service : networkDriverServices) { if(invalidStates.contains(service.getState())) { continue; } networkDriverService = service; } if (networkDriverService == null) { return true; } List<Service> services = objectManager.find(Service.class, SERVICE.ACCOUNT_ID, accountId, SERVICE.REMOVED, null, SERVICE.STACK_ID, networkDriverService.getStackId()); for (Service service : services) { if (!(service.getState().equals(CommonStatesConstants.ACTIVE) && service.getHealthState().equals(HealthcheckConstants.HEALTH_STATE_HEALTHY))) { return false; } } return true; }
Source:
<code>public Observable<String> getTextForBadge(EvaluationContext ec) { if (display.getBadgeText() == null) { return Observable.just(""); } return Observable.just(display.getBadgeText().evaluate(ec)) <START> .subscribeOn(Schedulers.computation()); <END> }</code><technical_language>Menu.java's implementation of getTextForBadge() include this call .subscribeOn(Schedulers.computation())</technical_language>

Target:
public Observable<String> getTextForBadge(EvaluationContext ec) { if (display.getBadgeText() == null) { return Observable.just(""); } return Observable.just(display.getBadgeText().evaluate(ec)); }
Source:
<code><START> private BlobServiceVersion fromClientVersion(String version) { <END> return Arrays.stream(BlobServiceVersion.values()) .filter(en -> Objects.equals(en.getVersion(), version)) .findFirst() .orElseGet(BlobServiceVersion::getLatest); }</code><technical_language>this private static depend member variables I see</technical_language>

Target:
private static BlobServiceVersion fromClientVersion(String version) { return Arrays.stream(BlobServiceVersion.values()) .filter(en -> Objects.equals(en.getVersion(), version)) .findFirst() .orElseGet(BlobServiceVersion::getLatest); }
Source:
<code>public static AnyValue convert( Iterable<Notification> notifications ) { List<AnyValue> out = new ArrayList<>(); for ( Notification notification : notifications ) { <START> MapValueBuilder builder = new MapValueBuilder(); <END> builder.add( "code", stringValue( notification.getCode() ) ); builder.add( "title", stringValue( notification.getTitle() ) ); builder.add( "description", stringValue( notification.getDescription() ) ); builder.add( "severity", stringValue( notification.getSeverity().toString() ) ); InputPosition pos = notification.getPosition(); boolean includePosition = !pos.equals( InputPosition.empty ); if ( includePosition ) { builder.add( "position", VirtualValues.map( new String[]{"offset", "line", "column"}, new AnyValue[]{ intValue( pos.getOffset() ), intValue( pos.getLine() ), intValue( pos.getColumn() ) } ) ); } out.add( builder.build() ); } return VirtualValues.fromList( out ); }</code><technical_language>new MapValueBuilder(4);</technical_language>

Target:
public static AnyValue convert( Iterable<Notification> notifications ) { List<AnyValue> out = new ArrayList<>(); for ( Notification notification : notifications ) { InputPosition pos = notification.getPosition(); boolean includePosition = !pos.equals( InputPosition.empty ); int size = includePosition ? 5 : 4; MapValueBuilder builder = new MapValueBuilder( size ); builder.add( "code", stringValue( notification.getCode() ) ); builder.add( "title", stringValue( notification.getTitle() ) ); builder.add( "description", stringValue( notification.getDescription() ) ); builder.add( "severity", stringValue( notification.getSeverity().toString() ) ); if ( includePosition ) { builder.add( "position", VirtualValues.map( new String[]{"offset", "line", "column"}, new AnyValue[]{ intValue( pos.getOffset() ), intValue( pos.getLine() ), intValue( pos.getColumn() ) } ) ); } out.add( builder.build() ); } return VirtualValues.fromList( out ); }
Source:
<code>public boolean createNewFile(File lock) throws IOException { if (!lock.createNewFile()) { return false; } if (supportsAtomicCreateNewFile() || !supportsUnixNLink) { return true; } Path lockPath = lock.toPath(); Path link = null; try { link = Files.createLink( <START> Paths.get(lock.getAbsolutePath() + ".lnk"), END> lockPath); Integer nlink = (Integer) (Files.getAttribute(lockPath, "unix:nlink")); if (nlink > 2) { LOG.warn("nlink of link to lock file was not 2 but {}", lock.getPath(), nlink); return false; } else if (nlink < 2) { supportsUnixNLink = false; } return true; } catch (UnsupportedOperationException | IllegalArgumentException e) { supportsUnixNLink = false; return true; } finally { if (link != null) Files.delete(link); } }</code><technical_language>Honestly said, I get logic here. want catch case processes/threads get true createNewFile("foo"). do create a hard link check nlink == 2. create ("foo.lnk"). Is atomic? succeed? If succeed, get nlink == 2, they? recommendation for this technique client create a link a unique file name, including hostname & pid some such. I understand it... kind of. a sequence A : createNewFile("foo") -> true B : createNewFile("foo") -> true A : createLink("foo.lnk_a_unique_id") -> OK A : getAttribute("foo", "unix:nlink") -> 2 A : delete("foo.lnk_a_unique_id") B : createLink("foo.lnk_b_unique_id") -> OK B : getAttribute("foo", "unix:nlink") -> 2 B : delete("foo.lnk_b_unique_id") occur? I not... Methinks algorithm work if 1. link names a unique id, 2. for long file is</technical_language>

Target:
public boolean createNewFile(File lock) throws IOException { if (!lock.createNewFile()) { return false; } if (supportsAtomicCreateNewFile() || !supportsUnixNLink) { return true; } Path lockPath = lock.toPath(); Path link = null; try { link = Files.createLink( Paths.get(lock.getAbsolutePath() + ".lnk"), lockPath); Integer nlink = (Integer) (Files.getAttribute(lockPath, "unix:nlink")); if (nlink > 2) { LOG.warn("nlink of link to lock file was not 2 but {}", lock.getPath(), nlink); return false; } else if (nlink < 2) { supportsUnixNLink = false; } return true; } catch (UnsupportedOperationException | IllegalArgumentException e) { supportsUnixNLink = false; return true; } finally { if (link != null) { Files.delete(link); } } }
Source:
<code>private void interpolateBoundaryRange(long x1, long x2, Record record) { for (int i = 0; i < groupByTwoPointFunctionCount; i++) { GroupByFunction function = groupByTwoPointFunctions.getQuick(i); MapValue startValue = findDataMapValue2(record, x1); MapValue endValue = findDataMapValue3(record, x2); <START> InterpolationUtil.INTERPOLATE_BOUNDARY.interpolateBoundaryAndStore(function, sampler.nextTimestamp(x1), startValue, endValue, true); <END> InterpolationUtil.INTERPOLATE_BOUNDARY.interpolateBoundaryAndStore(function, x2, startValue, endValue, false); } }</code><technical_language>inline</technical_language>

Target:
private void interpolateBoundaryRange(long x1, long x2, Record record) { for (int i = 0; i < groupByTwoPointFunctionCount; i++) { GroupByFunction function = groupByTwoPointFunctions.getQuick(i); MapValue startValue = findDataMapValue2(record, x1); MapValue endValue = findDataMapValue3(record, x2); InterpolationUtil.interpolateBoundary(function, sampler.nextTimestamp(x1), startValue, endValue, true); InterpolationUtil.interpolateBoundary(function, x2, startValue, endValue, false); } }
Source:
<code>protected ArtifactStore removeArtifactStoreInternal( StoreKey key ) { <START> String json = stores.getCache().remove( key.toString() ); <END> return readValueByJson( json, key ); }</code><technical_language>a nitpick. in indy prefer stores.execute(function) instead of stores.getCache() directly</technical_language>

Target:
protected ArtifactStore removeArtifactStoreInternal( StoreKey key ) { String json = stores.executeCache( ( c ) -> c.remove( key ) ); return readValueByJson( json, key ); }
Source:
<code>private void onRemove() { ConfirmationModel model = (ConfirmationModel) getWindow(); if (model.getProgress() != null) { return; } model.startProgress(); AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new <START> AsyncQuery<>(StoragePools <END> -> { if (StoragePools != null && !StoragePools.isEmpty()) { StoragePool StoragePool = StoragePools.get(0); List<ActionParametersBase> prms = getSelectedItems() .stream() .map(item -> new VmTemplateImportExportParameters(item.getId(), getEntity().getId(), StoragePool.getId())) .collect(Collectors.toList()); Frontend.getInstance().runMultipleAction(ActionType.RemoveUnregisteredVmTemplate, prms, result -> { ConfirmationModel localModel = (ConfirmationModel) result.getState(); localModel.stopProgress(); cancel(); }, model); } }), getEntity().getId()); }</code><technical_language>case</technical_language>

Target:
private void onRemove() { ConfirmationModel model = (ConfirmationModel) getWindow(); if (model.getProgress() != null) { return; } model.startProgress(); AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new AsyncQuery<>(storagePools -> { if (storagePools != null && !storagePools.isEmpty()) { StoragePool storagePool = storagePools.get(0); List<ActionParametersBase> prms = getSelectedItems() .stream() .map(item -> new VmTemplateImportExportParameters(item.getId(), getEntity().getId(), storagePool.getId())) .collect(Collectors.toList()); Frontend.getInstance().runMultipleAction(ActionType.RemoveUnregisteredVmTemplate, prms, result -> { ConfirmationModel localModel = (ConfirmationModel) result.getState(); localModel.stopProgress(); cancel(); }, model); } }), getEntity().getId()); }
Source:
<code>public static List<Object[]> data() { return Arrays.asList( <START> new Object[][]{{SimpleOperationTracker.class.getSimpleName(), false}, {SimpleOperationTracker.class.getSimpleName(), true}, {AdaptiveOperationTracker.class.getSimpleName(), false}, {AdaptiveOperationTracker.class.getSimpleName(), true}}); <END> }</code><technical_language>need of cases for encrypted = true (either simple adaptive). I useful - do think</technical_language>

Target:
public static List<Object[]> data() { return Arrays.asList( new Object[][]{{SimpleOperationTracker.class.getSimpleName(), false}, {AdaptiveOperationTracker.class.getSimpleName(), false}, {AdaptiveOperationTracker.class.getSimpleName(), true}}); }
Source:
<code>public Match(Column<String> column, String prefix, String suffix) { super(String.format("LIKE CONCAT('%s', %s, '%s')", prefix, column.getSqlKeyword(), suffix)); <START> Preconditions.checkNotNull(column); <END> }</code><technical_language>I realized current do null check is incorrect in a lot of matchers. If column is null, NPE thrown in super call reaching this statement. checkNotNull returns object itself, is call in super: super(..., prefix, Preconditions.checkNotNull(column).getSqlKeyword()), suffix));</technical_language>

Target:
public Match(Column<String> column, String prefix, String suffix) { super(String.format("LIKE CONCAT(CONCAT('%s', %s), '%s')", prefix, Preconditions.checkNotNull(column).getSqlKeyword(), suffix)); }
Source:
<code>public void refreshPeerLeadersForAllPartitions() { rwLock.readLock().lock(); try { for (Map.Entry<String, Set<ReplicaId>> entry : peerLeaderReplicasByPartition.entrySet()) { String partitionName = entry.getKey(); ReplicaId localLeaderReplica = storeManager.getReplica(partitionName); PartitionId partition = localLeaderReplica.getPartitionId(); Set<ReplicaId> previousRemoteLeaderReplicas = entry.getValue(); Set<ReplicaId> currentRemoteLeaderReplicas = new HashSet<>(partition.getReplicaIdsByState(ReplicaState.LEADER, null)); currentRemoteLeaderReplicas.remove(localLeaderReplica); if (!previousRemoteLeaderReplicas.equals(currentRemoteLeaderReplicas)) { peerLeaderReplicasByPartition.put(partitionName, currentRemoteLeaderReplicas); } } <START> } finally { <END> rwLock.readLock().unlock(); } }</code><technical_language>race condition if read-lock here. is example(leader): remote DC1 remote DC2 T1: R1(R2, R3) R4(R5, R6) T2: R2 (R1, R3) R4(R5, R6) ---> current remote leader replica (R2, R4) T3: R2 (R1, R3) R5(R4, R6). ---> current remote leader replica (R2, R5) (R2, R5) get in overridden (R2, R4)</technical_language>

Target:
public void refreshPeerLeadersForAllPartitions() { rwLock.writeLock().lock(); try { for (Map.Entry<String, Set<ReplicaId>> entry : peerLeaderReplicasByPartition.entrySet()) { String partitionName = entry.getKey(); ReplicaId localLeaderReplica = storeManager.getReplica(partitionName); PartitionId partition = localLeaderReplica.getPartitionId(); Set<ReplicaId> previousRemoteLeaderReplicas = entry.getValue(); Set<ReplicaId> currentRemoteLeaderReplicas = new HashSet<>(partition.getReplicaIdsByState(ReplicaState.LEADER, null)); currentRemoteLeaderReplicas.remove(localLeaderReplica); if (!previousRemoteLeaderReplicas.equals(currentRemoteLeaderReplicas)) { peerLeaderReplicasByPartition.put(partitionName, currentRemoteLeaderReplicas); } } } finally { rwLock.writeLock().unlock(); } }
Source:
<code>public void schedule_command_if_delay_is_set() { final CommandContext context = createCommandContext(DELAY); final Command cmd = Commands.create(createProject(newUuid()), context); scheduler.schedule(cmd); assertNull(postedCommand); <START> sleep(DELAY_MS + CHECK_OFFSET_MS); <END> assertEquals(cmd, postedCommand); }</code><technical_language>Please test spy() mock(). Sleeping threads scale for testing</technical_language>

Target:
public void schedule_command_if_delay_is_set() { final Command cmd = Commands.create(createProject(newUuid()), context); scheduler.schedule(cmd); verify(scheduler, never()).post(cmd); verify(scheduler, after(DELAY_MS).times(1)).post(cmd); }
Source:
<code>private void poisonTable(Connection connection) throws SQLException { try (Statement statement = connection.createStatement()) { <START> if (ConnectionDbTypes.getDbType(connection).equals(DBType.ORACLE)) { <END> poisonOracleTable(connection, statement); } else { poisonPostgresTable(connection, statement); } } }</code><technical_language>nit: enums compared == opposed Objects::equals</technical_language>

Target:
private void poisonTable(Connection connection) throws SQLException { try (Statement statement = connection.createStatement()) { if (ConnectionDbTypes.getDbType(connection) == DBType.ORACLE) { poisonOracleTable(connection, statement); } else { poisonPostgresTable(connection, statement); } } }
Source:
<code>public Integer toValue(String string, INode node) throws ValueConverterException { <START> if ("*".equals(string)) { <END> return -1; } else { return Integer.valueOf(string); } }</code><technical_language>constant</technical_language>

Target:
public Integer toValue(String string, INode node) throws ValueConverterException { if (Ecl.ANY.equals(string)) { return -1; } else { return Integer.valueOf(string); } }
Source:
<code>protected ConfigToolExecutionResult configToolInvocation(String... cli) { ConfigTool configTool = angela.tsa().configTool(getNode(1, 1)); if (!Arrays.asList(cli).contains("-t")) { String[] enhancedCli = new String[cli.length + 2]; <START> enhancedCli[0] = "-t"; <END> enhancedCli[1] = Measure.of(OPERATION_TIMEOUT.getSeconds(), TimeUnit.SECONDS).toString(); System.arraycopy(cli, 0, enhancedCli, 2, cli.length); return configTool.executeCommand(enhancedCli); } return configTool.executeCommand(cli); }</code><technical_language>operation timeout is -r, -t. -t is connection timeout. For -t, re-used existing timeout variable if need set</technical_language>

Target:
protected ConfigToolExecutionResult configToolInvocation(String... cli) { List<String> enhancedCli = new ArrayList<>(cli.length); List<String> configToolOptions = getConfigToolOptions(cli); boolean addedOptions = false; String timeout = Measure.of(getConnectionTimeout().getSeconds(), TimeUnit.SECONDS).toString(); if (!configToolOptions.contains("-t")) { enhancedCli.add("-t"); enhancedCli.add(timeout); addedOptions = true; } if (!configToolOptions.contains("-r")) { enhancedCli.add("-r"); enhancedCli.add(timeout); addedOptions = true; } String[] cmd; if (addedOptions) { enhancedCli.addAll(Arrays.asList(cli)); cmd = enhancedCli.toArray(new String[0]); } else { cmd = cli; } return angela.tsa().configTool(getNode(1, 1)).executeCommand(cmd); }
Source:
<code>public void setUp() { this.collisionArea = Mockito.mock(CollisionMask.class); this.drawable = new EnemyFish(collisionArea, null, 0, 0); this.graphicsContext = PowerMockito.mock(GraphicsContext.class); Mockito.when(collisionArea.getRotation()).thenReturn(42D); Mockito.when(collisionArea.getCenterX()).thenReturn(69D); Mockito.when(collisionArea.getCenterY()).thenReturn(1024D); Mockito.when(collisionArea.getHeight()).thenReturn(22D); Mockito.when(collisionArea.getSize()).thenReturn(33D); Mockito.when(collisionArea.getBottomLeft()).thenReturn(new Vec2d(1, 1)); Mockito.when(collisionArea.getBottomRight()).thenReturn(new Vec2d(2, 2)); Mockito.when(collisionArea.getTopLeft()).thenReturn(new Vec2d(3, 3)); <START> Mockito.when(collisionArea.getTopRight()).thenReturn(new Vec2d(4, 4)); <END> HashSet<Vec2d> set = new HashSet<>(); set.add(new Vec2d()); set.add(new Vec2d(100,100)); set.add(new Vec2d(200,200)); Mockito.when(collisionArea.getMask()).thenReturn(set); }</code><technical_language>static import for Mockito! <layout</technical_language>

Target:
public void setUp() { this.collisionArea = Mockito.mock(CollisionMask.class); this.drawable = new EnemyFish(collisionArea, null, 0, 0); this.graphicsContext = mock(GraphicsContext.class); when(collisionArea.getRotation()).thenReturn(42D); when(collisionArea.getCenterX()).thenReturn(69D); when(collisionArea.getCenterY()).thenReturn(1024D); when(collisionArea.getHeight()).thenReturn(22D); when(collisionArea.getSize()).thenReturn(33D); when(collisionArea.getBottomLeft()).thenReturn(new Vec2d(1, 1)); when(collisionArea.getBottomRight()).thenReturn(new Vec2d(2, 2)); when(collisionArea.getTopLeft()).thenReturn(new Vec2d(3, 3)); when(collisionArea.getTopRight()).thenReturn(new Vec2d(4, 4)); HashSet<Vec2d> set = new HashSet<>(); set.add(new Vec2d()); set.add(new Vec2d(100, 100)); set.add(new Vec2d(200, 200)); when(collisionArea.getMask()).thenReturn(set); }
Source:
<code>public Map<String, String> getJobMessageProperties() { DiskImage diskImage = diskImageDao.getSnapshotById(getParameters().getSubchainInfo().getTopImageId()); DiskImage destDiskImage = diskImageDao.getSnapshotById(getParameters().getSubchainInfo().getBaseImageId()); if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.Disk.name().toLowerCase(), diskImage.getDiskAlias()); jobProperties.put("sourcesnapshot", <START> Optional.ofNullable(snapshotDao.get(diskImage.getVmSnapshotId()).getDescription()).orElse(StringUtils.EMPTY)); <END> jobProperties.put("destinationsnapshot", Optional.ofNullable(snapshotDao.get(destDiskImage.getVmSnapshotId()).getDescription()).orElse(StringUtils.EMPTY)); } return jobProperties; }</code><technical_language>Please ""</technical_language>

Target:
public Map<String, String> getJobMessageProperties() { DiskImage diskImage = diskImageDao.getSnapshotById(getParameters().getSubchainInfo().getTopImageId()); DiskImage destDiskImage = diskImageDao.getSnapshotById(getParameters().getSubchainInfo().getBaseImageId()); if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.Disk.name().toLowerCase(), diskImage.getDiskAlias()); jobProperties.put("sourcesnapshot", Optional.ofNullable(snapshotDao.get(diskImage.getVmSnapshotId()).getDescription()).orElse("")); jobProperties.put("destinationsnapshot", Optional.ofNullable(snapshotDao.get(destDiskImage.getVmSnapshotId()).getDescription()).orElse("")); } return jobProperties; }
Source:
<code>public static UrisScheme forHost(String host) { try { if (host == null) { return WIKIDATA; } return new WikibaseUris(new URI("http://" + host), WIKIBASE_ENTITY_PREFIX, WIKIBASE_ENTITY_DATA_PREFIX, WIKIBASE_INITIALS); } catch (URISyntaxException e) { throw new <START> RuntimeException("Bad <END> URI host: " + host, e); } }</code><technical_language>IllegalArgumentException</technical_language>

Target:
public static UrisScheme forHost(String host) { try { if (host == null) { return WIKIDATA; } return new WikibaseUris(new URI("http://" + host), WIKIBASE_ENTITY_PREFIX, WIKIBASE_ENTITY_DATA_PREFIX, WIKIBASE_INITIALS); } catch (URISyntaxException e) { throw new IllegalArgumentException("Bad URI host: " + host, e); } }
Source:
<code>public Optional<Response> handle(HandlerInput input) { String speechText = "Welcome to the Alexa Skills Kit sample. Please tell me your favorite color by saying, my favorite color is red. " + <START> "Your options are green, blue, purple, red, orange and yellow."; <END> String repromptText = "Please tell me your favorite color by saying, my favorite color is red"; return input.getResponseBuilder() .withSimpleCard("ColorSession", speechText) .withSpeech(speechText) .withReprompt(repromptText) .build(); }</code><technical_language>I is necessary enumerate of options here. verbose intuitive in a natural conversational sense I this. is a maintainability concern color updates in interaction model need reflected in code</technical_language>

Target:
public Optional<Response> handle(HandlerInput input) { String speechText = "Welcome to the Alexa Skills Kit sample. Please tell me your favorite color by saying, my favorite color is red."; String repromptText = "Please tell me your favorite color by saying, my favorite color is red"; return input.getResponseBuilder() .withSimpleCard("ColorSession", speechText) .withSpeech(speechText) .withReprompt(repromptText) .build(); }
Source:
<code><START> public void onXWalkReady() <END></code><technical_language>This empty implementation override CordovaActivity.onXWalkReady. doc, this a deprecated Activity replaced CordovaActivity, here</technical_language>

Target:
protected void onXWalkReady() { }
Source:
<code>List<Dataset> getDatasetsInCollection(CollectionReader reader) throws ZebedeeException, IOException { List<Dataset> datasets = new ArrayList<>(); for (String uri : reader.getReviewed().listUris()) { <START> if (isDataJson(uri) && !isVersionedURI(uri)) { <END> Path parent = Paths.get(uri).getParent(); Page page = reader.getReviewed().getContent(parent.toString()); if (PageType.dataset.equals(page.getType())) { datasets.add((Dataset) page); } } } return datasets; }</code><technical_language>consider filtering pages /datasets/ in URI. load content for data.json files in collection. This expensive for large collections</technical_language>

Target:
List<Dataset> getDatasetsInCollection(CollectionReader reader) throws ZebedeeException, IOException { List<String> filtered = reader.getReviewed() .listUris() .stream() .filter(uri -> StringUtils.isNotEmpty(uri) && uri.contains("/datasets/") && isDataJson(uri) && !isVersionedURI(uri)) .collect(Collectors.toList()); List<Dataset> datasets = new ArrayList<>(); for (String uri : filtered) { Path parent = Paths.get(uri).getParent(); Page page = reader.getReviewed().getContent(parent.toString()); if (PageType.dataset.equals(page.getType())) { datasets.add((Dataset) page); } } return datasets; }
Source:
<code>public boolean isImmuneToBombs(){ <START> return immuneToBombs; <END> }</code><technical_language>player immune bombs forever. similar isInvulnerable</technical_language>

Target:
public boolean isImmuneToBombs(){ return (System.currentTimeMillis() < immuneToBombsTill || isInvulnerable()); }
Source:
<code><START> public void testSaveCreate() throws SQLException{ <END> String name = "TEST_RETROSPECTIVE_NAME"; String description = "TEST_RETROSPECTIVE_DESCRIPTION"; long sprintId = mCS.getSprintsId().get(0); long projectId = mCP.getAllProjects().get(0).getId(); int type = RetrospectiveObject.TYPE_GOOD; RetrospectiveObject retrospective = new RetrospectiveObject(projectId); retrospective.setName(name) .setSprintId(sprintId) .setDescription(description) .setType(type) .save(); IQueryValueSet valueSet = new MySQLQuerySet(); valueSet.addTableName(RetrospectiveEnum.TABLE_NAME); valueSet.addEqualCondition(RetrospectiveEnum.ID, retrospective.getId()); String query = valueSet.getSelectQuery(); ResultSet result = mControl.executeQuery(query); RetrospectiveObject retrospectiveCreated = null; if (result.next()) { retrospectiveCreated = RetrospectiveDAO.convert(result); } closeResultSet(result); assertEquals(name, retrospectiveCreated.getName()); assertEquals(description, retrospectiveCreated.getDescription()); assertEquals(type, retrospectiveCreated.getType()); assertEquals(projectId, retrospectiveCreated.getProjectId()); assertEquals(sprintId, retrospectiveCreated.getSprintId()); assertEquals(RetrospectiveObject.STATUS_NEW, retrospectiveCreated.getStatus()); }</code><technical_language>remove throws SQLException</technical_language>

Target:
public void testSaveCreate() { String name = "TEST_RETROSPECTIVE_NAME"; String description = "TEST_RETROSPECTIVE_DESCRIPTION"; long sprintId = mCS.getSprintsId().get(0); long projectId = mCP.getAllProjects().get(0).getId(); int type = RetrospectiveObject.TYPE_GOOD; RetrospectiveObject retrospective = new RetrospectiveObject(projectId); retrospective.setName(name) .setSprintId(sprintId) .setDescription(description) .setType(type) .save(); RetrospectiveObject retrospectiveCreated = RetrospectiveDAO.getInstance().get(retrospective.getId()); assertEquals(name, retrospectiveCreated.getName()); assertEquals(description, retrospectiveCreated.getDescription()); assertEquals(type, retrospectiveCreated.getType()); assertEquals(projectId, retrospectiveCreated.getProjectId()); assertEquals(sprintId, retrospectiveCreated.getSprintId()); assertEquals(RetrospectiveObject.STATUS_NEW, retrospectiveCreated.getStatus()); }
Source:
<code>public List<BrandingTheme> getBrandingThemes() { if (themes == null && brandingRootPath.exists() && brandingRootPath.isDirectory() && brandingRootPath.canRead()) { themes = new ArrayList<BrandingTheme>(); List<File> directories = Arrays.asList( brandingRootPath.listFiles(new FileFilter() { @Override public boolean accept(final File file) { <START> return file.isDirectory(); <END> } })); for (File directory : directories) { BrandingTheme theme = new BrandingTheme( directory.getAbsolutePath(), brandingRootPath); if (theme.isAvailable()) { themes.add(theme); } } Collections.sort(themes); Collections.reverse(themes); } return themes; }</code><technical_language>this accepts synlink</technical_language>

Target:
public List<BrandingTheme> getBrandingThemes() { if (themes == null && brandingRootPath.exists() && brandingRootPath.isDirectory() && brandingRootPath.canRead()) { themes = new ArrayList<BrandingTheme>(); List<File> directories = Arrays.asList( brandingRootPath.listFiles(new FileFilter() { @Override public boolean accept(final File file) { return file.isDirectory() && DIRECTORY_PATTERN.matcher(file.getName()).matches(); } })); Collections.sort(directories); for (File directory : directories) { BrandingTheme theme = new BrandingTheme( directory.getAbsolutePath(), brandingRootPath); if (theme.isAvailable()) { themes.add(theme); } } Collections.reverse(themes); } return themes; }
Source:
<code>public void onWorkspaceStarted(WorkspaceStartedEvent event) { List<MachineEntity> machines = getMachines(event.getWorkspace()); if (machines.isEmpty()) { return; } ProcessTreeNode machineToSelect = null; MachineEntity devMachine = appContext.getDevMachine(); if (devMachine != null) { machineToSelect = addMachineNode(devMachine); machines.remove(devMachine); } for (MachineEntity machine : machines) { addMachineNode(machine); } if (machineToSelect == null) { <START> machineToSelect = machineNodes.entrySet().iterator().next().getValue(); <END> } view.selectNode(machineToSelect); workspaceAgent.setActivePart(ProcessesPanelPresenter.this); }</code><technical_language>Is machineNodes empty collection</technical_language>

Target:
public void onWorkspaceStarted(WorkspaceStartedEvent event) { List<MachineEntity> machines = getMachines(event.getWorkspace()); if (machines.isEmpty()) { return; } ProcessTreeNode machineToSelect = null; MachineEntity devMachine = appContext.getDevMachine(); if (devMachine != null) { machineToSelect = addMachineNode(devMachine); machines.remove(devMachine); } for (MachineEntity machine : machines) { addMachineNode(machine); } if (machineToSelect != null) { view.selectNode(machineToSelect); } else if (!machineNodes.isEmpty()) { machineToSelect = machineNodes.entrySet().iterator().next().getValue(); view.selectNode(machineToSelect); } workspaceAgent.setActivePart(ProcessesPanelPresenter.this); }
Source:
<code>private void validate(FailureCollector collector) { boolean hasOneSplit = false; if (!containsMacro(NUM_SPLITS) && numSplits != null) { <START> if (numSplits < 1) { <END> collector.addFailure("Invalid value for Number of Splits", "Must be at least 1"). withConfigProperty(NUM_SPLITS); } if (numSplits == 1) { hasOneSplit = true; } } if (!containsMacro(TRANSACTION_ISOLATION_LEVEL) && transactionIsolationLevel != null) { TransactionIsolationLevel.validate(transactionIsolationLevel, collector); } if (query != null) { return; } if (!containsMacro(IMPORT_QUERY) && (query == null || query.isEmpty()) && (importQuery == null || importQuery.isEmpty())) { collector.addFailure("Invalid import query specified", null).withConfigProperty(IMPORT_QUERY); } if (!hasOneSplit && !containsMacro(IMPORT_QUERY) && !getImportQuery().contains("$CONDITIONS")) { collector.addFailure("Invalid Import Query specified", String.format("Import Query %s must contain " + "the string '$CONDITIONS'.", importQuery)).withConfigProperty(IMPORT_QUERY); } if (!hasOneSplit && !containsMacro(SPLIT_BY) && (splitBy == null || splitBy.isEmpty())) { collector.addFailure("Split-By Field Name must be specified if Number of Splits is not set to 1.", null).withConfigProperty(SPLIT_BY); } if (!hasOneSplit && !containsMacro(BOUNDING_QUERY) && (boundingQuery == null || boundingQuery.isEmpty())) { collector.addFailure("Bounding Query must be specified if Number of Splits is not set to 1.", null) .withConfigProperty(BOUNDING_QUERY); } }</code><technical_language>Error : Number of splits 1., null corrective action</technical_language>

Target:
private void validate(FailureCollector collector) { boolean hasOneSplit = false; if (!containsMacro(NUM_SPLITS) && numSplits != null) { if (numSplits < 1) { collector.addFailure("Number of Splits must be a positive number.", null).withConfigProperty(NUM_SPLITS); } if (numSplits == 1) { hasOneSplit = true; } } if (!containsMacro(TRANSACTION_ISOLATION_LEVEL) && transactionIsolationLevel != null) { TransactionIsolationLevel.validate(transactionIsolationLevel, collector); } if (!containsMacro(IMPORT_QUERY) && Strings.isNullOrEmpty(importQuery)) { collector.addFailure("Import Query must be specified.", null).withConfigProperty(IMPORT_QUERY); } if (!hasOneSplit && !containsMacro(IMPORT_QUERY) && !Strings.isNullOrEmpty(importQuery) && !getImportQuery().contains("$CONDITIONS")) { collector.addFailure("Invalid Import Query.", String.format("Import Query %s must contain the " + "string '$CONDITIONS'.", importQuery)) .withConfigProperty(IMPORT_QUERY); } if (!hasOneSplit && !containsMacro(SPLIT_BY) && Strings.isNullOrEmpty(splitBy)) { collector.addFailure("Split-By Field Name must be specified if Number of Splits is not set to 1.", null).withConfigProperty(SPLIT_BY).withConfigProperty(NUM_SPLITS); } if (!hasOneSplit && !containsMacro(BOUNDING_QUERY) && Strings.isNullOrEmpty(boundingQuery)) { collector.addFailure("Bounding Query must be specified if Number of Splits is not set to 1.", null) .withConfigProperty(BOUNDING_QUERY).withConfigProperty(NUM_SPLITS); } }
Source:
<code>public StringType() { <START> type = NativeTypeEnum.STRING; <END> }</code><technical_language>super( NativeTypeEnum.STRING );</technical_language>

Target:
public StringType() { super(NativeTypeEnum.STRING); }
Source:
<code>public static AuthControlFlag get(String flag) { try { return AuthControlFlag.valueOf(flag.toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException( <START> String.format("No authorization flag \"%s\", available flags are [%s]. %s", <END> flag, Arrays.asList(AuthControlFlag.values()) .stream() .map(AuthControlFlag::toString) .collect(Collectors.joining(", ")), ex.getLocalizedMessage()), ex); } }</code><technical_language>control flag</technical_language>

Target:
public static AuthControlFlag get(String flag) throws IllegalArgumentException { try { return AuthControlFlag.valueOf(flag.toUpperCase()); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException( String.format("No control flag \"%s\", available flags are [%s]. %s", flag, Arrays.asList(AuthControlFlag.values()) .stream() .map(AuthControlFlag::toString) .collect(Collectors.joining(", ")), ex.getLocalizedMessage()), ex); } }
Source:
<code>public void reset() { latch = new CountDownLatch(1); latch2 = new CountDownLatch(1); <START> System.out.println("RESET " + latch); <END> }</code><technical_language>This removed</technical_language>

Target:
public void reset() { latch = new CountDownLatch(1); latch2 = new CountDownLatch(1); }
Source:
<code>public static boolean getEmojiConverter(Context context){ <START> return getBoolean(context, "pref_emoji_converter", false); <END> }</code><technical_language>Please add default res/values/config.xml (see other preferences) instead of hard-coded false</technical_language>

Target:
public static boolean getEmojiConverter(Context context){ return getBoolean(context, "pref_emoji_converter", context.getResources().getBoolean(R.bool.pref_default_emoji_converter)); }
Source:
<code><START> public void shouldBeConfiguredIfUsernameAndPasswordAreNotNull() throws Exception { <END> boolean isConfigured = usernamePasswordAuthenticationCredentials.isConfigured(); assertThat(isConfigured, is(true)); }</code><technical_language>"throws Exception" removed, necessary</technical_language>

Target:
public void shouldBeConfiguredIfUsernameAndPasswordAreNotNull() { boolean isConfigured = usernamePasswordAuthenticationCredentials.isConfigured(); assertThat(isConfigured, is(true)); }
Source:
<code>public long getRegionSizeInBytes(int positionOffset, int length) { int positionCount = getPositionCount(); if (positionOffset < 0 || length < 0 || positionOffset + length > positionCount) { throw new IndexOutOfBoundsException("Invalid position " + positionOffset + " in block with " + positionCount + " positions"); } <START> return (long) length * (fixedSize + Byte.BYTES); <END> }</code><technical_language>is obvious this is correct: (long) x * y. I rewrite y * (long) x x * (long) y</technical_language>

Target:
public long getRegionSizeInBytes(int positionOffset, int length) { int positionCount = getPositionCount(); if (positionOffset < 0 || length < 0 || positionOffset + length > positionCount) { throw new IndexOutOfBoundsException("Invalid position " + positionOffset + " in block with " + positionCount + " positions"); } return (fixedSize + Byte.BYTES) * (long) length; }
Source:
<code>public QuotaBalanceVO findLastBalanceEntry(final Long accountId, final Long domainId, final Date beforeThis) { return Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallback<QuotaBalanceVO>() { @Override public QuotaBalanceVO doInTransaction(final TransactionStatus status) { List<QuotaBalanceVO> quotaBalanceEntries = new ArrayList<>(); Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", false, 0L, 1L); SearchCriteria<QuotaBalanceVO> sc = createSearchCriteria(); sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId); sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId); sc.addAnd("creditsId", SearchCriteria.Op.EQ, 0); sc.addAnd("updatedOn", SearchCriteria.Op.LT, beforeThis); quotaBalanceEntries = search(sc, filter); <START> return quotaBalanceEntries.size() > 0 ? quotaBalanceEntries.get(0) : null; <END> } }); }</code><technical_language>List.isEmpty() checking size determine a list is empty. Also, check quotaBalanceEntries is null checking is empty</technical_language>

Target:
public QuotaBalanceVO findLastBalanceEntry(final Long accountId, final Long domainId, final Date beforeThis) { return Transaction.execute(TransactionLegacy.USAGE_DB, new TransactionCallback<QuotaBalanceVO>() { @Override public QuotaBalanceVO doInTransaction(final TransactionStatus status) { List<QuotaBalanceVO> quotaBalanceEntries = new ArrayList<>(); Filter filter = new Filter(QuotaBalanceVO.class, "updatedOn", false, 0L, 1L); QueryBuilder<QuotaBalanceVO> qb = QueryBuilder.create(QuotaBalanceVO.class); qb.and(qb.entity().getAccountId(), SearchCriteria.Op.EQ, accountId); qb.and(qb.entity().getDomainId(), SearchCriteria.Op.EQ, domainId); qb.and(qb.entity().getCreditsId(), SearchCriteria.Op.EQ, 0); qb.and(qb.entity().getUpdatedOn(), SearchCriteria.Op.LT, beforeThis); quotaBalanceEntries = search(qb.create(), filter); return !quotaBalanceEntries.isEmpty() ? quotaBalanceEntries.get(0) : null; } }); }
Source:
<code>private void writeObject(ObjectOutputStream out) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (OutputStreamDataOutput osdo = new OutputStreamDataOutput(bos)) { automaton.save(osdo); } byte[] bytes = bos.toByteArray(); <START> out.writeInt(bytes.length); <END> out.write(bytes); }</code><technical_language>do need size in bytes in output? for logging</technical_language>

Target:
private void writeObject(ObjectOutputStream out) throws IOException { automaton.save(new OutputStreamDataOutput(out)); }
Source:
<code>public static Slice ipSubnetMin(@SqlType(StandardTypes.IPPREFIX) Slice value) { <START> validateIpPrefixAndGetBytes(value); <END> return castFromIpPrefixToIpAddress(value); }</code><technical_language>input a valid ipprefix need validate it</technical_language>

Target:
public static Slice ipSubnetMin(@SqlType(StandardTypes.IPPREFIX) Slice value) { return castFromIpPrefixToIpAddress(value); }
Source:
<code>public boolean test(Float value) { <START> return value <= threshold; <END> }</code><technical_language>null check, anytime encounter a boxed null check</technical_language>

Target:
public boolean test(Float value) { if (value == null) { return threshold < 0; } return value <= threshold; }
Source:
<code>static void throwSuppressed(final String message, final LinkedList<RuntimeException> suppressed) { if (suppressed != null && !suppressed.isEmpty()) { final RuntimeException firstCause = suppressed.pollFirst(); <START> final RuntimeException toThrow = new RuntimeException(message, firstCause); <END> for (final RuntimeException e : suppressed) { toThrow.addSuppressed(e); } throw toThrow; } }</code><technical_language>exception "cause"</technical_language>

Target:
static void throwSuppressed(final String message, final LinkedList<RuntimeException> suppressed) { if (!suppressed.isEmpty()) { final RuntimeException firstCause = suppressed.pollFirst(); final RuntimeException toThrow = new RuntimeException(message, firstCause); for (final RuntimeException e : suppressed) { toThrow.addSuppressed(e); } throw toThrow; } }
Source:
<code>public void onFullScreen(boolean isFullScreen) { if (isPrepared) { isManualFullscreen = isFullScreen; if (isFullScreen) { enterFullScreen(); } else { exitFullScreen(); } environment.getAnalyticsRegistry().trackVideoOrientation(videoEntry.videoId, player.getCurrentPosition() / AppConstants.MILLISECONDS_PER_SECOND, <START> isFullScreen, videoEntry.eid, videoEntry.lmsUrl, ""); <END> } else { logger.debug("Player not prepared ?? full screen will NOT work!"); } }</code><technical_language>**Same:** pass null a parameter</technical_language>

Target:
public void onFullScreen(boolean isFullScreen) { if (isPrepared) { isManualFullscreen = isFullScreen; if (isFullScreen) { enterFullScreen(); } else { exitFullScreen(); } environment.getAnalyticsRegistry().trackVideoOrientation(videoEntry.videoId, player.getCurrentPosition() / AppConstants.MILLISECONDS_PER_SECOND, isFullScreen, videoEntry.eid, videoEntry.lmsUrl, null); } else { logger.debug("Player not prepared ?? full screen will NOT work!"); } }
Source:
<code>private String doHttpGet(String urlStr) throws IOException { URL url = new URL(urlStr); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setUseCaches(false); InputStream is = connection.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String theLine; StringBuilder response = new StringBuilder(); while ((theLine = br.readLine()) != null) { response.append(theLine); } <START> connection.disconnect(); <END> return response.toString(); }</code><technical_language>disconnect in finally block</technical_language>

Target:
private String doHttpGet(String urlStr) throws IOException { InputStream is=null; StringBuilder response = new StringBuilder(); try{ URL url = new URL(urlStr); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setInstanceFollowRedirects(false); connection.setUseCaches(false); is = connection.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String theLine; while ((theLine = br.readLine()) != null) { response.append(theLine); } } finally { if(is!=null){ is.close(); } } return response.toString(); }
Source:
<code>public void userAuthFalseDevIdPermission() throws DeviceAccessAuthorizationException, UserStoreException, PermissionManagementException { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true); PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(NON_ADMIN_ALLOWED_USER); Assert.assertFalse(deviceAccessAuthorizationService.isUserAuthorized(deviceIds.get(3), new String[]{NON_ADMIN_PERMISSION}), "Non admin user accessing not allowed device authorized"); PrivilegedCarbonContext.endTenantFlow(); <START> } <END></code><technical_language>starting tenant flow in test cases? move start tenant flow @BeforeTest method end tenant flow in tear</technical_language>

Target:
public void userAuthFalseDevIdPermission() throws DeviceAccessAuthorizationException, UserStoreException, PermissionManagementException { PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(NON_ADMIN_ALLOWED_USER); Assert.assertFalse(deviceAccessAuthorizationService.isUserAuthorized(deviceIds.get(3), new String[]{NON_ADMIN_PERMISSION}), "Non admin user accessing not allowed device authorized"); }