auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void trackSessionIfNeeded(boolean autoCaptured, Session session) { String releaseStage = getReleaseStage(); <START> boolean notifyForRelease = client != null && configuration.shouldNotifyForReleaseStage(releaseStage); <END> if ((configuration.shouldAutoCaptureSessions() || !autoCaptured) && notifyForRelease) { sessionQueue.add(session); sessionStore.write(session); trackedFirstSession = true; } }</code><technical_language>this check if client is null here? put a session in queue/store if client is initialized yet</technical_language>

Target:
private void trackSessionIfNeeded(boolean autoCaptured, Session session) { String releaseStage = getReleaseStage(); boolean notifyForRelease = configuration.shouldNotifyForReleaseStage(releaseStage); if ((configuration.shouldAutoCaptureSessions() || !autoCaptured) && notifyForRelease) { sessionQueue.add(session); sessionStore.write(session); trackedFirstSession = true; } }
Source:
<code>public void writeObject(ObjectOutput output, ScriptMetadata object) throws IOException { output.writeUTF(object.name); output.writeUTF(object.extension); output.writeUTF(object.mode.name()); writeSet(output, object.parameters); <START> OptionalObjectInputOutput.writeOptional(output, object.language); <END> OptionalObjectInputOutput.writeOptional(output, object.role); OptionalObjectInputOutput.writeOptional(output, object.reducer); OptionalObjectInputOutput.writeOptional(output, object.collator); OptionalObjectInputOutput.writeOptional(output, object.combiner); }</code><technical_language>OptionalExternalizer, need call OptionalObjectInputOutput.writeOptional missing something. need do is call output.writeObject(object.language) externalizer used</technical_language>

Target:
public void writeObject(ObjectOutput output, ScriptMetadata object) throws IOException { output.writeUTF(object.name); output.writeUTF(object.extension); output.writeUTF(object.mode.name()); output.writeObject(object.parameters); output.writeObject(object.language); output.writeObject(object.role); output.writeObject(object.reducer); output.writeObject(object.collator); output.writeObject(object.combiner); }
Source:
<code>private void setVote(boolean vote, int otherUserVotes){ if (vote){ addVote(otherUserVotes); }else{ <START> removeVote(otherUserVotes); <END> } }</code><technical_language>sample code I shared for updating setFollowing function, this function refactoring too</technical_language>

Target:
private void setVote(boolean vote, int otherUserVotes) { voteViewContainer.setSelected(vote); threadVoteTextView.setText(ResourceUtil.getFormattedStringForQuantity( threadVoteTextView.getResources(), R.plurals.discussion_responses_action_bar_vote_text, vote ? otherUserVotes + 1 : otherUserVotes)); threadVoteIconImageView.setIconColorResource(vote ? R.color.edx_brand_primary_base : R.color.edx_brand_gray_base); }
Source:
<code>private boolean _isParent(String parentDeckName, String childDeckName) { <START> List<String> parentDeckPath = path(parentDeckName); <END> List<String> childDeckPath = path(childDeckName); parentDeckPath.add(basename(childDeckName)); if (parentDeckPath.size() != childDeckPath.size()) { return false; } Iterator<String> cpIt = childDeckPath.iterator(); Iterator<String> ppIt = parentDeckPath.iterator(); while (cpIt.hasNext() && ppIt.hasNext()) { if (!cpIt.next().equals(ppIt.next())) { return false; } } return true; }</code><technical_language>wait! I +1, this is correct. needs a whitespace difference</technical_language>

Target:
private boolean _isParent(String parentDeckName, String childDeckName) { String[] parentDeckPath = path(parentDeckName); String[] childDeckPath = path(childDeckName); if (parentDeckPath.length + 1 != childDeckPath.length) { return false; } for (int i = 0; i < parentDeckPath.length; i++) { if (! parentDeckPath[i].equals(childDeckPath[i])) { return false; } } return true; }
Source:
<code>public CompletableFuture<ClientResponse> run(String theTable, String otherTable) { String sql = "@SwapTables " + theTable + " " + otherTable; Object[] userParams = null; CatalogContext context = VoltDB.instance().getCatalogContext(); List<String> sqlStatements = new ArrayList<>(1); sqlStatements.add(sql); for (Table t: context.database.getTables()) { if (t.getTypeName().equalsIgnoreCase(theTable) && t.getTimetolive() != null) { return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, <START> String.format("Table %s cannot be swaped since it uses TTL.",theTable)); <END> } } return runNonDDLAdHoc(context, sqlStatements, true, null, ExplainMode.NONE, false, true, userParams); }</code><technical_language>Typo , "swapped"</technical_language>

Target:
public CompletableFuture<ClientResponse> run(String theTable, String otherTable) { String sql = "@SwapTables " + theTable + " " + otherTable; Object[] userParams = null; CatalogContext context = VoltDB.instance().getCatalogContext(); List<String> sqlStatements = new ArrayList<>(1); sqlStatements.add(sql); Map<String, Table> ttlTables = CatalogUtil.getTimeToLiveTables(context.database); if (ttlTables.containsKey(theTable.toUpperCase())) { return makeQuickResponse(ClientResponse.GRACEFUL_FAILURE, String.format("Table %s cannot be swapped since it uses TTL.",theTable)); } return runNonDDLAdHoc(context, sqlStatements, true, null, ExplainMode.NONE, false, true, userParams); }
Source:
<code><START> public void testAddAdd() throws Exception { <END> Note add1 = newNote("add1"); Note add2 = newNote("add2"); Note result = merger.merge(baseNote, add1, add2); assertEquals(result, noteOn); assertEquals(result.getData(), tr.blob("add1add2")); result = merger.merge(baseNote, add2, add1); assertEquals(result, noteOn); assertEquals(result.getData(), tr.blob("add2add1")); }</code><technical_language>difference compared testEditEdit()</technical_language>

Target:
public void testAddAdd() throws Exception { Note add1 = newNote("add1"); Note add2 = newNote("add2"); Note result = merger.merge(null, add1, add2); assertEquals(result, noteOn); assertEquals(result.getData(), tr.blob("add1add2")); result = merger.merge(null, add2, add1); assertEquals(result, noteOn); assertEquals(result.getData(), tr.blob("add2add1")); }
Source:
<code>public static BackupPhase map(org.ovirt.engine.core.common.businessentities.VmBackupPhase action) { switch (action) { case <START> Initializing: <END> return BackupPhase.INITIALIZING; case Starting: return BackupPhase.STARTING; case Ready: return BackupPhase.READY; case Finalizing: return BackupPhase.FINALIZING; default: return null; } }</code><technical_language>please this upper case</technical_language>

Target:
public static BackupPhase map(org.ovirt.engine.core.common.businessentities.VmBackupPhase action) { switch (action) { case INITIALIZING: return BackupPhase.INITIALIZING; case STARTING: return BackupPhase.STARTING; case READY: return BackupPhase.READY; case FINALIZING: return BackupPhase.FINALIZING; default: return null; } }
Source:
<code>private Optional<Symbol> getSymbol(RelationPlan plan, Expression expression) { <START> if (!analysis.isColumnReference(expression)) { <END> return Optional.empty(); } return plan.getScope() .tryResolveField(expression) .filter(ResolvedField::isLocal) .map(field -> plan.getFieldMappings().get(field.getHierarchyFieldIndex())); }</code><technical_language>this is needed? Is some query fails this is fail-safe? add check state expression is column reference</technical_language>

Target:
private Optional<Symbol> getSymbol(RelationPlan plan, Expression expression) { if (!analysis.isColumnReference(expression)) { return Optional.empty(); } return plan.getScope() .tryResolveField(expression) .filter(ResolvedField::isLocal) .map(field -> requireNonNull(plan.getFieldMappings().get(field.getHierarchyFieldIndex()))); }
Source:
<code>protected boolean shouldDrawBox(TraditionalMemoryByte bytes[], int col) { TraditionalRendering ren = fRendering.getTraditionalRendering(); if(ren.getBoxEdit()) <START> for(TraditionalMemoryByte tmb : bytes) <END> if(tmb.isEdited()) return true; if(ren.getBoxChanged()) for(int i = 0; i < fRendering.getHistoryDepth(); i++) for(TraditionalMemoryByte tmb : bytes) if(tmb.isChanged(i)) return true; return false; }</code><technical_language>Braces, please! Especially commands here, works is if statement..</technical_language>

Target:
protected boolean shouldDrawBox(TraditionalMemoryByte bytes[], int col) { TraditionalRendering ren = fRendering.getTraditionalRendering(); if (ren.getBoxEdit()) { for (TraditionalMemoryByte tmb : bytes) { if (tmb.isEdited()) { return true; } } } if (ren.getBoxChanged()) { for (int i = 0; i < fRendering.getHistoryDepth(); i++) { for (TraditionalMemoryByte tmb : bytes) { if (tmb.isChanged(i)) { return true; } } } } return false; }
Source:
<code>private static File findNodeInCurrentFileSystem(){ Runtime rt = Runtime.getRuntime(); String instancePath; try { Process p = rt.exec(returnCommandThatSearchesForDefaultNode()); p.waitFor(); instancePath = getProcessOutput(p.getInputStream()); } catch (Exception e) { throw new RuntimeException(e); } File result; if (StringUtils.isBlank(instancePath) || !(result = new File(instancePath + File.separator + NODE_MODULES_FOLDER + APPIUM_NODE_MASK)).exists()) <START> throw new InvalidServerInstanceException( "There is no installed nodes! Please install " + <END> " node via NPM (<LINK_0> or download and " + "install Appium app (<LINK_1>", new IOException("There is no installed nodes! Please install " + " node via NPM (<LINK_0> or download and " + "install Appium app (<LINK_1>")); return result; }</code><technical_language>I this error message referenced a String instead of duplicated</technical_language>

Target:
private static File findNodeInCurrentFileSystem(){ Runtime rt = Runtime.getRuntime(); String instancePath; try { Process p = rt.exec(returnCommandThatSearchesForDefaultNode()); p.waitFor(); instancePath = getProcessOutput(p.getInputStream()); } catch (Exception e) { throw new RuntimeException(e); } File result; if (StringUtils.isBlank(instancePath) || !(result = new File(instancePath + File.separator + NODE_MODULES_FOLDER + APPIUM_NODE_MASK)).exists()) throw new InvalidServerInstanceException( "There is no installed nodes! Please install " + " node via NPM (<LINK_0> or download and " + "install Appium app (<LINK_1>", new IOException("The installed appium node package has not been found.")); return result; }
Source:
<code>private BuildAction getBuildAction(IWorkbenchWindow window) { BuildAction buildAction = (BuildAction) buildActions.get(window); if (buildAction != null) { return buildAction; } buildAction = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD); buildActions.put(window, buildAction); <START> window.addPageListener(new IPageListener() { <END> public void pageOpened(IWorkbenchPage page) { } public void pageClosed(IWorkbenchPage page) { IWorkbenchWindow closedWindow = page.getWorkbenchWindow(); buildActions.remove(closedWindow); closedWindow.removePageListener(this); } public void pageActivated(IWorkbenchPage page) { } }); return buildAction; }</code><technical_language>This pattern is good, need a level. window.getWorkbench().addWindowListener(...) close remove window action. add this listener manage windows way</technical_language>

Target:
private BuildAction getBuildAction(IWorkbenchWindow window) { BuildAction buildAction = (BuildAction) buildActions.get(window); if (buildAction != null) { return buildAction; } buildAction = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD); buildActions.put(window, buildAction); return buildAction; }
Source:
<code>public IStatus transferSettings(IPath newWorkspaceRoot) { try { IPath currentLocation = getNewWorkbenchStateLocation(Platform.getLocation()); File workspaceFile = createFileAndDirectories(newWorkspaceRoot); if (workspaceFile == null) return new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, WorkbenchMessages.WorkbenchSettings_CouldNotCreateDirectories); File deltas = new File(currentLocation.toOSString(), "deltas.xml"); if (deltas.exists()) { <START> byte[] bytes = new byte[8192]; <END> FileOutputStream outputStream; try (FileInputStream inputStream = new FileInputStream(deltas)) { outputStream = new FileOutputStream(new File(workspaceFile, "deltas.xml")); int read = inputStream.read(bytes, 0, 8192); while (read != -1) { outputStream.write(bytes, 0, read); read = inputStream.read(bytes, 0, 8192); } } outputStream.close(); } File workbenchModel = new File(currentLocation.toOSString(), "workbench.xmi"); if (workbenchModel.exists()) { byte[] bytes = new byte[8192]; FileOutputStream outputStream; try (FileInputStream inputStream = new FileInputStream(workbenchModel)) { outputStream = new FileOutputStream(new File(workspaceFile, "workbench.xmi")); int read = inputStream.read(bytes, 0, 8192); while (read != -1) { outputStream.write(bytes, 0, read); read = inputStream.read(bytes, 0, 8192); } } outputStream.close(); } } catch (IOException e) { return new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, WorkbenchMessages.Workbench_problemsSavingMsg, e); } return Status.OK_STATUS; }</code><technical_language>in next method: is output stream in try()</technical_language>

Target:
public IStatus transferSettings(IPath newWorkspaceRoot) { try { IPath currentLocation = getNewWorkbenchStateLocation(Platform.getLocation()); File workspaceFile = createFileAndDirectories(newWorkspaceRoot); if (workspaceFile == null) return new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, WorkbenchMessages.WorkbenchSettings_CouldNotCreateDirectories); File deltas = new File(currentLocation.toOSString(), "deltas.xml"); if (deltas.exists()) { byte[] bytes = new byte[8192]; try (FileInputStream inputStream = new FileInputStream(deltas); FileOutputStream outputStream = new FileOutputStream(new File(workspaceFile, "deltas.xml")); ) { int read = inputStream.read(bytes, 0, 8192); while (read != -1) { outputStream.write(bytes, 0, read); read = inputStream.read(bytes, 0, 8192); } } } File workbenchModel = new File(currentLocation.toOSString(), "workbench.xmi"); if (workbenchModel.exists()) { byte[] bytes = new byte[8192]; try (FileInputStream inputStream = new FileInputStream(workbenchModel); FileOutputStream outputStream = new FileOutputStream(new File(workspaceFile, "workbench.xmi")); ) { int read = inputStream.read(bytes, 0, 8192); while (read != -1) { outputStream.write(bytes, 0, read); read = inputStream.read(bytes, 0, 8192); } } } } catch (IOException e) { return new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, WorkbenchMessages.Workbench_problemsSavingMsg, e); } return Status.OK_STATUS; }
Source:
<code>private ExtensionEntry(Properties props, File file) { this.file = file; this.name = props.getProperty( Base.ConfigKeys.NAME, String.format("__unamed_%1$03d__", extensionNameIndex++) ); this.enabled = Boolean.valueOf(props.getProperty(Base.ConfigKeys.ENABLED, "true")); <START> this.isDefault = Boolean.valueOf(props.getProperty(Authn.ConfigKeys.DEFAULT.getUuid().getName(), "false")); <END> }</code><technical_language>Do need this? access extension configuration Properties instance, getContext().get(CONFIGURATION).getProperty(DEFAULT_PROFILE)</technical_language>

Target:
private ExtensionEntry(Properties props, File file) { this.file = file; this.name = props.getProperty( Base.ConfigKeys.NAME, String.format("__unamed_%1$03d__", extensionNameIndex++) ); this.enabled = Boolean.valueOf(props.getProperty(Base.ConfigKeys.ENABLED, "true")); }
Source:
<code>protected List<WorkflowStep> getCompletedSteps() { switch (nextStepNumber) { case 0: return Collections.emptyList(); case 1: return Collections.singletonList(step0); default: <START> return Arrays.asList(step0, step1); <END> } }</code><technical_language>previous suggestion separate references step0 step1 specific types for convenience avoid casting, remove List<ProgressStep>. simplify this some other methods if list separate references, is more convenient time: * need pool, step1.getInput() * this method previous implementation - return steps.subList(0, nextStepNumber);</technical_language>

Target:
protected List<WorkflowStep> getCompletedSteps() { return steps.subList(0, nextStepNumber); }
Source:
<code>public Time(String timeStr) { <START> if (timeStr.length() == 11) { <END> DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("HH:mm Z"); DateTime localTime = DateTime.parse(timeStr, dateTimeFormatter).withZone(DateTimeZone.UTC); this.hour = localTime.getHourOfDay(); this.minute = localTime.getMinuteOfHour(); } else { String[] tokens = timeStr.split(":"); if (tokens.length < TIME_TOKEN_MIN_LENGTH || tokens.length > TIME_TOKEN_MAX_LENGTH) { throw new IllegalArgumentException("Invalid time string: " + timeStr); } try { this.hour = Integer.parseInt(tokens[0]); this.minute = Integer.parseInt(tokens[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid time string: " + timeStr, e); } } }</code><technical_language>move this separate method 'isTimeContainsZone</technical_language>

Target:
public Time(String timeStr) { if (isTimeContainsZone(timeStr)) { DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("HH:mm Z"); DateTime localTime = DateTime.parse(timeStr, dateTimeFormatter).withZone(DateTimeZone.UTC); this.hour = localTime.getHourOfDay(); this.minute = localTime.getMinuteOfHour(); } else { String[] tokens = timeStr.split(":"); if (tokens.length < TIME_TOKEN_MIN_LENGTH || tokens.length > TIME_TOKEN_MAX_LENGTH) { throw new IllegalArgumentException("Invalid time string: " + timeStr); } try { this.hour = Integer.parseInt(tokens[0]); this.minute = Integer.parseInt(tokens[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid time string: " + timeStr, e); } } }
Source:
<code>public Condition(CodedOrFreeText condition, ConditionClinicalStatus clinicalStatus, ConditionVerificationStatus verificationStatus, Condition previousVersion, String additionalDetail, Date onsetDate, Date endDate, Patient patient) { this.condition = condition; this.clinicalStatus = clinicalStatus; this.verificationStatus = verificationStatus; this.previousVersion = previousVersion; this.additionalDetail = additionalDetail; <START> this.onsetDate = new Date(onsetDate.getTime()); <END> this.endDate = new Date(endDate.getTime()); this.patient = patient; }</code><technical_language>happens, if onsetDate endDate is null</technical_language>

Target:
public Condition(CodedOrFreeText condition, ConditionClinicalStatus clinicalStatus, ConditionVerificationStatus verificationStatus, Condition previousVersion, String additionalDetail, Date onsetDate, Date endDate, Patient patient) { this.condition = condition; this.clinicalStatus = clinicalStatus; this.verificationStatus = verificationStatus; this.previousVersion = previousVersion; this.additionalDetail = additionalDetail; this.onsetDate = onsetDate != null ? new Date(onsetDate.getTime()) : null; this.endDate = endDate != null ? new Date(endDate.getTime()) : null; this.patient = patient; }
Source:
<code>public void update(Observable arg0, Object argN) { if (arg0 != player) { return; } final String arg1 = OoyalaNotification.getNameOrUnknown(argN); if (arg1 == OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME) { return; } if (arg1 == OoyalaPlayer.ERROR_NOTIFICATION_NAME) { final String msg = "Error Event Received"; if (player != null && player.getError() != null) { Log.e(TAG, msg, player.getError()); } else { Log.e(TAG, msg); } return; } String text="Notification Received: " + arg1 + " - state: " + player.getState(); playbacklog.writeToSdcardLog(text); <START> Log.d(TAG, "Notification Received: " + arg1 + " - state: " + player.getState()); <END> }</code><technical_language>text variable in Log. stuff. Please do for Activities applied change :)</technical_language>

Target:
public void update(Observable arg0, Object argN) { if (arg0 != player) { return; } final String arg1 = OoyalaNotification.getNameOrUnknown(argN); if (arg1 == OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME) { return; } if (arg1 == OoyalaPlayer.ERROR_NOTIFICATION_NAME) { final String msg = "Error Event Received"; if (player != null && player.getError() != null) { Log.e(TAG, msg, player.getError()); } else { Log.e(TAG, msg); } return; } String text="Notification Received: " + arg1 + " - state: " + player.getState(); playbacklog.writeToSdcardLog(text); Log.d(TAG, text); }
Source:
<code>private void reserveSpace(int reserve) { clockLock.lock(); try { long live = liveBytes + reserve; if (maxBytes < live) { Ref prev = clockHand; Ref hand = clockHand.next; do { if (hand.hot) { hand.hot = false; prev = hand; hand = hand.next; continue; } else if (prev == hand) break; Ref dead = hand; hand = hand.next; prev.next = hand; dead.next = null; dead.value = null; live -= dead.size; dead.pack.cachedSize.addAndGet(-dead.size); int slot = slot(dead.pack, dead.position); for (HashEntry entry = table <START> .get(slot); entry != null; entry = entry.next) { <END> if (entry.ref == dead) { ReentrantLock regionLock = lockFor(dead.pack, dead.position); regionLock.lock(); try { table.compareAndSet(slot, entry, clean(entry)); break; } finally { regionLock.unlock(); } } } statEvict++; } while (maxBytes < live); clockHand = prev; } liveBytes = live; } finally { clockLock.unlock(); } }</code><technical_language>Yes, cache leaks entry in hash table, this is HashEntry chain handle child Ref node. actual byte[] nulled out dead.value = null line 405. byte[] immediately reclaimed Java GC. I previously bother clean hash table chain clock eviction I assumed touch hash table chains soon enough other accesses eventually clean orphaned nodes out of buckets</technical_language>

Target:
private void reserveSpace(int reserve) { clockLock.lock(); try { long live = liveBytes + reserve; if (maxBytes < live) { Ref prev = clockHand; Ref hand = clockHand.next; do { if (hand.hot) { hand.hot = false; prev = hand; hand = hand.next; continue; } else if (prev == hand) break; Ref dead = hand; hand = hand.next; prev.next = hand; dead.next = null; dead.value = null; live -= dead.size; dead.pack.cachedSize.addAndGet(-dead.size); statEvict++; } while (maxBytes < live); clockHand = prev; } liveBytes = live; } finally { clockLock.unlock(); } }
Source:
<code>public void accumulateValue(Long newValue) { <START> setValue(newValue + getValue()); <END> }</code><technical_language>This is thread safe. Is guaranteed this called in a single thread? this guarantee hold if Nimbus is sweeping products once? this safe clear future this is issue need fix</technical_language>

Target:
public void accumulateValue(Long newValue) { value.addAndGet(newValue); }
Source:
<code>public String addStorageResource(StorageResourceDescription description) throws AppCatalogException { try { final String storageResourceId = AppCatalogUtils.getID(description.getHostName()); <START> if (description.getStorageResourceDescription().equals("") || description.getStorageResourceId().equals(airavata_commonsConstants.DEFAULT_ID)) { <END> description.setStorageResourceId(storageResourceId); } description.setCreationTime(System.currentTimeMillis()); if (description.getDataMovementInterfaces() != null) { description.getDataMovementInterfaces().stream().forEach(dm -> dm.setStorageResourceId(description.getStorageResourceId())); } StorageResourceDescription storageResourceDescription = create(description); return storageResourceDescription.getStorageResourceId(); } catch (Exception e) { logger.error("Error while saving storage resource...", e); throw new AppCatalogException(e); } }</code><technical_language>Surely logic if description.getStorageResourceId().equals(""), description</technical_language>

Target:
public String addStorageResource(StorageResourceDescription description) throws AppCatalogException { try { final String storageResourceId = AppCatalogUtils.getID(description.getHostName()); if ("".equals(description.getStorageResourceId()) || airavata_commonsConstants.DEFAULT_ID.equals(description.getStorageResourceId())) { description.setStorageResourceId(storageResourceId); } description.setCreationTime(System.currentTimeMillis()); if (description.getDataMovementInterfaces() != null) { description.getDataMovementInterfaces().stream().forEach(dm -> dm.setStorageResourceId(description.getStorageResourceId())); } StorageResourceDescription storageResourceDescription = create(description); return storageResourceDescription.getStorageResourceId(); } catch (Exception e) { logger.error("Error while saving storage resource. StorageResourceId : " + description.getStorageResourceId() + "" + " HostName : " + description.getHostName(), e); throw new AppCatalogException("Error while saving storage resource. StorageResourceId : " + description.getStorageResourceId() + "" + " HostName : " + description.getHostName(), e); } }
Source:
<code>public Object get(ByteBuffer buf, int position) { int size = card.sizeof(); byte[] bytes = new byte[size]; <START> for (int i = 0; i < size; i++) { <END> bytes[i] = buf.get(position + i); } ICardinality cardinalityCounter = new AdaptiveCounting(bytes); return cardinalityCounter; }</code><technical_language>bulk get ftw</technical_language>

Target:
public Object get(ByteBuffer buf, int position) { int size = card.sizeof(); byte[] bytes = new byte[size]; ByteBuffer copy = buf.duplicate(); copy.position(position); copy.get(bytes, 0, size); ICardinality cardinalityCounter = new AdaptiveCounting(bytes); return cardinalityCounter; }
Source:
<code>public void burn() { int ogLogAmount = ctx.inventory.select().id(logChoiceID).count(); Item tinder = ctx.inventory.select().id(tinder_id).poll(); Item log = ctx.inventory.select().id(logChoiceID).poll(); <START> log.interact("Use"); <END> tinder.interact(("Use")); Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return ctx.players.local().animation() == -1; } }); Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return ctx.players.local().animation() == -1; } }); int newLogAmount = ctx.inventory.select().id(logChoiceID).count(); if (ogLogAmount == newLogAmount) { int randomX = org.powerbot.script.Random.nextInt(0,5); int randomY = org.powerbot.script.Random.nextInt(-2, 2); Tile randomTile = ctx.players.local().tile().derive(randomX,randomY); ctx.movement.step(randomTile); } }</code><technical_language>if game lags, disconnects? For example, this method click log, instantly snap tinderbox, click it, wait for animation finish (twice...?). need add conditional waits, below</technical_language>

Target:
public void burn() { int ogLogAmount = ctx.inventory.select().id(logChoiceID).count(); Item tinder = ctx.inventory.select().id(tinder_id).poll(); Item log = ctx.inventory.select().id(logChoiceID).poll(); log.interact("Use"); Condition.sleep(100); tinder.interact(("Use")); Condition.sleep(700); ctx.inventory.select().id(logChoiceID).peek().hover(); Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return ctx.players.local().animation() == -1 && !ctx.players.local().inMotion(); } }); int newLogAmount = ctx.inventory.select().id(logChoiceID).count(); if (ogLogAmount == newLogAmount) { Tile bestOption = calcBestNewStartingSpot(); ctx.movement.step(bestOption); Condition.wait(new Callable<Boolean>() { @Override public Boolean call() throws Exception { return !ctx.players.local().inMotion(); } }); } }
Source:
<code>private void translateV1VolumesToV2(Map<String, Object> cattleServiceData, Map<String, Object> composeServiceData, Map<String, Object> volumesData) { String volumeDriver = String.valueOf(cattleServiceData.get(ComposeExportConfigItem.VOLUME_DRIVER .getCattleName())); if (StringUtils.isEmpty(volumeDriver)) { return; } <START> if ("null".equals(volumeDriver)) { <END> volumeDriver = VolumeConstants.LOCAL_DRIVER; } composeServiceData.remove(ComposeExportConfigItem.VOLUME_DRIVER .getDockerName()); Object dataVolumes = cattleServiceData.get(InstanceConstants.FIELD_DATA_VOLUMES); if (dataVolumes == null) { return; } for (String dataVolume : (List<String>) dataVolumes) { String[] splitted = dataVolume.split(":"); if (splitted.length < 2) { continue; } String dataVolumeName = splitted[0]; Path p = Paths.get(dataVolumeName); if (p.isAbsolute()) { continue; } if (volumesData.containsKey(dataVolumeName)) { continue; } Map<String, Object> cattleVolumeData = new HashMap<>(); cattleVolumeData.put(ServiceConstants.FIELD_VOLUME_EXTERNAL, true); cattleVolumeData.put(ServiceConstants.FIELD_VOLUME_DRIVER, volumeDriver); Map<String, Object> composeVolumeData = new HashMap<>(); for (String cattleVolume : cattleVolumeData.keySet()) { translateRancherToCompose(true, cattleVolumeData, composeVolumeData, cattleVolume, null, true); } if (!composeVolumeData.isEmpty()) { volumesData.put(dataVolumeName, composeVolumeData); } } }</code><technical_language>wrong fix. correct fix is String.valudOf() above. is returning "null" is null</technical_language>

Target:
private void translateV1VolumesToV2(Map<String, Object> cattleServiceData, Map<String, Object> composeServiceData, Map<String, Object> volumesData) { String volumeDriver = ObjectUtils.toString((cattleServiceData.get(ComposeExportConfigItem.VOLUME_DRIVER .getCattleName()))); if (StringUtils.isBlank(volumeDriver)) { return; } composeServiceData.remove(ComposeExportConfigItem.VOLUME_DRIVER .getDockerName()); Object dataVolumes = cattleServiceData.get(InstanceConstants.FIELD_DATA_VOLUMES); if (dataVolumes == null) { return; } for (String dataVolume : (List<String>) dataVolumes) { String[] splitted = dataVolume.split(":"); if (splitted.length < 2) { continue; } String dataVolumeName = splitted[0]; Path p = Paths.get(dataVolumeName); if (p.isAbsolute()) { continue; } if (volumesData.containsKey(dataVolumeName)) { continue; } Map<String, Object> cattleVolumeData = new HashMap<>(); cattleVolumeData.put(ServiceConstants.FIELD_VOLUME_EXTERNAL, true); cattleVolumeData.put(ServiceConstants.FIELD_VOLUME_DRIVER, volumeDriver); Map<String, Object> composeVolumeData = new HashMap<>(); for (String cattleVolume : cattleVolumeData.keySet()) { translateRancherToCompose(true, cattleVolumeData, composeVolumeData, cattleVolume, null, true); } if (!composeVolumeData.isEmpty()) { volumesData.put(dataVolumeName, composeVolumeData); } } }
Source:
<code><START> private boolean containsAny(List<? extends EObject> sequence1, List<? extends EObject> sequence2) { <END> for (EObject o2 : sequence2) { if (sequence1.contains(o2)) { return true; } } return false; }</code><technical_language>Iterales.any(sequence2, Predicates.in(sequence1)) instead</technical_language>

Target:
private boolean containsAny(List<? extends EObject> sequence1, List<? extends EObject> sequence2) { return Iterables.any(sequence2, Predicates.in(sequence1)); }
Source:
<code><START> public static ParseResult<CompilationUnit> parse(final String code, <END> final String encoding, boolean considerComments) throws ParseException { try { InputStream in = SourcesHelper.stringToStream(code, encoding); ASTParser astParser = new ASTParser(in, encoding); CompilationUnit cu = astParser.CompilationUnit(); if (considerComments) { insertComments(cu, code); } return new ParseResult<CompilationUnit>(cu, astParser.getTokens()); } catch (IOException ioe) { throw new ParseException(ioe.getMessage()); } }</code><technical_language>maintain compatibility method name return type a new method named "parseWithTokens" similar. new method return ParseResult method name ("parse") call new method, node throw tokens. do think? I a bit repetitive write in this stay compatible offer a clean interface for users interested in tokens, while giving information users interested in nodes tokens</technical_language>

Target:
public static CompilationUnit parse(final String code, final String encoding, boolean considerComments) throws ParseException { return parseToResult(code, encoding, considerComments).getNode(); }
Source:
<code>private static <B extends Message.Builder> Class<B> getBuilderForType(TypeUrl typeUrl) { Class<B> builderClass; try { <START> builderClass = (Class<B>) Class.forName(KnownTypes.getClassName(typeUrl).value()) <END> .getClasses()[0]; } catch (ClassNotFoundException | ClassCastException e) { builderClass = null; } return builderClass; }</code><technical_language>Please extract variable for class name</technical_language>

Target:
private static <B extends Message.Builder> Class<B> getBuilderForType(TypeUrl typeUrl) { Class<B> builderClass; final String className = KnownTypes.getClassName(typeUrl) .value(); try { builderClass = (Class<B>) Class.forName(className) .getClasses()[0]; } catch (ClassNotFoundException e) { final String message = String.format( BUILDER_CLASS_ERROR_LOGGING_PATTERN, className); log().warn(message, e); builderClass = null; } catch (ClassCastException e) { final String message = String.format( TYPE_CAST_ERROR_LOGGING_PATTERN, className); log().warn(message, e); builderClass = null; } return builderClass; }
Source:
<code>public ResponseEntity<String> searchEvent(EventSearch eventSearch) { try { return getResponseHandler() .setDataAdapter(new EventSearchAdapter(userEventService)) .success(eventService.searchEvent(eventSearch)); <START> } catch (final Exception e) { <END> LOGGER.error(EGOV_API_ERROR, e); return getResponseHandler().error(getMessage(SERVER_ERROR_KEY)); } }</code><technical_language>Please exception handler catch exception remove try catch block</technical_language>

Target:
public ResponseEntity<String> searchEvent(EventSearch eventSearch) { return getResponseHandler() .setDataAdapter(new EventSearchAdapter(userEventService)) .success(eventService.searchEvent(eventSearch)); }
Source:
<code>private static boolean mbusShortIdMatches(final MbusChannelElementsDto mbusChannelElements, final ChannelElementValuesDto channelElementValues) { <START> final boolean hasMbusDeviceInfo = mbusChannelElements.hasMbusIdentificationNumber() <END> && mbusChannelElements.hasMbusManufacturerIdentification() && mbusChannelElements.hasMbusVersion() && mbusChannelElements.hasMbusDeviceTypeIdentification(); final boolean hasMbusChannelElementMatch = Objects.equals(mbusChannelElements.getMbusIdentificationNumber(), channelElementValues.getIdentificationNumber()) && Objects.equals(mbusChannelElements.getMbusManufacturerIdentification(), channelElementValues.getManufacturerIdentification()) && Objects.equals(mbusChannelElements.getMbusVersion(), channelElementValues.getVersion()) && Objects.equals(mbusChannelElements.getMbusDeviceTypeIdentification(), channelElementValues.getDeviceTypeIdentification()); return hasMbusDeviceInfo && hasMbusChannelElementMatch; }</code><technical_language>Extract hasMbusDeviceInfo hasMbusChannelElementMatch separate methods, do return this.checkMbusDeviceInfo() && this.hasMbusChannelElementMatch(); in this method</technical_language>

Target:
private static boolean mbusShortIdMatches(final MbusChannelElementsDto mbusChannelElements, final ChannelElementValuesDto channelElementValues) { return hasMbusDeviceInfo(mbusChannelElements) && hasMbusChannelElementMatch(mbusChannelElements, channelElementValues); }
Source:
<code>private static Color getColor(int type) { switch (type) { case FilterParserLexer.OP: return <START> new Color(0, 1, 0, 1); <END> case FilterParserLexer.TEXT: return new Color(0, 0, 0, 1); case FilterParserLexer.SEPARATOR: return new Color(0, 0, 1, 1); default: return new Color(0, 0, 0, 1); } }</code><technical_language>statically define colors, instead of a new Color time</technical_language>

Target:
private static Color getColor(int type) { switch (type) { case FilterParserLexer.OP: return OPERATION_COLOR; case FilterParserLexer.TEXT: return TEXT_COLOR; case FilterParserLexer.SEPARATOR: return SEPARATOR_COLOR; default: return TEXT_COLOR; } }
Source:
<code>public static JobDetail scheduleImport(Owner owner, String storedFileId, String uploadedFileName, ConflictOverrides overrides) { JobDataMap map = new JobDataMap(); map.put(JobStatus.OWNER_ID, owner.getKey()); map.put(JobStatus.TARGET_TYPE, JobStatus.TargetType.OWNER); map.put(JobStatus.TARGET_ID, owner.getKey()); map.put(STORED_FILE_ID, storedFileId); map.put(UPLOADED_FILE_NAME, uploadedFileName); map.put(CONFLICT_OVERRIDES, overrides.asStringArray()); map.put(JobStatus.CORRELATION_ID, MDC.get("csid")); <START> log.info("CSID: " + map.get(JobStatus.CORRELATION_ID)); <END> JobDetail detail = newJob(ImportJob.class) .withIdentity("import_" + Util.generateUUID()) .usingJobData(map) .build(); return detail; }</code><technical_language>Is this log statement necessary</technical_language>

Target:
public static JobDetail scheduleImport(Owner owner, String storedFileId, String uploadedFileName, ConflictOverrides overrides) { JobDataMap map = new JobDataMap(); map.put(JobStatus.OWNER_ID, owner.getKey()); map.put(JobStatus.TARGET_TYPE, JobStatus.TargetType.OWNER); map.put(JobStatus.TARGET_ID, owner.getKey()); map.put(STORED_FILE_ID, storedFileId); map.put(UPLOADED_FILE_NAME, uploadedFileName); map.put(CONFLICT_OVERRIDES, overrides.asStringArray()); map.put(JobStatus.CORRELATION_ID, MDC.get(LoggingFilter.CSID)); JobDetail detail = newJob(ImportJob.class) .withIdentity("import_" + Util.generateUUID()) .usingJobData(map) .build(); return detail; }
Source:
<code>private VDS getVdsFromRunningVm(VM vm) { <START> return DbFacade.getInstance().getVdsDao().get(vm.getRunOnVds()); <END> }</code><technical_language>s/DbFacade.getInstance().getVdsDao()/getVdsDAO/</technical_language>

Target:
private VDS getVdsFromRunningVm(VM vm) { return getVdsDAO().get(vm.getRunOnVds()); }
Source:
<code>private void createVolume(final GlusterVolumeEntity volume) { if (volume.getBricks() == null) { log.warn("Bricks of volume '{}' were not fetched. " + "Hence will not add it to engine at this point.", volume.getName()); return; } for (GlusterBrickEntity brick : volume.getBricks()) { if (brick == null) { log.warn("Volume '{}' contains a apparently corrupt brick(s). " + "Hence will not add it to engine at this point.", volume.getName()); return; } else if (brick.getServerId() == null) { log.warn("Volume '{}' contains brick(s) from unknown hosts. " + "Hence will not add it to engine at this point.", volume.getName()); return; } brick.setStatus(volume.getStatus()); } logUtil.logVolumeMessage(volume, AuditLogType.GLUSTER_VOLUME_CREATED_FROM_CLI); log.debug("Volume '{}' has been created directly using the gluster CLI. Creating it in engine as well.", volume.getName()); getVolumeDao().save(volume); if (volume.getName().equals(Config.<String> getValue(ConfigValues.GlusterMetaVolumeName))) { log.debug("Mounting gluster meta volume on nodes of cluster '{}'", volume.getVdsGroupName()); <START> mountMetaVolumeOnNodes(volume.getClusterId()); <END> } }</code><technical_language>if volume is started? Gluster mount fail volume is started</technical_language>

Target:
private void createVolume(final GlusterVolumeEntity volume) { if (volume.getBricks() == null) { log.warn("Bricks of volume '{}' were not fetched. " + "Hence will not add it to engine at this point.", volume.getName()); return; } for (GlusterBrickEntity brick : volume.getBricks()) { if (brick == null) { log.warn("Volume '{}' contains a apparently corrupt brick(s). " + "Hence will not add it to engine at this point.", volume.getName()); return; } else if (brick.getServerId() == null) { log.warn("Volume '{}' contains brick(s) from unknown hosts. " + "Hence will not add it to engine at this point.", volume.getName()); return; } brick.setStatus(volume.getStatus()); } logUtil.logVolumeMessage(volume, AuditLogType.GLUSTER_VOLUME_CREATED_FROM_CLI); log.debug("Volume '{}' has been created directly using the gluster CLI. Creating it in engine as well.", volume.getName()); getVolumeDao().save(volume); }
Source:
<code>public void <START> testCreateInvalidConfigAeadWithAuthAndCrypt() <END> throws Exception { IpSecConfig ipSecConfig = buildBasicIpSecConfig(); for (int direction : directions) { ipSecConfig.setAuthentication(direction, authAlgo); ipSecConfig.setEncryption(direction, encryptAlgo); try { ipSecConfig.setAuthenticatedEncryption(direction, aeadAlgo); } catch (IllegalArgumentException expected) { } } try { mIpSecService.createTransportModeTransform(ipSecConfig, new Binder()); fail( "IpSecService should have thrown an error on authentication and encryption being" + " enabled with authenticated encryption"); } catch (IllegalArgumentException expected) { } }</code><technical_language>composition, do need this</technical_language>

Target:
public void testCreateInvalidConfigAeadWithAuthAndCrypt() throws Exception { IpSecConfig ipSecConfig = new IpSecConfig(); addDefaultSpisAndRemoteAddrToIpSecConfig(ipSecConfig); for (int direction : DIRECTIONS) { ipSecConfig.setAuthentication(direction, AUTH_ALGO); ipSecConfig.setEncryption(direction, CRYPT_ALGO); try { ipSecConfig.setAuthenticatedEncryption(direction, AEAD_ALGO); } catch (IllegalArgumentException expected) { } } try { mIpSecService.createTransportModeTransform(ipSecConfig, new Binder()); fail( "IpSecService should have thrown an error on authentication and encryption being" + " enabled with authenticated encryption"); } catch (IllegalArgumentException expected) { } }
Source:
<code>public List<Pattern> createPatternObjects(Map<String, Stop> stopById, SQLErrorStorage errorStorage) { int nextPatternId = 1; List<Pattern> patterns = new ArrayList<>(); for (TripPatternKey key : tripsForPattern.keySet()) { Collection<Trip> trips = tripsForPattern.get(key); Pattern pattern = new Pattern(key.stops, trips, null); pattern.pattern_id = Integer.toString(nextPatternId++); pattern.associatedShapes = new HashSet<>(); <START> pattern.associatedShapes <END> .addAll(trips.stream().map(trip -> trip.shape_id).collect(Collectors.toList())); if (pattern.associatedShapes.size() > 1) { errorStorage.storeError(NewGTFSError.forEntity( pattern, NewGTFSErrorType.MULTIPLE_SHAPES_FOR_PATTERN) .setBadValue(pattern.associatedShapes.toString())); } pattern.patternStops = new ArrayList<>(); for (int i = 0; i < key.stops.size(); i++) { int dwellTime = key.departureTimes.get(i) - key.arrivalTimes.get(i); int travelTime = 0; String stopId = key.stops.get(i); if (i > 0) travelTime = key.arrivalTimes.get(i) - key.departureTimes.get(i - 1); double shapeDistTraveled = key.shapeDistances.get(i); pattern.patternStops.add( new PatternStop( pattern.pattern_id, stopId, i, travelTime, dwellTime, shapeDistTraveled, key.pickupTypes.get(i), key.dropoffTypes.get(i))); } patterns.add(pattern); } renamePatterns(patterns, stopById); LOG.info("Total patterns: {}", tripsForPattern.keySet().size()); return patterns; }</code><technical_language>I Collectors.toCollection(HashSet::new); here, due weirdness of Java streams I find imperative foreach syntax is clearer</technical_language>

Target:
public Map<TripPatternKey, Pattern> createPatternObjects(Map<String, Stop> stopById, SQLErrorStorage errorStorage) { int nextPatternId = 1; Map<TripPatternKey, Pattern> patterns = new HashMap<>(); for (TripPatternKey key : tripsForPattern.keySet()) { Collection<Trip> trips = tripsForPattern.get(key); Pattern pattern = new Pattern(key.stops, trips, null); pattern.pattern_id = Integer.toString(nextPatternId++); pattern.associatedShapes = new HashSet<>(); trips.stream().forEach(trip -> pattern.associatedShapes.add(trip.shape_id)); if (pattern.associatedShapes.size() > 1) { errorStorage.storeError(NewGTFSError.forEntity( pattern, NewGTFSErrorType.MULTIPLE_SHAPES_FOR_PATTERN) .setBadValue(pattern.associatedShapes.toString())); } patterns.put(key, pattern); } renamePatterns(patterns.values(), stopById); LOG.info("Total patterns: {}", tripsForPattern.keySet().size()); return patterns; }
Source:
<code>protected void OnEntityChanged() { super.OnEntityChanged(); if (getEntity() != null) { <START> final StorageDomain storageDomain = (StorageDomain) getEntity(); <END> setIsNfs(storageDomain.getStorageType() == StorageType.NFS); setIsLocalS(storageDomain.getStorageType() == StorageType.LOCALFS); setIsPosix(storageDomain.getStorageType() == StorageType.POSIXFS); if (getIsNfs() || getIsLocalS() || getIsPosix()) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object ReturnValue) { StorageServerConnections connection = (StorageServerConnections) ReturnValue; StorageGeneralModel generalModel = (StorageGeneralModel) model; generalModel.setPath(connection == null ? null : connection.getconnection()); if (isPosix) { generalModel.setVfsType(connection.getVfsType()); generalModel.setMountOptions(connection.getMountOptions()); } } }; AsyncDataProvider.GetStorageConnectionById(_asyncQuery, storageDomain.getStorage(), true); } else { setPath(null); } } }</code><technical_language>need for 'final' keyword</technical_language>

Target:
protected void OnEntityChanged() { super.OnEntityChanged(); if (getEntity() != null) { StorageDomain storageDomain = (StorageDomain) getEntity(); setIsNfs(storageDomain.getStorageType() == StorageType.NFS); setIsLocalS(storageDomain.getStorageType() == StorageType.LOCALFS); setIsPosix(storageDomain.getStorageType() == StorageType.POSIXFS); if (getIsNfs() || getIsLocalS() || getIsPosix()) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object ReturnValue) { StorageServerConnections connection = (StorageServerConnections) ReturnValue; StorageGeneralModel generalModel = (StorageGeneralModel) model; generalModel.setPath(connection == null ? null : connection.getconnection()); if (isPosix) { generalModel.setVfsType(connection.getVfsType()); generalModel.setMountOptions(connection.getMountOptions()); } } }; AsyncDataProvider.GetStorageConnectionById(_asyncQuery, storageDomain.getStorage(), true); } else { setPath(null); } } }
Source:
<code>public DefaultJsr107SerializationProvider() { <START> super(new DefaultSerializationProviderConfiguration().addSerializerFor(Object.class, (Class) JavaSerializer.class)); <END> }</code><technical_language>new compact one? ditch JavaSerializer code base altogether</technical_language>

Target:
public DefaultJsr107SerializationProvider() { super(new DefaultSerializationProviderConfiguration() .addSerializerFor(Object.class, (Class) CompactJavaSerializer.class) .addSerializerFor(Object.class, (Class) CompactPersistentJavaSerializer.class)); }
Source:
<code>public static XmlFile getConfigXml(String serverName) { <START> File xmlFile = new File(Jenkins.getInstance().getRootDir() + GERRIT_SERVER_EVENT_DATA_FOLDER <END> + serverName, GERRIT_TRIGGER_SERVER_TIMESTAMPS_XML); xmlFile.getParentFile().mkdirs(); return new XmlFile(Jenkins.XSTREAM, xmlFile); }</code><technical_language>CheckForNull Jenkins.getInstance() Try new File(parent, child) construct instead of string concatenation. jenkins.getRootPath().child(x).child(y)</technical_language>

Target:
public static XmlFile getConfigXml(String serverName) throws IOException { Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { return null; } File dataDir = new File(jenkins.getRootDir(), GERRIT_SERVER_EVENT_DATA_FOLDER); File serverDataDir = new File(dataDir, serverName); serverDataDir.mkdirs(); File xmlFile = new File(serverDataDir, GERRIT_TRIGGER_SERVER_TIMESTAMPS_XML); return new XmlFile(Jenkins.XSTREAM, xmlFile); }