auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void createProject() throws OrmException { final Project.NameKey newProjectNameKey = new Project.NameKey(projectName); final RefRight.Key prk = new RefRight.Key(newProjectNameKey, new RefRight.RefPattern("refs/*"), ApprovalCategory.OWN, ownerId); final RefRight pr = new RefRight(prk); pr.setMaxValue((short) 1); pr.setMinValue((short) 1); db.refRights().insert(Collections.singleton(pr)); final Project newProject = new Project(newProjectNameKey); newProject.setDescription(projectDescription); newProject.setSubmitType(submitType); newProject.setUseContributorAgreements(contributorAgreements); newProject.setUseSignedOffBy(signedOffBy); <START> newProject.setParent(wildProject); <END> db.projects().insert(Collections.singleton(newProject)); }</code><technical_language>suggestion leave this NULL wild project, avoid changing this class altogether</technical_language>

Target:
private void createProject() throws OrmException { final Project.NameKey newProjectNameKey = new Project.NameKey(projectName); final RefRight.Key prk = new RefRight.Key(newProjectNameKey, new RefRight.RefPattern("refs/*"), ApprovalCategory.OWN, ownerId); final RefRight pr = new RefRight(prk); pr.setMaxValue((short) 1); pr.setMinValue((short) 1); db.refRights().insert(Collections.singleton(pr)); final Project newProject = new Project(newProjectNameKey); newProject.setDescription(projectDescription); newProject.setSubmitType(submitType); newProject.setUseContributorAgreements(contributorAgreements); newProject.setUseSignedOffBy(signedOffBy); db.projects().insert(Collections.singleton(newProject)); }
Source:
<code>public void update(StructuredRecord record) { Object val = record.get(fieldName); if (val == null) { return; } sum += ((Number) val).doubleValue(); <START> count++; <END> }</code><technical_language>yeah</technical_language>

Target:
public void update(StructuredRecord record) { Object val = record.get(fieldName); if (val == null) { return; } count++; avg = avg + (((Number) val).doubleValue() - avg) / count; }
Source:
<code>public String reportProblemForAll() { for (Task s : this.steps) { this.currentStep = s; this.myDav.uploadFromHome(this.currentStep.getProcess()); serviceManager.getWorkflowService().setProblem(getProblem()); try { setCurrentStep(serviceManager.getWorkflowService().reportProblem(this.currentStep, this.problemTask)); } catch (DataException e) { <START> logger.error("Problem couldn't be reported: " + e); <END> } saveStep(); } this.problem.setMessage(""); this.problemTask = ""; AktuelleSchritteForm asf = (AktuelleSchritteForm) Helper.getManagedBeanValue("#{AktuelleSchritteForm}"); return asf.filterAll(); }</code><technical_language>2 things: 1) If a DataException is thrown is a good idea on? 2) this kind of error logging work casting exception object string message</technical_language>

Target:
public String reportProblemForAll() { for (Task s : this.steps) { this.currentStep = s; this.myDav.uploadFromHome(this.currentStep.getProcess()); serviceManager.getWorkflowService().setProblem(getProblem()); try { setCurrentStep(serviceManager.getWorkflowService().reportProblem(this.currentStep, this.problemTask)); saveStep(); } catch (DataException e) { logger.error("Problem couldn't be reported: " + e); } } this.problem.setMessage(""); this.problemTask = ""; AktuelleSchritteForm asf = (AktuelleSchritteForm) Helper.getManagedBeanValue("#{AktuelleSchritteForm}"); return asf.filterAll(); }
Source:
<code>public void checkFillSelectionAfterSelectingDatasetAuthentication() throws Exception { enableService(); Bundle clientState = new Bundle(); clientState.putCharSequence("clientStateKey", "clientStateValue"); final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1, new CannedDataset.Builder() .setField(ID_USERNAME, "dude") .setField(ID_PASSWORD, "sweet") .setPresentation(createPresentation("Dataset")) .build()); sReplier.addResponse(new CannedFillResponse.Builder().addDataset( new CannedDataset.Builder() .setField(ID_USERNAME, "username") .setId("name") .setPresentation(createPresentation("authentication")) .setAuthentication(authentication) .build()) .setExtras(clientState).build()); mActivity.onUsername(View::requestFocus); sUiBot.selectDataset("authentication"); sReplier.getNextFillRequest(); eventually(() -> { FillEventHistory selection = InstrumentedAutoFillService.peekInstance() .getFillEventHistory(); assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo( "clientStateValue"); <START> assertThat(selection.getEvents().size()).isEqualTo(2); <END> FillEventHistory.Event event = selection.getEvents().get(0); assertThat(event.getType()).isEqualTo(TYPE_DATASET_AUTHENTICATION_SELECTED); assertThat(event.getDatasetId()).isEqualTo("name"); }); }</code><technical_language>Good news, - this change passed devices. please add a set of assertions for event (type / name / etc)</technical_language>

Target:
public void checkFillSelectionAfterSelectingDatasetAuthentication() throws Exception { enableService(); Bundle clientState = new Bundle(); clientState.putCharSequence("clientStateKey", "clientStateValue"); final IntentSender authentication = AuthenticationActivity.createSender(getContext(), 1, new CannedDataset.Builder() .setField(ID_USERNAME, "dude") .setField(ID_PASSWORD, "sweet") .setPresentation(createPresentation("Dataset")) .build()); sReplier.addResponse(new CannedFillResponse.Builder().addDataset( new CannedDataset.Builder() .setField(ID_USERNAME, "username") .setId("name") .setPresentation(createPresentation("authentication")) .setAuthentication(authentication) .build()) .setExtras(clientState).build()); mActivity.onUsername(View::requestFocus); sUiBot.selectDataset("authentication"); sReplier.getNextFillRequest(); eventually(() -> { FillEventHistory selection = InstrumentedAutoFillService.peekInstance() .getFillEventHistory(); assertThat(selection.getClientState().getCharSequence("clientStateKey")).isEqualTo( "clientStateValue"); assertThat(selection.getEvents().size()).isEqualTo(2); FillEventHistory.Event event1 = selection.getEvents().get(0); assertThat(event1.getType()).isEqualTo(TYPE_DATASET_AUTHENTICATION_SELECTED); assertThat(event1.getDatasetId()).isEqualTo("name"); FillEventHistory.Event event2 = selection.getEvents().get(1); assertThat(event2.getType()).isEqualTo(TYPE_DATASET_SELECTED); assertThat(event2.getDatasetId()).isNull(); }); }
Source:
<code>public void onEditorFragmentInitialized() { boolean shouldFinishInit = true; if (getIntent().hasExtra(EXTRA_INSERT_MEDIA)) { List<MediaModel> mediaList = (List<MediaModel>) getIntent().getSerializableExtra(EXTRA_INSERT_MEDIA); <START> if (mediaList != null && !mediaList.isEmpty()) { <END> shouldFinishInit = false; mMediaInsertedOnCreation = true; for (MediaModel media : mediaList) { addExistingMediaToEditor(media.getMediaId()); } savePostAsync(new AfterSavePostListener() { @Override public void onPostSave() { runOnUiThread(new Runnable() { @Override public void run() { onEditorFinalTouchesBeforeShowing(); } }); } }); } } if (shouldFinishInit) { onEditorFinalTouchesBeforeShowing(); } }</code><technical_language>this point need remove EXTRA_INSERT_MEDIA intent, this run if activity is re-created</technical_language>

Target:
public void onEditorFragmentInitialized() { boolean shouldFinishInit = true; if (getIntent().hasExtra(EXTRA_INSERT_MEDIA)) { List<MediaModel> mediaList = (List<MediaModel>) getIntent().getSerializableExtra(EXTRA_INSERT_MEDIA); getIntent().removeExtra(EXTRA_INSERT_MEDIA); if (mediaList != null && !mediaList.isEmpty()) { shouldFinishInit = false; mMediaInsertedOnCreation = true; for (MediaModel media : mediaList) { addExistingMediaToEditor(media.getMediaId()); } savePostAsync(new AfterSavePostListener() { @Override public void onPostSave() { runOnUiThread(new Runnable() { @Override public void run() { onEditorFinalTouchesBeforeShowing(); } }); } }); } } if (shouldFinishInit) { onEditorFinalTouchesBeforeShowing(); } }
Source:
<code>public String toString() { <START> return "QueuedRequestImpl [requestTicket=" + requestTicket + ", downlinkRequest=" + downlinkRequest <END> + ", endpoint=" + endpoint + ", requestId=" + requestId + "]"; }</code><technical_language>a StringBuilder</technical_language>

Target:
public String toString() { return new StringBuilder().append("QueuedRequestImpl [requestTicket=").append(requestTicket) .append(", downlinkRequest=").append(downlinkRequest).append(", endpoint=" + endpoint) .append(", requestId=").append(requestId).append("]").toString(); }
Source:
<code>private void printStats(String result) { printHeadings(); if (result == null) { if (verbose) { context.err.println("printStats(): got NULL result string."); } return; } JsonObject queuesAsJsonObject = JsonUtil.readJsonObject(result); JsonArray array = (JsonArray) queuesAsJsonObject.get("data"); for (int i = 0; i < array.size(); i++) { printQueueStats(array.getJsonObject(i)); } <START> if (maxRows == null && array.size() == DEFAULT_MAX_ROWS) { <END> context.out.println(String.format("WARNING: the displayed queues are limited to %d by default, set maxRows to display more queues.", DEFAULT_MAX_ROWS)); } }</code><technical_language>of array.size() == DEFAULT_MAX_ROWS duff logic, surely if size > DEFAULT_MAX_ROWS is logix expected based output below. surely this if maxRows >= array.size() this if sets some other value, smaller array.size want ouytput output limited</technical_language>

Target:
private void printStats(String result) { printHeadings(); if (result == null) { if (verbose) { context.err.println("printStats(): got NULL result string."); } return; } JsonObject queuesAsJsonObject = JsonUtil.readJsonObject(result); int count = queuesAsJsonObject.getInt("count"); JsonArray array = queuesAsJsonObject.getJsonArray("data"); for (int i = 0; i < array.size(); i++) { printQueueStats(array.getJsonObject(i)); } if (count > maxRows) { context.out.println(String.format("WARNING: the displayed queues are %d/%d, set maxRows to display more queues.", maxRows, count)); } }
Source:
<code>public String updateEndpointRegistry(String registryId, EndpointRegistryInfo endpointRegistry) throws APIManagementException { String query = SQLConstants.UPDATE_ENDPOINT_REGISTRY_SQL; <START> String uuid = UUID.randomUUID().toString(); <END> try (Connection connection = APIMgtDBUtil.getConnection(); PreparedStatement ps = connection.prepareStatement(query)) { connection.setAutoCommit(false); ps.setString(1, endpointRegistry.getName()); ps.setString(2, endpointRegistry.getType()); ps.setString(3, endpointRegistry.getMode()); ps.setString(4, ""); ps.setString(5, ""); ps.setString(6, registryId); ps.executeUpdate(); connection.commit(); } catch (SQLException e) { handleException("Error while updating endpoint registry: " + endpointRegistry.getName(), e); } return uuid; }</code><technical_language>need generate uuid updating Registry. remove it</technical_language>

Target:
public void updateEndpointRegistry(String registryId, EndpointRegistryInfo endpointRegistry) throws APIManagementException { String query = SQLConstants.UPDATE_ENDPOINT_REGISTRY_SQL; try (Connection connection = APIMgtDBUtil.getConnection(); PreparedStatement ps = connection.prepareStatement(query)) { connection.setAutoCommit(false); ps.setString(1, endpointRegistry.getName()); ps.setString(2, endpointRegistry.getType()); ps.setString(3, endpointRegistry.getMode()); ps.setString(4, ""); ps.setString(5, ""); ps.setString(6, registryId); ps.executeUpdate(); connection.commit(); } catch (SQLException e) { handleException("Error while updating endpoint registry: " + endpointRegistry.getName(), e); } return; }
Source:
<code>public void getThreadData() throws InterruptedException{ final String THREAD_ID = "1"; final DataRequestMonitor<IThreadDMData> rm = new DataRequestMonitor<IThreadDMData>(fSession.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { fWait.setReturnInfo(getData()); } fWait.waitFinished(getStatus()); } }; final IProcessDMContext processContext = DMContexts.getAncestorOfType(SyncUtil.getContainerContext(), IProcessDMContext.class); fProcService.getExecutor().submit(new Runnable() { @Override public void run() { IThreadDMContext threadDmc = fProcService.createThreadContext(processContext, THREAD_ID); fProcService.getExecutionData(threadDmc, rm); } }); fWait.waitUntilDone(TestsPlugin.massageTimeout(2000)); assertTrue(fWait.getMessage(), fWait.isOK()); IThreadDMData threadData = (IThreadDMData)fWait.getReturnInfo(); Assert.assertNotNull("Thread data not returned for thread id = " + THREAD_ID, threadData); Pattern pattern = Pattern.compile("\\d*", Pattern.MULTILINE); Matcher matcher = pattern.matcher(threadData.getId()); assertTrue("Thread ID is a series of number", matcher.find()); String expectedThreadName = threadNamesSupported() ? EXEC_NAME : ""; <START> assertEquals("main thread's name is the name of the executable", expectedThreadName, threadData.getName()); <END> fWait.waitReset(); }</code><technical_language>Please update error message, do if (threadNamesSupported()) asserts error message</technical_language>

Target:
public void getThreadData() throws InterruptedException{ final String THREAD_ID = "1"; final DataRequestMonitor<IThreadDMData> rm = new DataRequestMonitor<IThreadDMData>(fSession.getExecutor(), null) { @Override protected void handleCompleted() { if (isSuccess()) { fWait.setReturnInfo(getData()); } fWait.waitFinished(getStatus()); } }; final IProcessDMContext processContext = DMContexts.getAncestorOfType(SyncUtil.getContainerContext(), IProcessDMContext.class); fProcService.getExecutor().submit(new Runnable() { @Override public void run() { IThreadDMContext threadDmc = fProcService.createThreadContext(processContext, THREAD_ID); fProcService.getExecutionData(threadDmc, rm); } }); fWait.waitUntilDone(TestsPlugin.massageTimeout(2000)); assertTrue(fWait.getMessage(), fWait.isOK()); IThreadDMData threadData = (IThreadDMData)fWait.getReturnInfo(); Assert.assertNotNull("Thread data not returned for thread id = " + THREAD_ID, threadData); Pattern pattern = Pattern.compile("\\d*", Pattern.MULTILINE); Matcher matcher = pattern.matcher(threadData.getId()); assertTrue("Thread ID is a series of number", matcher.find()); String expectedThreadName = threadNamesSupported() ? EXEC_NAME : ""; assertEquals("main thread's name is wrong", expectedThreadName, threadData.getName()); fWait.waitReset(); }
Source:
<code>public S3NotebookRepo(ZeppelinConfiguration conf) throws IOException { <START> this.conf = conf; <END> bucketName = conf.getBucketName(); user = conf.getUser(); useServerSideEncryption = conf.isS3ServerSideEncryption(); saveAndCommit = conf.isPersistOnCommit(); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); CryptoConfiguration cryptoConf = null; String keyRegion = conf.getS3KMSKeyRegion(); if (StringUtils.isNotBlank(keyRegion)) { cryptoConf = new CryptoConfiguration(); cryptoConf.setAwsKmsRegion(Region.getRegion(Regions.fromName(keyRegion))); } String kmsKeyID = conf.getS3KMSKeyID(); if (kmsKeyID != null) { KMSEncryptionMaterialsProvider emp = new KMSEncryptionMaterialsProvider(kmsKeyID); if (cryptoConf != null) { this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cryptoConf); } else { this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp); } } else if (conf.getS3EncryptionMaterialsProviderClass() != null) { EncryptionMaterialsProvider emp = createCustomProvider(conf); this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp); } else { this.s3client = new AmazonS3Client(credentialsProvider); } s3client.setEndpoint(conf.getEndpoint()); }</code><technical_language>sense ask NotebookRepo implementation do saveAndCommit logic. is supposed in a base class</technical_language>

Target:
public S3NotebookRepo(ZeppelinConfiguration conf) throws IOException { this.conf = conf; bucketName = conf.getBucketName(); user = conf.getUser(); useServerSideEncryption = conf.isS3ServerSideEncryption(); AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); CryptoConfiguration cryptoConf = null; String keyRegion = conf.getS3KMSKeyRegion(); if (StringUtils.isNotBlank(keyRegion)) { cryptoConf = new CryptoConfiguration(); cryptoConf.setAwsKmsRegion(Region.getRegion(Regions.fromName(keyRegion))); } String kmsKeyID = conf.getS3KMSKeyID(); if (kmsKeyID != null) { KMSEncryptionMaterialsProvider emp = new KMSEncryptionMaterialsProvider(kmsKeyID); if (cryptoConf != null) { this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cryptoConf); } else { this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp); } } else if (conf.getS3EncryptionMaterialsProviderClass() != null) { EncryptionMaterialsProvider emp = createCustomProvider(conf); this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp); } else { this.s3client = new AmazonS3Client(credentialsProvider); } s3client.setEndpoint(conf.getEndpoint()); }
Source:
<code>public Map<byte[], byte[]> all() { try { List<String> zkSubDirectories = zkClient.getChildren(zkBaseDir); Map<byte[], byte[]> result = new HashMap<>(); for (String zkSubDir : zkSubDirectories) { String completeZkPath = String.format("%s/%s", zkBaseDir, zkSubDir); <START> byte[] value = zkClient.readData(completeZkPath, true); <END> result.put(completeZkPath.getBytes("UTF-8"), value); } return result; } catch (Exception e) { LOG.error("Exception occurred on reading the path: from zookeeper.", zkBaseDir, e); throw new SamzaException(e); } }</code><technical_language>this need done atomically for data base dir</technical_language>

Target:
public Map<byte[], byte[]> all() { try { List<String> zkSubDirectories = zkClient.getChildren(zkBaseDir); Map<byte[], byte[]> result = new HashMap<>(); for (String zkSubDir : zkSubDirectories) { String completeZkPath = String.format("%s/%s", zkBaseDir, zkSubDir); byte[] value = zkClient.readData(completeZkPath, true); if (value != null) { result.put(completeZkPath.getBytes("UTF-8"), value); } } return result; } catch (Exception e) { String errorMsg = String.format("Error reading path: %s from zookeeper.", zkBaseDir); LOG.error(errorMsg, e); throw new SamzaException(errorMsg, e); } }
Source:
<code>public static String getClassName(String beanName){ int lastDotPosition = beanName.lastIndexOf("."); <START> if(lastDotPosition < 0 || beanName.length() < lastDotPosition){ <END> lastDotPosition = 0; } if(beanName.length() > 0) { beanName = beanName.substring(lastDotPosition, lastDotPosition+1).toUpperCase() + beanName.substring(lastDotPosition+1); } return beanName; }</code><technical_language>beanName.length() is < lastDotPosition</technical_language>

Target:
public static String getClassName(String beanName){ int lastDotPosition = beanName.lastIndexOf("."); String beforeLastDot = ""; if(lastDotPosition >= 0 && beanName.length() > lastDotPosition){ beforeLastDot = beanName.substring(0, lastDotPosition+1); lastDotPosition++; }else{ lastDotPosition = 0; } if(beanName.length() > lastDotPosition) { beanName = beforeLastDot+beanName.substring(lastDotPosition, lastDotPosition+1).toUpperCase() + beanName.substring(lastDotPosition+1); } return beanName; }
Source:
<code>private boolean runVmAsStateless(VM vmToRunAsStateless) { log.infoFormat("Running Vm {0} as stateless", vmToRunAsStateless); RunVmParams runVmParams = new RunVmParams(vmToRunAsStateless.getId()); runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToRunAsStateless.getId())); runVmParams.setRunAsStateless(true); VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RunVm, runVmParams, ExecutionHandler.createInternalJobContext()); boolean prestartingVmSucceeded = vdcReturnValue.getSucceeded(); if (!prestartingVmSucceeded) { AuditLogableBase log = new AuditLogableBase(); <START> log.setVmId(vmToRunAsStateless.getId()); <END> log.addCustomValue("VmName", vmToRunAsStateless.getName()); log.addCustomValue("VmPoolName", vmToRunAsStateless.getVmPoolName()); AuditLogDirector.log(log, AuditLogType.VM_FAILED_TO_PRESTART_IN_POOL); } log.infoFormat("Running Vm {0} as stateless {1}", vmToRunAsStateless, prestartingVmSucceeded ? "succeeded" : "failed"); return prestartingVmSucceeded; }</code><technical_language>im if want this message vm fails run, for pool (which means mention specific vm)</technical_language>

Target:
private boolean runVmAsStateless(VM vmToRunAsStateless) { log.infoFormat("Running Vm {0} as stateless", vmToRunAsStateless); RunVmParams runVmParams = new RunVmParams(vmToRunAsStateless.getId()); runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToRunAsStateless.getId())); runVmParams.setRunAsStateless(true); VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RunVm, runVmParams, ExecutionHandler.createInternalJobContext()); boolean prestartingVmSucceeded = vdcReturnValue.getSucceeded(); if (!prestartingVmSucceeded) { AuditLogableBase log = new AuditLogableBase(); log.setVmId(vmToRunAsStateless.getId()); log.addCustomValue("VmPoolName", vmToRunAsStateless.getVmPoolName()); AuditLogDirector.log(log, AuditLogType.VM_FAILED_TO_PRESTART_IN_POOL); } log.infoFormat("Running Vm {0} as stateless {1}", vmToRunAsStateless, prestartingVmSucceeded ? "succeeded" : "failed"); return prestartingVmSucceeded; }
Source:
<code>public static synchronized IgnoreEntryOccurrence deserialize(@NotNull DataInput in) throws IOException { final String url = in.readUTF(); if (StringUtils.isEmpty(url)) { return null; } final int size = in.readInt(); final ArrayList<Pair<Pattern, Boolean>> items = ContainerUtil.newArrayList(); for (int i = 0; i < size; i++) { <START> final Pattern pattern = Pattern.compile(in.readUTF()); <END> Boolean isNegated = in.readBoolean(); items.add(Pair.create(pattern, isNegated)); } return new IgnoreEntryOccurrence(url, ContainerUtil.immutableList(items)); }</code><technical_language>Btw, Pattern.compile is slow, I eventually compile pattern matching (with cache of String -> Pattern)</technical_language>

Target:
public static synchronized IgnoreEntryOccurrence deserialize(@NotNull DataInput in) throws IOException { final String url = in.readUTF(); final ArrayList<Pair<String, Boolean>> items = ContainerUtil.newArrayList(); if (!StringUtils.isEmpty(url)) { final int size = in.readInt(); for (int i = 0; i < size; i++) { String pattern = in.readUTF(); Boolean isNegated = in.readBoolean(); items.add(Pair.create(pattern, isNegated)); } } return new IgnoreEntryOccurrence(url, items); }
Source:
<code>private void setupWALAndReplication() throws IOException { boolean isMasterNoTableOrSystemTableOnly = this instanceof HMaster && !LoadBalancer.isMasterCanHostUserRegions(conf); <START> WALFactory factory = new WALFactory(conf, serverName.toString(), (Server) this, <END> !isMasterNoTableOrSystemTableOnly); if (!isMasterNoTableOrSystemTableOnly) { Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME); String logName = AbstractFSWALProvider.getWALDirectoryName(this.serverName.toString()); Path logDir = new Path(walRootDir, logName); LOG.debug("logDir={}", logDir); if (this.walFs.exists(logDir)) { throw new RegionServerRunningException( "Region server has already created directory at " + this.serverName.toString()); } if (!this.walFs.mkdirs(logDir)) { throw new IOException("Can not create wal directory " + logDir); } createNewReplicationInstance(conf, this, this.walFs, logDir, oldLogDir, factory.getWALProvider()); } this.walFactory = factory; }</code><technical_language>cast? HRegionServer a Server</technical_language>

Target:
private void setupWALAndReplication() throws IOException { boolean isMasterNoTableOrSystemTableOnly = this instanceof HMaster && !LoadBalancer.isMasterCanHostUserRegions(conf); WALFactory factory = new WALFactory(conf, serverName.toString(), this, !isMasterNoTableOrSystemTableOnly); if (!isMasterNoTableOrSystemTableOnly) { Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME); String logName = AbstractFSWALProvider.getWALDirectoryName(this.serverName.toString()); Path logDir = new Path(walRootDir, logName); LOG.debug("logDir={}", logDir); if (this.walFs.exists(logDir)) { throw new RegionServerRunningException( "Region server has already created directory at " + this.serverName.toString()); } if (!this.walFs.mkdirs(logDir)) { throw new IOException("Can not create wal directory " + logDir); } createNewReplicationInstance(conf, this, this.walFs, logDir, oldLogDir, factory.getWALProvider()); } this.walFactory = factory; }
Source:
<code>public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(List<ByteBuffer> keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { try (CloseableTrace trace = startLocalTrace( "client.multiget_slice(table {}, number of keys {}, number of columns {}, consistency {})", <START> LoggingArgs.safeInternalTableNameOrPlaceholder(column_parent.column_family), <END> keys.size(), predicate.slice_range.count, toString(consistency_level))) { return registerDuration( () -> delegate.multiget_slice(keys, column_parent, predicate, consistency_level), MULTIGET_SLICE_TIMER); } }</code><technical_language>i guess tracing support SafeArg</technical_language>

Target:
public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(List<ByteBuffer> keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { String internalTableReference = column_parent.column_family; int numberOfKeys = keys.size(); int numberOfColumns = predicate.slice_range.count; try (CloseableTrace trace = startLocalTrace( "client.multiget_slice(table {}, number of keys {}, number of columns {}, consistency {})", LoggingArgs.safeInternalTableNameOrPlaceholder(internalTableReference), numberOfKeys, numberOfColumns, consistency_level)) { return registerDuration( () -> delegate.multiget_slice(keys, column_parent, predicate, consistency_level), MULTIGET_SLICE_TIMER, logger -> logger.warn("client.multiget_slice({}, {}, {}, {})", LoggingArgs.safeInternalTableNameOrPlaceholder(internalTableReference), SafeArg.of("number of keys", numberOfKeys), SafeArg.of("number of columns", numberOfColumns), SafeArg.of("consistency", consistency_level.toString()))); } }
Source:
<code>public void show() { super.show(); float dp = getContext().getResources().getDimension(R.dimen.bottom_sheet_dialog_width); if (dp > 0) { DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); <START> int px = (int) ((dp * displayMetrics.density) + 0.5); <END> WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = px; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; getWindow().setAttributes(lp); } }</code><technical_language>a utility class for this. Check out DisplayUtils.dpToPx()</technical_language>

Target:
public void show() { super.show(); int dp = (int)getContext().getResources().getDimension(R.dimen.bottom_sheet_dialog_width); if (dp > 0) { int px = DisplayUtils.dpToPx(getContext(), dp); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(getWindow().getAttributes()); lp.width = px; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; getWindow().setAttributes(lp); } }
Source:
<code><START> public void onInitializationFailure(YouTubePlayer.Provider provider, <END> YouTubeInitializationResult result) { }</code><technical_language>In onError onInitializationFailure callbacks, show a dialog user give option get redirected Youtube app</technical_language>

Target:
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult result) { redirectToYoutubeDialog(); }
Source:
<code>private void setupFields(ReorientRequest request) { this.oppositeEnd = null; this.oppositePartWithPort = null; if (getElementToEdit() instanceof Connector) { ConnectorEnd source = ((Connector) getElementToEdit()).getEnds().get(0); ConnectorEnd target = ((Connector) getElementToEdit()).getEnds().get(1); <START> this.oppositeEnd = isSourceReorient() ? target.getRole() : source.getRole(); <END> this.oppositePartWithPort = isSourceReorient() ? target.getPartWithPort() : source.getPartWithPort(); } initFields(); }</code><technical_language>if source is get(0) get(1). ti case for associationwhrer source target inversed. for oldEnd reconnect. compare end. if oldEnd ==get(0) oppsiteEnd= get(1) code org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice.getBeforeReorientRelationshipCommand(ReorientRelationshipRequest)</technical_language>

Target:
private void setupFields(ReorientRequest request) { this.oppositeEnd = null; this.oppositePartWithPort = null; if (getElementToEdit() instanceof Connector) { ConnectorEnd source = getLink().getEnds().get(0); ConnectorEnd target = getLink().getEnds().get(1); this.oppositeEnd = isSourceRedirect() ? target.getRole() : source.getRole(); this.oppositePartWithPort = isSourceRedirect() ? target.getPartWithPort() : source.getPartWithPort(); } initFields(); }
Source:
<code>public NinjaRule parseNinjaRule() throws GenericParsingException { parseExpected(NinjaToken.RULE); String name = asString(parseExpected(NinjaToken.IDENTIFIER)); ImmutableSortedMap.Builder<NinjaRuleVariable, NinjaVariableValue> variablesBuilder = ImmutableSortedMap.naturalOrder(); variablesBuilder.put(NinjaRuleVariable.NAME, NinjaVariableValue.createPlainText(name)); parseExpected(NinjaToken.NEWLINE); while (parseIndentOrFinishDeclaration()) { <START> String variableName = asString(parseExpected(ImmutableSet.of(NinjaToken.IDENTIFIER, NinjaToken.POOL))); <END> parseExpected(NinjaToken.EQUALS); NinjaVariableValue value = parseVariableValue(); NinjaRuleVariable ninjaRuleVariable = NinjaRuleVariable.nullOrValue(variableName); if (ninjaRuleVariable == null) { throw new GenericParsingException(String.format("Unexpected variable '%s'", variableName)); } variablesBuilder.put(ninjaRuleVariable, value); if (lexer.hasNextToken()) { parseExpected(NinjaToken.NEWLINE); } } return new NinjaRule(variablesBuilder.build()); }</code><technical_language>is "pool" treated differently identifier? existing code understand this lexer, I happened NinjaLexer.interpretPoolAsVariable() some toggleable logic for treating "pool" identifier, no</technical_language>

Target:
public NinjaRule parseNinjaRule() throws GenericParsingException { parseExpected(NinjaToken.RULE); String name = asString(parseExpected(NinjaToken.IDENTIFIER)); ImmutableSortedMap.Builder<NinjaRuleVariable, NinjaVariableValue> variablesBuilder = ImmutableSortedMap.naturalOrder(); variablesBuilder.put(NinjaRuleVariable.NAME, NinjaVariableValue.createPlainText(name)); parseExpected(NinjaToken.NEWLINE); lexer.interpretPoolAsVariable(); while (parseIndentOrFinishDeclaration()) { String variableName = asString(parseExpected(NinjaToken.IDENTIFIER)); parseExpected(NinjaToken.EQUALS); NinjaVariableValue value = parseVariableValue(); NinjaRuleVariable ninjaRuleVariable = NinjaRuleVariable.nullOrValue(variableName); if (ninjaRuleVariable == null) { throw new GenericParsingException(String.format("Unexpected variable '%s'", variableName)); } variablesBuilder.put(ninjaRuleVariable, value); if (lexer.hasNextToken()) { parseExpected(NinjaToken.NEWLINE); } } return new NinjaRule(variablesBuilder.build()); }
Source:
<code>public void create(Username currentUser, ElasticProfile elasticProfile, LocalizedOperationResult result) { <START> ElasticAgentProfileCreateCommand command = new ElasticAgentProfileCreateCommand(goConfigService, elasticProfile, elasticAgentExtension, currentUser, result); <END> validatePluginProperties(command, elasticProfile); update(currentUser, elasticProfile, result, command); }</code><technical_language>Move this validation PluginProfileService</technical_language>

Target:
public void create(Username currentUser, ElasticProfile elasticProfile, LocalizedOperationResult result) { ElasticAgentProfileCreateCommand command = new ElasticAgentProfileCreateCommand(goConfigService, elasticProfile, elasticAgentExtension, currentUser, result); update(currentUser, elasticProfile, result, command); }
Source:
<code>private UpdateAccountResponse updateAccount(URL updateAccountUrl, String requestBody) throws Exception { RealmLog.debug("Network request (updateAccount): " + updateAccountUrl); Request request = newAuthRequest(updateAccountUrl) .post(RequestBody.create(JSON, requestBody)) .build(); <START> RealmLog.error(updateAccountUrl.toString()); <END> RealmLog.error(requestBody); Call call = client.newCall(request); Response response = call.execute(); return UpdateAccountResponse.from(response); }</code><technical_language>debugging logging? if level log error</technical_language>

Target:
private UpdateAccountResponse updateAccount(URL updateAccountUrl, String requestBody) throws Exception { RealmLog.debug("Network request (updateAccount): " + updateAccountUrl); Request request = newAuthRequest(updateAccountUrl) .post(RequestBody.create(JSON, requestBody)) .build(); Call call = client.newCall(request); Response response = call.execute(); return UpdateAccountResponse.from(response); }
Source:
<code>public void rootTestGetVariantsByVariantCoreString() throws URISyntaxException { String url = "/v2/variants/20:60100:A:T?species=mmusculus&assembly=grcm38"; List<VariantWithSamplesAndAnnotation> variantWithSamplesAndAnnotations = WSTestHelpers.testRestTemplateHelper( url,restTemplate); <START> assertTrue(variantWithSamplesAndAnnotations.size() == 1); <END> assertTrue(variantWithSamplesAndAnnotations.get(0).getSourceEntries().isEmpty()); assertNull(variantWithSamplesAndAnnotations.get(0).getAnnotation()); assertTrue(variantWithSamplesAndAnnotations.get(0).getIds().size() > 0); }</code><technical_language>common idiom be: suggestion assertEquals(1, variantWithSamplesAndAnnotations.size());</technical_language>

Target:
public void rootTestGetVariantsByVariantCoreString() throws URISyntaxException { String url = "/v2/variants/20:60100:A:T?species=mmusculus&assembly=grcm38"; List<VariantWithSamplesAndAnnotation> variantWithSamplesAndAnnotations = WSTestHelpers.testRestTemplateHelper( url, restTemplate); assertEquals(1, variantWithSamplesAndAnnotations.size()); assertTrue(variantWithSamplesAndAnnotations.get(0).getSourceEntries().isEmpty()); assertNull(variantWithSamplesAndAnnotations.get(0).getAnnotation()); assertTrue(variantWithSamplesAndAnnotations.get(0).getIds().size() > 0); }
Source:
<code>public Response intercept(Chain chain) throws IOException { try { return chain.proceed(chain.request()); } catch (IOException | RuntimeException | Error t) { <START> if (t instanceof IOException) { <END> throw (IOException) t; } throw new SafeIoException("Caught a non-IOException. " + "This is a serious bug and requires investigation. Rethrowing " + "as an IOException in order to avoid blocking a Dispatcher thread", t); } }</code><technical_language>needs extra catch block</technical_language>

Target:
public Response intercept(Chain chain) throws IOException { try { return chain.proceed(chain.request()); } catch (Throwable t) { if (t instanceof IOException) { throw (IOException) t; } throw new SafeIoException("Caught a non-IOException. " + "This is a serious bug and requires investigation. Rethrowing " + "as an IOException in order to avoid blocking a Dispatcher thread", t); } }
Source:
<code>public static void writeLinkUrl(final Response response, final CharSequence url, final CharSequence media, final String markupId, final String rel) { HeaderItemAttributeMap attributes = new HeaderItemAttributeMap(); if (Strings.isEmpty(rel) == false) { attributes.add(HeaderItemAttribute.LINK_REL, rel); <START> } else { <END> attributes.add(HeaderItemAttribute.LINK_REL, "stylesheet"); } attributes.add(HeaderItemAttribute.LINK_HREF, String.valueOf(Strings.escapeMarkup(url))); if (Strings.isEmpty(media) == false) { attributes.add(HeaderItemAttribute.LINK_MEDIA, media.toString()); } if (Strings.isEmpty(markupId) == false) { attributes.add(HeaderItemAttribute.ID, markupId); } writeLinkUrl(response, attributes); }</code><technical_language>place for ternary operator ..</technical_language>

Target:
public static void writeLinkUrl(final Response response, final CharSequence url, final CharSequence media, final String markupId, final String rel) { AttributeMap attributes = new AttributeMap(); attributes.put(ATTR_LINK_REL, Strings.isEmpty(rel) ? "stylesheet" : rel); attributes.put(ATTR_TYPE, "text/css"); attributes.put(ATTR_LINK_HREF, UrlEncoder.FULL_URL_INSTANCE.encode(String.valueOf(url),"UTF-8")); if (Strings.isEmpty(media) == false) { attributes.put(ATTR_LINK_MEDIA, media.toString()); } if (Strings.isEmpty(markupId) == false) { attributes.put(ATTR_ID, markupId); } writeLink(response, attributes); }
Source:
<code>public ConfigOrigin withLineNumber(int lineNumber) { if (this.originType == OriginType.GENERIC) { throw new UnsupportedOperationException(); <START> } <END> return this.setLineNumber(lineNumber); }</code><technical_language>I OK throw exception here; if a description a line number, fine. rename setLineNumber withLineNumber. If do throw exception ConfigException.BugOrBroken, I simplest throw one</technical_language>

Target:
public SimpleConfigOrigin withLineNumber(int lineNumber) { if (lineNumber == this.lineNumber && lineNumber == this.endLineNumber) { return this; } else { return new SimpleConfigOrigin(this.description, lineNumber, lineNumber, this.originType, this.urlOrNull, this.commentsOrNull); } }
Source:
<code>public synchronized void stop() { <START> handle.cancel(true); <END> }</code><technical_language>Check for null here: ScheduledFuture<?> f = handle; if (f != null) { handle = null; f.cancel(true); }</technical_language>

Target:
public void stop() { ScheduledFuture<?> f = handle; if (f != null) { handle = null; f.cancel(true); } }
Source:
<code>protected synchronized Properties getProps() { if (properties == null) { properties = new Properties(); <START> loadProps(properties, -1); <END> } return properties; }</code><technical_language>I appreciate if rewrite this -1 startIdx. A year I remember want load position -1</technical_language>

Target:
protected synchronized Properties getProps() { if (properties == null) { properties = new Properties(); loadProps(properties, 0, true); } return properties; }
Source:
<code>private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); } } if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference writeAnswersDisable = (CheckBoxPreference) screen.findPreference("writeAnswersDisable"); CheckBoxPreference useInputTag = (CheckBoxPreference) screen.findPreference("useInputTag"); CheckBoxPreference inputWorkaround = (CheckBoxPreference) screen.findPreference("inputWorkaround"); CheckBoxPreference longclickWorkaround = (CheckBoxPreference) screen.findPreference("textSelectionLongclickWorkaround"); CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CheckBoxPreference safeDisplayMode = (CheckBoxPreference) screen.findPreference("safeDisplay"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); <START> workarounds.removePreference(longclickWorkaround); <END> workarounds.removePreference(safeDisplayMode); workarounds.removePreference(writeAnswersDisable); workarounds.removePreference(inputWorkaround); if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }</code><technical_language>workarounds able removed I believe..</technical_language>

Target:
private void removeUnnecessaryAdvancedPrefs(PreferenceScreen screen) { PreferenceCategory plugins = (PreferenceCategory) screen.findPreference("category_plugins"); if (!CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference emojiScrolling = (CheckBoxPreference) screen.findPreference("scrolling_buttons"); if (emojiScrolling != null && plugins != null) { plugins.removePreference(emojiScrolling); } } if (!CompatHelper.hasScrollKeys() && !CompatHelper.hasKanaAndEmojiKeys()) { CheckBoxPreference doubleScrolling = (CheckBoxPreference) screen.findPreference("double_scrolling"); if (doubleScrolling != null && plugins != null) { plugins.removePreference(doubleScrolling); } } PreferenceCategory workarounds = (PreferenceCategory) screen.findPreference("category_workarounds"); if (workarounds != null) { CheckBoxPreference fixHebrewText = (CheckBoxPreference) screen.findPreference("fixHebrewText"); CheckBoxPreference safeDisplayMode = (CheckBoxPreference) screen.findPreference("safeDisplay"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); if (!CompatHelper.isNook()) { workarounds.removePreference(safeDisplayMode); } if (CompatHelper.getSdkVersion() >= 16) { workarounds.removePreference(fixHebrewText); } } }
Source:
<code>public OverthereProcess startProcess(final CmdLine cmd) { checkNotNull(cmd, "Cannot execute null command line"); checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line"); final String obfuscatedCmd = cmd.toCommandLine(os, true); logger.info("Starting command on [{}]", obfuscatedCmd, this); final CmdLine winrsCmd = new CmdLine(); winrsCmd.addArgument("winrs"); winrsCmd.addArgument("-remote:" + address + ":" + port); winrsCmd.addArgument("-username:" + username); <START> winrsCmd.addRaw("-password:" + password); <END> if (workingDirectory != null) { winrsCmd.addArgument("-directory:" + workingDirectory.getPath()); } if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) { winrsCmd.addArgument("-noecho"); } if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) { winrsCmd.addArgument("-noprofile"); } if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) { winrsCmd.addArgument("-allowdelegate"); } if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) { winrsCmd.addArgument("-compression"); } if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) { winrsCmd.addArgument("-unencrypted"); } if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) { winrsCmd.addArgument("-usessl"); } winrsCmd.add(cmd.getArguments()); return winrsProxyConnection.startProcess(winrsCmd); }</code><technical_language>this work password contains other non-safe characters spaces, colons (':'), etc? answer improve encoding? add another type of encoding</technical_language>

Target:
public OverthereProcess startProcess(final CmdLine cmd) { checkNotNull(cmd, "Cannot execute null command line"); checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line"); final String obfuscatedCmd = cmd.toCommandLine(os, true); logger.info("Starting command on [{}]", obfuscatedCmd, this); final CmdLine winrsCmd = new CmdLine(); winrsCmd.addArgument("winrs"); winrsCmd.addArgument("-remote:" + address + ":" + port); winrsCmd.addArgument("-username:" + username); winrsCmd.addPassword("-password:" + password); if (workingDirectory != null) { winrsCmd.addArgument("-directory:" + workingDirectory.getPath()); } if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) { winrsCmd.addArgument("-noecho"); } if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) { winrsCmd.addArgument("-noprofile"); } if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) { winrsCmd.addArgument("-allowdelegate"); } if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) { winrsCmd.addArgument("-compression"); } if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) { winrsCmd.addArgument("-unencrypted"); } if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) { winrsCmd.addArgument("-usessl"); } winrsCmd.add(cmd.getArguments()); return winrsProxyConnection.startProcess(winrsCmd); }
Source:
<code>protected void onPause() { super.onPause(); <START> if (playerSkinLayoutController != null) { <END> playerSkinLayoutController.onPause(); } Log.d(TAG, "Player Activity Paused"); if (null != player) { player.suspend(); } }</code><technical_language>I asked change null, i meant for cases encounter them, changed for ask for player. check for null null != variable</technical_language>

Target:
protected void onPause() { super.onPause(); if (null != playerSkinLayoutController) { playerSkinLayoutController.onPause(); } Log.d(TAG, "Player Activity Paused"); if (null != player) { player.suspend(); } }
Source:
<code>public void advanceIfNeeded(int i) { if (mark < i) { baseIterator.skipAllBefore(i); <START> if (baseIterator.hasNext()) { <END> mark = baseIterator.next(); } } }</code><technical_language>If i is end of set, guessing baseIterator.hasNext false mark remain unchanged. means next return it, >= i. Is right</technical_language>

Target:
public void advanceIfNeeded(int i) { if (mark < i) { baseIterator.skipAllBefore(i); if (baseIterator.hasNext()) { mark = baseIterator.next(); } else { mark = NOT_SET; } } }
Source:
<code><START> public int read() throws IOException { <END> prepare(); if (buf.remaining() > 0) { return buf.get(); } buf.rewind(); position += buf.capacity(); int nr = os.read(position, buf); if (nr < 0) { buf.limit(0); return -1; } buf.flip(); return buf.get(); }</code><technical_language>classical hack is implement read() this: byte[] b = new byte[1]; int n = read(b); return n == 1 ? b[0] & 0xff : -1; this form is short easy read</technical_language>

Target:
public int read() throws IOException { byte[] b = new byte[1]; int n = read(b); return n == 1 ? b[0] & 0xff : -1; }
Source:
<code><START> public JsonObject getRawJson() { <END> return rawJson; }</code><technical_language>Hmm, export a GSON type part of public API. do making this a more opaque data type (like []byte in Go)</technical_language>

Target:
public String getRawJson() { return rawJson; }