auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testOverwrite() throws IOException { URI path = GoogleCloudStorageFileSystemIntegrationTest.getTempFilePath(); Path hadoopPath = ghfsHelper.castAsHadoopPath(path); assertThrows(FileNotFoundException.class, () -> ghfs.getFileStatus(hadoopPath)); String text = "Hello World!"; int numBytesWritten = ghfsHelper.writeFile(hadoopPath, text, 1, false); assertThat(numBytesWritten).isEqualTo(text.getBytes(UTF_8).length); assertThrows( IOException.class, () -> ghfsHelper.writeFile(hadoopPath, text, 1, false)); <START> ghfsHelper.writeFile(hadoopPath, text, 1, true); <END> String readText = ghfsHelper.readTextFile(hadoopPath, 0, text.getBytes().length, true); assertThat(readText).isEqualTo(text); }</code><technical_language>testing helper method instead of public interface here</technical_language>

Target:
public void testOverwrite() throws IOException { URI path = GoogleCloudStorageFileSystemIntegrationTest.getTempFilePath(); Path hadoopPath = ghfsHelper.castAsHadoopPath(path); assertThrows(FileNotFoundException.class, () -> ghfs.getFileStatus(hadoopPath)); String text = "Hello World!"; int numBytesWritten = ghfsHelper.writeFile(hadoopPath, text, 1, false); assertThat(numBytesWritten).isEqualTo(text.getBytes(UTF_8).length); assertThrows( IOException.class, () -> ghfsHelper.writeFile(hadoopPath, text, 1, false)); String textToOverwrite = "World Hello!"; ghfsHelper.writeFile(hadoopPath, textToOverwrite, 1, true); String readText = ghfsHelper.readTextFile(hadoopPath); assertThat(readText).isEqualTo(textToOverwrite); }
Source:
<code>private void prepareDescription(Description description) { if (TextUtils.isEmpty(description.getContent()) || description == Description.emptyDescription) { return; } if (description.getType() != Description.HTML) { videoDescriptionView.setAutoLinkMask(Linkify.WEB_URLS); } if (description.getType() == Description.HTML) { disposables.add(Single.just(description.getContent()) .map((@io.reactivex.annotations.NonNull String descriptionText) -> { Spanned parsedDescription; if (Build.VERSION.SDK_INT >= 24) { parsedDescription = Html.fromHtml(descriptionText, 0); } else { parsedDescription = Html.fromHtml(descriptionText); } return parsedDescription; }) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .subscribe((@io.reactivex.annotations.NonNull Spanned spanned) -> { videoDescriptionView.setText(spanned); videoDescriptionView.setVisibility(View.VISIBLE); })); } else if (description.getType() == Description.MARKDOWN) { <START> videoDescriptionView.setText(description.getContent().replace("**", ""), TextView.BufferType.SPANNABLE); <END> videoDescriptionView.setVisibility(View.VISIBLE); } else { videoDescriptionView.setText(description.getContent(), TextView.BufferType.SPANNABLE); videoDescriptionView.setVisibility(View.VISIBLE); } }</code><technical_language>for asking for changes manipulating string buggy. add a [markdown library](<LINK_0> render in a separate PR</technical_language>

Target:
private void prepareDescription(Description description) { if (TextUtils.isEmpty(description.getContent()) || description == Description.emptyDescription) { return; } if (description.getType() == Description.HTML) { disposables.add(Single.just(description.getContent()) .map((@io.reactivex.annotations.NonNull String descriptionText) -> { Spanned parsedDescription; if (Build.VERSION.SDK_INT >= 24) { parsedDescription = Html.fromHtml(descriptionText, 0); } else { parsedDescription = Html.fromHtml(descriptionText); } return parsedDescription; }) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .subscribe((@io.reactivex.annotations.NonNull Spanned spanned) -> { videoDescriptionView.setText(spanned); videoDescriptionView.setVisibility(View.VISIBLE); })); } else if (description.getType() == Description.MARKDOWN) { final Markwon markwon = Markwon.builder(getContext()) .usePlugin(LinkifyPlugin.create()) .build(); markwon.setMarkdown(videoDescriptionView, description.getContent()); videoDescriptionView.setVisibility(View.VISIBLE); } else { videoDescriptionView.setAutoLinkMask(Linkify.WEB_URLS); videoDescriptionView.setText(description.getContent(), TextView.BufferType.SPANNABLE); videoDescriptionView.setVisibility(View.VISIBLE); } }
Source:
<code>public boolean isUserDefined() { <START> if (m_userAggregateId != null) { <END> return FunctionForVoltDB.isUserDefinedFunctionId(Integer.parseInt(m_userAggregateId)); } else { return false; } }</code><technical_language>Is this correct? set null</technical_language>

Target:
public boolean isUserDefined() { return FunctionForVoltDB.isUserDefinedFunctionId(m_userAggregateId); }
Source:
<code><START> public CloseablePart getFilePart(Request req, Transaction t) throws PublishException, BadRequestException { <END> if (req == null) { throw new PublishException("error getting file part from request as request was null"); } if (t == null) { throw new PublishException("error getting file part from request transaction expected but was null"); } HttpServletRequest raw = req.raw(); if (raw == null) { throw new PublishException("error getting file part from request as HttpServletRequest was null", t); } req.attribute(MULTIPART_CONFIG, new MultipartConfigElement(tmpDir.toString(), maxFileSize, maxRequestSize, fileThresholdSize)); info().transactionID(t).log("parsing request body for file item"); Part part = null; try { part = raw.getPart(FILE_PART_NAME); } catch (Exception ex) { throw new BadRequestException(ex, "error attempting to retriving multipart file upload request body", t.id()); } if (part == null) { throw new BadRequestException("expected multipart file upload request body but was null", t.id()); } return new CloseablePart(part, t.id()); }</code><technical_language>a programmer variable names :trollface:</technical_language>

Target:
public CloseablePart getFilePart(Request req, Transaction t) throws PublishException, BadRequestException { if (req == null) { throw new PublishException("error getting file part from request as request was null"); } if (t == null) { throw new PublishException("error getting file part from request transaction expected but was null"); } HttpServletRequest raw = req.raw(); if (raw == null) { throw new PublishException("error getting file part from request as HttpServletRequest was null", t); } req.attribute(MULTIPART_CONFIG, new MultipartConfigElement(tmpDir.toString(), maxFileSize, maxRequestSize, fileThresholdSize)); info().transactionID(t).log("parsing request body for file item"); Part part = null; try { part = raw.getPart(FILE_PART_NAME); } catch (Exception ex) { throw new BadRequestException(ex, "error attempting to retrieve multipart file upload request body", t.id()); } if (part == null) { throw new BadRequestException("expected multipart file upload request body but was null", t.id()); } return new CloseablePart(part, t.id()); }
Source:
<code>static Spannable getSpannableContentForRanges(FormattableContent formattableContent, TextView textView, final Function1<FormattableRange, Unit> clickHandler, boolean isFooter) { return getSpannableContentForRanges(formattableContent, textView, isFooter, <START> new Function1<NoteBlockClickableSpan, Unit>() { <END> @Override public Unit invoke(NoteBlockClickableSpan noteBlockClickableSpan) { clickHandler.invoke(noteBlockClickableSpan.getFormattableRange()); return null; } }); }</code><technical_language>Creates function listener is null</technical_language>

Target:
static Spannable getSpannableContentForRanges(FormattableContent formattableContent, TextView textView, final Function1<FormattableRange, Unit> clickHandler, boolean isFooter) { Function1<NoteBlockClickableSpan, Unit> clickListener = clickHandler != null ? new Function1<NoteBlockClickableSpan, Unit>() { @Override public Unit invoke(NoteBlockClickableSpan noteBlockClickableSpan) { clickHandler.invoke(noteBlockClickableSpan.getFormattableRange()); return null; } } : null; return getSpannableContentForRanges(formattableContent, textView, isFooter, clickListener); }
Source:
<code>protected Collection<String> defaultSuppressionAnnotations() { <START> Collection defaultValues = new ArrayList<String>(); <END> defaultValues.addAll(LOMBOK_ANNOTATIONS); return defaultValues; }</code><technical_language>ArrayList (and HashSet for example) a constructor a collection. write return new ArrayList<>(LOMBOK_ANNOTATIONS);</technical_language>

Target:
protected Collection<String> defaultSuppressionAnnotations() { return LOMBOK_ANNOTATIONS; }
Source:
<code>private IdealState trimIdealState(IdealState originalIdealState) { IdealState trimmedIdealState = new IdealState(originalIdealState.getRecord()); <START> ZNRecord idealStateRecord = trimmedIdealState.getRecord(); <END> switch (originalIdealState.getRebalanceMode()) { case FULL_AUTO: idealStateRecord.setListFields(idealStateRecord.getListFields().keySet().stream().collect( Collectors.toMap(partition -> partition, partition -> Collections.emptyList()))); case SEMI_AUTO: idealStateRecord.setMapFields(idealStateRecord.getMapFields().keySet().stream().collect( Collectors.toMap(partition -> partition, partition -> Collections.emptyMap()))); break; default: break; } return trimmedIdealState; }</code><technical_language>Nit: trimmedIdealStateRecord</technical_language>

Target:
private IdealState trimIdealState(IdealState originalIdealState) { IdealState trimmedIdealState = new IdealState(originalIdealState.getRecord()); ZNRecord trimmedIdealStateRecord = trimmedIdealState.getRecord(); switch (originalIdealState.getRebalanceMode()) { case FULL_AUTO: trimmedIdealStateRecord.setListFields(trimmedIdealStateRecord.getListFields().keySet().stream().collect( Collectors.toMap(partition -> partition, partition -> Collections.emptyList()))); case SEMI_AUTO: trimmedIdealStateRecord.setMapFields(trimmedIdealStateRecord.getMapFields().keySet().stream().collect( Collectors.toMap(partition -> partition, partition -> Collections.emptyMap()))); break; default: break; } return trimmedIdealState; }
Source:
<code>public boolean select(Viewer viewer, Object parentElement, Object element) { try { if (element instanceof IProject) { IProject project = (IProject) element; <START> if (project.hasNature(TmfProjectNature.ID) && TmfProjectModelHelper.isShadowProject(project)) { <END> return false; } } } catch (CoreException e) { } return true; }</code><technical_language>slightly check project is opened instead of letting throw CoreException in hasNature()</technical_language>

Target:
public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IProject) { IProject project = (IProject) element; if (TmfProjectModelHelper.isShadowProject(project)) { return false; } } return true; }
Source:
<code>public void updateBatchSchedule(RequestExecution requestExecution) throws AmbariException { BatchRequest lastCompletedBatchRequest = calculateLastCompletedBatch(requestExecution); if (requestExecution.getStatus().equals(SCHEDULED.name())) { long startingBatchId = lastCompletedBatchRequest == null? 1L : lastCompletedBatchRequest.getOrderId() + 1; scheduleBatch(requestExecution, startingBatchId); } else if (requestExecution.getStatus().equals(PAUSED.name()) || requestExecution.getStatus().equals(ABORTED.name())) { deleteAllJobs(requestExecution); <START> long possibleBatchToAbort = lastCompletedBatchRequest == null? 1L : lastCompletedBatchRequest.getOrderId() + 1; <END> Collection<Long> requestIDsToAbort = requestExecution.getBatchRequestRequestsIDs(possibleBatchToAbort); for (Long requestId : requestIDsToAbort) { if (requestId == null) continue; StrBuilder sb = new StrBuilder(); sb.append(DEFAULT_API_PATH) .append("/clusters/") .append(requestExecution.getClusterName()) .append("/requests/") .append(requestId); String body = "{\"Requests\":{\"request_status\":\"ABORTED\",\"abort_reason\":\"Request schedule status changed to " + requestExecution.getStatus() + "\"}}"; performApiRequest(sb.toString(), body, "PUT", requestExecution.getAuthenticatedUserId()); } } }</code><technical_language>This is dangerous user is allowed submit orderIds: [2,4,10,15]</technical_language>

Target:
public void updateBatchSchedule(RequestExecution requestExecution) throws AmbariException { BatchRequest activeBatch = calculateActiveBatch(requestExecution); if (activeBatch == null) { LOG.warn("Ignoring RequestExecution status update since all batches has been executed"); return; } if (requestExecution.getStatus().equals(SCHEDULED.name())) { scheduleBatch(requestExecution, activeBatch.getOrderId()); } else if (requestExecution.getStatus().equals(PAUSED.name()) || requestExecution.getStatus().equals(ABORTED.name())) { LOG.info("Request execution status changed to " + requestExecution.getStatus() + " for request schedule " + requestExecution.getId() + ". Deleting related jobs."); deleteJobs(requestExecution, activeBatch.getOrderId()); Collection<Long> requestIDsToAbort = requestExecution.getBatchRequestRequestsIDs(activeBatch.getOrderId()); for (Long requestId : requestIDsToAbort) { if (requestId == null) continue; abortRequestById(requestExecution, requestId); } } }
Source:
<code>@Override public CatboostClassificationModel parse(byte[] mdl) { try (InputStream inputStream = new ByteArrayInputStream(mdl)) { return new CatboostClassificationModel(CatBoostModel.loadModel(inputStream)); } catch (IOException | CatBoostError e) { <START> throw new RuntimeException("Failed to parse model", e); <END> } }</code><technical_language>Rewrite RuntimeException message more clear (maybe tips, on)</technical_language>

Target:
@Override public CatboostClassificationModel parse(byte[] mdl) { try (InputStream inputStream = new ByteArrayInputStream(mdl)) { return new CatboostClassificationModel(CatBoostModel.loadModel(inputStream)); } catch (IOException | CatBoostError e) { throw new RuntimeException("Failed to parse model " + e.getMessage(), e); } }
Source:
<code>public void func_wrapping_class() { FunctionDef functionTree = functionTreesByName.get("func_wrapping_class"); <START> assertThat(functionTree.localVariables()).hasSize(1); <END> }</code><technical_language>assert name of variable</technical_language>

Target:
public void func_wrapping_class() { FunctionDef functionTree = functionTreesByName.get("func_wrapping_class"); assertThat(functionTree.localVariables()).extracting(Symbol::name).containsExactly("A"); }
Source:
<code>public static ITypedElement getFileRevisionTypedElementForCommonAncestor( final String gitPath, ObjectId commit1, ObjectId commit2, Repository db) { ITypedElement ancestor = null; RevCommit commonAncestor = null; try { commonAncestor = RevUtils.getCommonAncestor(db, commit1, commit2); } catch (IOException e) { Activator.logError(NLS.bind(UIText.CompareUtils_errorCommonAncestor, commit1.getName(), commit2.getName()), e); } if (commonAncestor != null) { ITypedElement ancestorCandidate = CompareUtils .getFileRevisionTypedElement(gitPath, commonAncestor, db); <START> if (!ITypedElement.UNKNOWN_TYPE.equals(ancestorCandidate.getType())) <END> ancestor = ancestorCandidate; } return ancestor; }</code><technical_language>check instanceof GitCompareFileRevisionEditorInput.EmptyTypedElement directly</technical_language>

Target:
public static ITypedElement getFileRevisionTypedElementForCommonAncestor( final String gitPath, ObjectId commit1, ObjectId commit2, Repository db) { ITypedElement ancestor = null; RevCommit commonAncestor = null; try { commonAncestor = RevUtils.getCommonAncestor(db, commit1, commit2); } catch (IOException e) { Activator.logError(NLS.bind(UIText.CompareUtils_errorCommonAncestor, commit1.getName(), commit2.getName()), e); } if (commonAncestor != null) { ITypedElement ancestorCandidate = CompareUtils .getFileRevisionTypedElement(gitPath, commonAncestor, db); if (!(ancestorCandidate instanceof EmptyTypedElement)) ancestor = ancestorCandidate; } return ancestor; }
Source:
<code>public LinkDiscoverer getDiscoverer(MockHttpServletResponse response) { String contentType = response.getContentType(); LinkDiscoverer linkDiscovererFor = discoverers.getLinkDiscovererFor(contentType); <START> assertThat("Did not find a LinkDiscoverer for returned media type " + contentType + "!", linkDiscovererFor, <END> is(notNullValue())); return linkDiscovererFor; }</code><technical_language>Please, AssertJ</technical_language>

Target:
public LinkDiscoverer getDiscoverer(MockHttpServletResponse response) { String contentType = response.getContentType(); LinkDiscoverer linkDiscovererFor = discoverers.getLinkDiscovererFor(contentType); assertThat(linkDiscovererFor) .describedAs("Did not find a LinkDiscoverer for returned media type " + contentType + "!") .isNotNull(); return linkDiscovererFor; }
Source:
<code>private boolean confInvocationPassed(ITestNGMethod method, ITestNGMethod currentTestMethod, IClass testClass, Object instance) { boolean result = true; Class<?> cls = testClass.getRealClass(); if(m_suiteState.isFailed()) { result = false; } else { if (classConfigurationFailed(cls)) { if (! m_continueOnFailedConfiguration) { result = !classConfigurationFailed(cls); } else { synchronized (m_classInvocationResults) { Set<Object> set = m_classInvocationResults.get(cls); <START> while (set == null || cls.equals(Object.class)) { <END> cls = cls.getSuperclass(); set = m_classInvocationResults.get(cls); } if (set == null) { throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } result = !set.contains(instance); } } } else if (m_continueOnFailedConfiguration && currentTestMethod != null && m_methodInvocationResults.containsKey(currentTestMethod)) { result = !m_methodInvocationResults.get(currentTestMethod).contains(getMethodInvocationToken(currentTestMethod, instance)); } else if (! m_continueOnFailedConfiguration) { synchronized(m_classInvocationResults){ for(Class<?> clazz : m_classInvocationResults.keySet()) { if (clazz.isAssignableFrom(cls)) { result = false; break; } } } } } String[] groups = method.getGroups(); if(null != groups && groups.length > 0) { for(String group : groups) { if(m_beforegroupsFailures.containsKey(group)) { result = false; break; } } } return result; }</code><technical_language>while (set == null || !cls.equals(Object.class)), true</technical_language>

Target:
private boolean confInvocationPassed(ITestNGMethod method, ITestNGMethod currentTestMethod, IClass testClass, Object instance) { boolean result = true; Class<?> cls = testClass.getRealClass(); if(m_suiteState.isFailed()) { result = false; } else { if (classConfigurationFailed(cls)) { if (! m_continueOnFailedConfiguration) { result = !classConfigurationFailed(cls); } else { synchronized (m_classInvocationResults) { Set<Object> set = m_classInvocationResults.get(cls); while (set == null || !cls.equals(Object.class)) { cls = cls.getSuperclass(); set = m_classInvocationResults.get(cls); } if (set == null) { throw new IllegalStateException("No failure logs for " + testClass.getRealClass()); } result = !set.contains(instance); } } } else if (m_continueOnFailedConfiguration && currentTestMethod != null && m_methodInvocationResults.containsKey(currentTestMethod)) { result = !m_methodInvocationResults.get(currentTestMethod).contains(getMethodInvocationToken(currentTestMethod, instance)); } else if (! m_continueOnFailedConfiguration) { synchronized(m_classInvocationResults){ for(Class<?> clazz : m_classInvocationResults.keySet()) { if (clazz.isAssignableFrom(cls)) { result = false; break; } } } } } String[] groups = method.getGroups(); if(null != groups && groups.length > 0) { for(String group : groups) { if(m_beforegroupsFailures.containsKey(group)) { result = false; break; } } } return result; }
Source:
<code>public final InputStream getContent() throws IOException, IllegalStateException { if (this.objSer == null) { <START> createBytes(this.objRef); <END> } return new ByteArrayInputStream(this.objSer); }</code><technical_language>Based this (apparent) lazy initialization path, this class is currently immutable in sense</technical_language>

Target:
public final InputStream getContent() throws IOException, IllegalStateException { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); writeTo(buf); return new ByteArrayInputStream(buf.toByteArray()); }
Source:
<code>public String toString() { return "JoinAction{" + "jarId='" + jarId + '\'' + ", joinerClassName='" + joinerClassName + '\'' + <START> ", expiryEntryInterval=" + groupExpiryInterval + <END> '}'+super.toString(); }</code><technical_language>missed eventExpiryInterval</technical_language>

Target:
public String toString() { return "JoinAction{" + "jarId='" + jarId + '\'' + ", joinerClassName='" + joinerClassName + '\'' + ", groupExpiryInterval=" + groupExpiryInterval + ", eventExpiryInterval=" + eventExpiryInterval + '}' + super.toString(); }
Source:
<code>private IpSecManager.IpSecTunnelInterface createAndValidateVti(int resourceId, String intfName) throws Exception { IpSecTunnelInterfaceResponse dummyResponse = new IpSecTunnelInterfaceResponse(IpSecManager.Status.OK, resourceId, intfName); <START> when(mMockIpSecService.createTunnelInterface( <END> eq(VTI_LOCAL_ADDRESS.getHostAddress()), eq(GOOGLE_DNS_4.getHostAddress()), anyObject(), anyObject())) .thenReturn(dummyResponse); return mIpSecManager.createIpSecTunnelInterface( VTI_LOCAL_ADDRESS, GOOGLE_DNS_4, mock(Network.class)); }</code><technical_language>Instead of when(), do want verify() this function is called</technical_language>

Target:
private IpSecManager.IpSecTunnelInterface createAndValidateVti(int resourceId, String intfName) throws Exception { IpSecTunnelInterfaceResponse dummyResponse = new IpSecTunnelInterfaceResponse(IpSecManager.Status.OK, resourceId, intfName); when(mMockIpSecService.createTunnelInterface( eq(VTI_LOCAL_ADDRESS.getHostAddress()), eq(GOOGLE_DNS_4.getHostAddress()), anyObject(), anyObject())) .thenReturn(dummyResponse); IpSecManager.IpSecTunnelInterface tunnelIntf = mIpSecManager.createIpSecTunnelInterface( VTI_LOCAL_ADDRESS, GOOGLE_DNS_4, mock(Network.class)); assertNotNull(tunnelIntf); return tunnelIntf; }
Source:
<code>public CtfTmfTimestamp(long timestamp) { <START> super(timestamp, -9, 0); <END> type = TimestampType.DAY; }</code><technical_language>rebasing TmfTimestampFormat patch, replace "-9" ITmfTimestamp.NANOSECOND_SCALE</technical_language>

Target:
public CtfTmfTimestamp(long timestamp) { super(timestamp, ITmfTimestamp.NANOSECOND_SCALE, 0); type = TimestampType.DAY; }
Source:
<code>private void verifyWriteSucceeds(short version, Message message) throws Exception { ObjectSerializationCache cache = new ObjectSerializationCache(); int size = message.size(cache, version); ByteBuffer buf = ByteBuffer.allocate(size * 2); ByteBufferAccessor byteBufferAccessor = new ByteBufferAccessor(buf); message.write(byteBufferAccessor, cache, version); ByteBuffer alt = buf.duplicate(); alt.flip(); StringBuilder bld = new StringBuilder(); while (alt.hasRemaining()) { bld.append(String.format(" %02x", alt.get())); } <START> System.out.println("WATERMELON: buffer is " + bld.toString()); <END> assertEquals("Expected the serialized size to be " + size + ", but it was " + buf.position(), size, buf.position()); }</code><technical_language>Do need this</technical_language>

Target:
private void verifyWriteSucceeds(short version, Message message) throws Exception { ObjectSerializationCache cache = new ObjectSerializationCache(); int size = message.size(cache, version); ByteBuffer buf = ByteBuffer.allocate(size * 2); ByteBufferAccessor byteBufferAccessor = new ByteBufferAccessor(buf); message.write(byteBufferAccessor, cache, version); ByteBuffer alt = buf.duplicate(); alt.flip(); StringBuilder bld = new StringBuilder(); while (alt.hasRemaining()) { bld.append(String.format(" %02x", alt.get())); } assertEquals("Expected the serialized size to be " + size + ", but it was " + buf.position(), size, buf.position()); }
Source:
<code>public int hashCode() { <START> return Objects.hash(replicaList); <END> }</code><technical_language>replicaList is null I replicaList.hashCode(). This allocate a wrapper array for varargs. Objects.hashCode() is single arg version allocate</technical_language>

Target:
public int hashCode() { return replicaList.hashCode(); }
Source:
<code><START> public DefaultCopierConfiguration(Class<? extends Copier<T>> copierClass) { <END> super(copierClass); this.type = null; }</code><technical_language>This constructor set public for a good reason. change visibility a constructor instead</technical_language>

Target:
DefaultCopierConfiguration(Class<? extends Copier<T>> copierClass) { super(copierClass); this.type = null; }
Source:
<code><START> protected int getReplaceOffset() { <END> int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }</code><technical_language>do need this? pass offset context region</technical_language>

Target:
protected final int getReplaceOffset() { int start; if (fContext instanceof DocumentTemplateContext) { DocumentTemplateContext docContext = (DocumentTemplateContext)fContext; start= docContext.getStart(); } else { start= fRegion.getOffset(); } return start; }
Source:
<code>protected boolean validateFields() { String trimmedRegex = getRegexTextField().getText().trim(); try { if (MultipleRegexesOptionsPanel.validateRegexAndCheckForDuplicates( trimmedRegex, regexes)) { return true; <START> } else { <END> JOptionPane.showMessageDialog( this, TEXT_ALREADY_EXIST_INVALID_REGEX_DIALOG, TITLE_ALREADY_EXIST_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } } catch (PatternSyntaxException e) { JOptionPane.showMessageDialog( this, MessageFormat.format(TEXT_INVALID_REGEX_DIALOG, e.getLocalizedMessage()), TITLE_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } }</code><technical_language>else is necessary</technical_language>

Target:
protected boolean validateFields() { String trimmedRegex = getRegexTextField().getText().trim(); try { if (validateRegexAndCheckForDuplicates(trimmedRegex, regexes)) { return true; } JOptionPane.showMessageDialog( this, TEXT_ALREADY_EXIST_INVALID_REGEX_DIALOG, TITLE_ALREADY_EXIST_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } catch (PatternSyntaxException e) { JOptionPane.showMessageDialog( this, MessageFormat.format(TEXT_INVALID_REGEX_DIALOG, e.getLocalizedMessage()), TITLE_INVALID_REGEX_DIALOG, JOptionPane.INFORMATION_MESSAGE); getRegexTextField().requestFocusInWindow(); return false; } }
Source:
<code>public void addAttachment(SQLDatabase db,PreparedAttachment a, BasicDocumentRevision rev) throws AttachmentNotSavedException { ContentValues values = new ContentValues(); long sequence = rev.getSequence(); String filename = a.attachment.name; byte[] sha1 = a.sha1; String type = a.attachment.type; int encoding = a.attachment.encoding.ordinal(); long length = a.tempFile.length(); long revpos = CouchUtils.generationFromRevId(rev.getRevision()); values.put("sequence", sequence); values.put("filename", filename); values.put("key", sha1); values.put("type", type); values.put("encoding", encoding); values.put("length", length); values.put("encoded_length", length); values.put("revpos", revpos); db.delete("attachments", " filename = ? and sequence = ? ", new String[]{filename, String.valueOf(sequence)}); long result = db.insert("attachments", values); if (result == -1) { a.tempFile.delete(); throw new AttachmentNotSavedException("Could not insert attachment " + a + " into database with values " + values + "; not copying to attachments directory"); } File newFile = fileFromKey(sha1); <START> if(newFile.exists()){ <END> if(a.tempFile.exists()){ a.tempFile.delete(); } } else { try { FileUtils.moveFile(a.tempFile, newFile); } catch (FileExistsException fee) { a.tempFile.delete(); } catch (IOException e) { throw new AttachmentNotSavedException(e); } } }</code><technical_language>if useful add this newFile.exists() check. catching FileExistsException anyway, redundant. remove catch a race condition file system. try do move deal in catch block</technical_language>

Target:
public void addAttachment(SQLDatabase db,PreparedAttachment a, BasicDocumentRevision rev) throws AttachmentNotSavedException { ContentValues values = new ContentValues(); long sequence = rev.getSequence(); String filename = a.attachment.name; byte[] sha1 = a.sha1; String type = a.attachment.type; int encoding = a.attachment.encoding.ordinal(); long length = a.tempFile.length(); long revpos = CouchUtils.generationFromRevId(rev.getRevision()); values.put("sequence", sequence); values.put("filename", filename); values.put("key", sha1); values.put("type", type); values.put("encoding", encoding); values.put("length", length); values.put("encoded_length", length); values.put("revpos", revpos); db.delete("attachments", " filename = ? and sequence = ? ", new String[]{filename, String.valueOf(sequence)}); long result = db.insert("attachments", values); if (result == -1) { a.tempFile.delete(); throw new AttachmentNotSavedException("Could not insert attachment " + a + " into database with values " + values + "; not copying to attachments directory"); } File newFile = fileFromKey(sha1); try { FileUtils.moveFile(a.tempFile, newFile); } catch (FileExistsException fee) { a.tempFile.delete(); } catch (FileNotFoundException e) { if(!newFile.exists()){ throw new AttachmentNotSavedException(e); } } catch (IOException e) { if(newFile.exists()){ newFile.delete(); } if (a.tempFile.exists()){ a.tempFile.delete(); } throw new AttachmentNotSavedException(e); } }
Source:
<code><START> public void applyHandshakeTimeout() { <END> final ChannelPromise localHandshakePromise = handshakePromise; final long handshakeTimeoutMillis = this.handshakeTimeoutMillis; if (handshakeTimeoutMillis <= 0 || localHandshakePromise.isDone()) { return; } final ScheduledFuture<?> timeoutFuture = ctx.executor().schedule(new Runnable() { @Override public void run() { if (localHandshakePromise.isDone()) { return; } if (localHandshakePromise.tryFailure(HANDSHAKE_TIMED_OUT_EXCEPTION)) { ctx.flush() .fireUserEventTriggered(ServerHandshakeStateEvent.HANDSHAKE_TIMEOUT) .close(); } } }, handshakeTimeoutMillis, TimeUnit.MILLISECONDS); localHandshakePromise.addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> f) throws Exception { timeoutFuture.cancel(false); } }); }</code><technical_language>package-private class is package-private</technical_language>

Target:
private void applyHandshakeTimeout() { final ChannelPromise localHandshakePromise = handshakePromise; final long handshakeTimeoutMillis = this.handshakeTimeoutMillis; if (handshakeTimeoutMillis <= 0 || localHandshakePromise.isDone()) { return; } final Future<?> timeoutFuture = ctx.executor().schedule(new Runnable() { @Override public void run() { if (localHandshakePromise.tryFailure(HANDSHAKE_TIMED_OUT_EXCEPTION)) { ctx.flush() .fireUserEventTriggered(ServerHandshakeStateEvent.HANDSHAKE_TIMEOUT) .close(); } } }, handshakeTimeoutMillis, TimeUnit.MILLISECONDS); localHandshakePromise.addListener(new FutureListener<Void>() { @Override public void operationComplete(Future<Void> f) throws Exception { timeoutFuture.cancel(false); } }); }
Source:
<code>private void assertNonNullWrapping(GraphQLType wrappedType) { <START> if (wrappedType instanceof GraphQLNonNull) { <END> throw new AssertException(String.format("A non null type cannot wrap an existing non null type '%s'", GraphQLTypeUtil.getUnwrappedTypeName(wrappedType))); } }</code><technical_language>GraphqlTypeUtil assertTrue</technical_language>

Target:
private void assertNonNullWrapping(GraphQLType wrappedType) { assertTrue(!GraphQLTypeUtil.isNonNull(wrappedType), String.format("A non null type cannot wrap an existing non null type '%s'", GraphQLTypeUtil.getUnwrappedTypeName(wrappedType))); }
Source:
<code>protected void executeCommandWithConsoleSafenessWarning(final UICommand command) { VM vm = getEntity(); if (vm.getAllowConsoleReconnect() || vm.getConsoleCurentUserName() == null || Frontend.getLoggedInUser().getUserId().equals(vm.getConsoleUserId())) { command.Execute(); return; } GetRoleActionGroupsByUserIdParameters params = <START> new GetRoleActionGroupsByUserIdParameters(vm.getConsoleUserId()); <END> AsyncQuery query = new AsyncQuery(); query.setModel(this); query.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object result) { VdcQueryReturnValue returnValue = (VdcQueryReturnValue) result; List<ActionGroup> resultList = ((List<ActionGroup>) returnValue.getReturnValue()); if (resultList.contains(ActionGroup.RECONNECT_TO_VM)) { command.Execute(); } else { displayConsoleConnectConfirmPopup(command); } } }; Frontend.RunQuery(VdcQueryType.GetRoleActionGroupsByUserId, params, query); }</code><technical_language>console user ID is *not* specific for VM. in case RECONNECT VM other get a false answer. check VM specific</technical_language>

Target:
protected void executeCommandWithConsoleSafenessWarning(final UICommand command) { VM vm = getEntity(); if (vm.getAllowConsoleReconnect() || vm.getConsoleCurentUserName() == null || Frontend.getLoggedInUser().getUserId().equals(vm.getConsoleUserId())) { command.Execute(); return; } GetEntityPermissionsParameters params = new GetEntityPermissionsParameters(vm.getConsoleUserId().getValue(), ActionGroup.RECONNECT_TO_VM, vm.getId().getValue(), VdcObjectType.VM); AsyncQuery query = new AsyncQuery(); query.setModel(this); query.asyncCallback = new INewAsyncCallback() { @Override public void OnSuccess(Object model, Object result) { NGuid returnValue = ((NGuid) ((VdcQueryReturnValue)result).getReturnValue()); if (returnValue != null) { command.Execute(); } else { displayConsoleConnectConfirmPopup(command); } } }; Frontend.RunQuery(VdcQueryType.GetEntityPermissions, params, query); }
Source:
<code>public void startTrack() { changes = new HashMap<ByteArrayWrapper, byte[]>(); deletes = new HashMap<ByteArrayWrapper, byte[]>(); <START> trackingChanges = true; <END> }</code><technical_language>@nicksavers do</technical_language>

Target:
public void startTrack() { changes = new HashMap<>(); deletes = new HashMap<>(); trackingChanges = true; }
Source:
<code>public void testCreateRole() { <START> if (roleAdminOption.isPresent()) { <END> testRole = roleAdminOption.get().create("jclouds-test-role"); assertTrue(retry(new Predicate<RoleAdminApi>() { public boolean apply(RoleAdminApi roleApi) { return roleApi.get(testRole.getId()) != null; } }, 180 * 1000L).apply(roleAdminOption.get())); assertEquals(roleAdminOption.get().get(testRole.getId()).getName(), "jclouds-test-role"); } }</code><technical_language>throw a SkipException show test executed why</technical_language>

Target:
public void testCreateRole() { testRole = roleAdminOption.get().create("jclouds-test-role"); assertTrue(retry(new Predicate<RoleAdminApi>() { public boolean apply(RoleAdminApi roleApi) { return roleApi.get(testRole.getId()) != null; } }, 180 * 1000L).apply(roleAdminOption.get())); assertEquals(roleAdminOption.get().get(testRole.getId()).getName(), "jclouds-test-role"); }
Source:
<code>public SimpleFilterProjectSemiJoinStatsRule(StatsNormalizer normalizer, FilterStatsCalculator filterStatsCalculator, FunctionManager functionManager) { super(normalizer); this.filterStatsCalculator = requireNonNull(filterStatsCalculator, "filterStatsCalculator can not be null"); <START> this.logicalRowExpressions = new LogicalRowExpressions(requireNonNull(functionManager, "functionManager can not be null")); <END> this.functionResolution = new StandardFunctionResolution(functionManager); }</code><technical_language>Nit: Move requireNonNull in out of this statement</technical_language>

Target:
public SimpleFilterProjectSemiJoinStatsRule(StatsNormalizer normalizer, FilterStatsCalculator filterStatsCalculator, FunctionManager functionManager) { super(normalizer); this.filterStatsCalculator = requireNonNull(filterStatsCalculator, "filterStatsCalculator can not be null"); requireNonNull(functionManager, "functionManager can not be null"); this.logicalRowExpressions = new LogicalRowExpressions(functionManager); this.functionResolution = new StandardFunctionResolution(functionManager); }
Source:
<code>public void testGetStrippedVdsUniqueIdWithoutValidChars() { RegisterVdsParameters paramsMock = getQueryParameters(); when(paramsMock.getVdsUniqueId()).thenReturn("^%^"); String result = getQuery().getStrippedVdsUniqueId(); <START> assertEquals("Vds id is not empty as expected", result, ""); <END> }</code><technical_language>order of arguments is reversed - assertEquals("Vds id is empty expected", "", result);</technical_language>

Target:
public void testGetStrippedVdsUniqueIdWithoutValidChars() { String result = this.gerStrippedVdsUniqueId("^%^"); assertEquals("Vds id is not empty as expected", "", result); }
Source:
<code>private CoreEvent addContextToEvent(CoreEvent event, Context ctx) throws MuleException { SdkInternalContext sdkInternalContext = (SdkInternalContext) ((InternalEvent) event).<SdkInternalContext>getSdkInternalContext(); if (((InternalEvent) event).getSdkInternalContext() == null) { sdkInternalContext = new SdkInternalContext(); ((InternalEvent) event).setSdkInternalContext(sdkInternalContext); } if (hasChainNested && (ctx.hasKey(POLICY_NEXT_OPERATION) || ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS))) { sdkInternalContext.setInnerChainSubscriberContextMapping(innerChainCtx -> { if (ctx.hasKey(POLICY_NEXT_OPERATION)) { innerChainCtx = innerChainCtx.put(POLICY_NEXT_OPERATION, ctx.get(POLICY_NEXT_OPERATION)); } if (ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)) { innerChainCtx = innerChainCtx.put(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS, ctx.get(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)); } return innerChainCtx; }); } sdkInternalContext.setConfiguration(resolveConfiguration(event)); final Map<String, Object> resolutionResult = getResolutionResult(event, sdkInternalContext.getConfiguration()); sdkInternalContext.setResolutionResult(resolutionResult); <START> sdkInternalContext.setPolicyToApply(getLocation() != null <END> ? policyManager.createOperationPolicy(this, event, () -> resolutionResult) : NO_POLICY_OPERATION); return event; }</code><technical_language>is this context cleared/replaced</technical_language>

Target:
private CoreEvent addContextToEvent(CoreEvent event, Context ctx) throws MuleException { SdkInternalContext sdkInternalContext = new SdkInternalContext(); ((InternalEvent) event).setSdkInternalContext(sdkInternalContext); if (hasNestedChain && (ctx.hasKey(POLICY_NEXT_OPERATION) || ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS))) { sdkInternalContext.setInnerChainSubscriberContextMapping(innerChainCtx -> { if (ctx.hasKey(POLICY_NEXT_OPERATION)) { innerChainCtx = innerChainCtx.put(POLICY_NEXT_OPERATION, ctx.get(POLICY_NEXT_OPERATION)); } if (ctx.hasKey(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)) { innerChainCtx = innerChainCtx.put(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS, ctx.get(POLICY_IS_PROPAGATE_MESSAGE_TRANSFORMATIONS)); } return innerChainCtx; }); } sdkInternalContext.setConfiguration(resolveConfiguration(event)); final Map<String, Object> resolutionResult = getResolutionResult(event, sdkInternalContext.getConfiguration()); sdkInternalContext.setResolutionResult(resolutionResult); sdkInternalContext.setPolicyToApply(getLocation() != null ? policyManager.createOperationPolicy(this, event, () -> resolutionResult) : noPolicyOperation()); return event; }
Source:
<code>public void testBuildSQL() { IonSqlQueryBuilder queryBuilder = new IonSqlQueryBuilder(new TypeRegistry()); List<HiveColumnHandle> columns = ImmutableList.of( <START> new HiveColumnHandle("n_nationkey", HiveType.HIVE_INT, parseTypeSignature(StandardTypes.INTEGER), 0, REGULAR, Optional.empty()), <END> new HiveColumnHandle("n_name", HiveType.HIVE_STRING, parseTypeSignature(StandardTypes.VARCHAR), 1, REGULAR, Optional.empty()), new HiveColumnHandle("n_regionkey", HiveType.HIVE_INT, parseTypeSignature(StandardTypes.INTEGER), 2, REGULAR, Optional.empty())); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s", queryBuilder.buildSql(columns, TupleDomain.all())); TupleDomain<HiveColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( columns.get(2), Domain.create(SortedRangeSet.copyOf(BIGINT, ImmutableList.of(Range.equal(BIGINT, 3L))), false))); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s WHERE (case s._3 when '' then null else CAST(s._3 AS int) end = 3)", queryBuilder.buildSql(columns, tupleDomain)); }</code><technical_language>static import HIVE_* StandardTypes.*</technical_language>

Target:
public void testBuildSQL() { IonSqlQueryBuilder queryBuilder = new IonSqlQueryBuilder(new TypeRegistry()); List<HiveColumnHandle> columns = ImmutableList.of( new HiveColumnHandle("n_nationkey", HIVE_INT, parseTypeSignature(INTEGER), 0, REGULAR, Optional.empty()), new HiveColumnHandle("n_name", HIVE_STRING, parseTypeSignature(VARCHAR), 1, REGULAR, Optional.empty()), new HiveColumnHandle("n_regionkey", HIVE_INT, parseTypeSignature(INTEGER), 2, REGULAR, Optional.empty())); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s", queryBuilder.buildSql(columns, TupleDomain.all())); TupleDomain<HiveColumnHandle> tupleDomain = withColumnDomains(ImmutableMap.of( columns.get(2), Domain.create(SortedRangeSet.copyOf(BIGINT, ImmutableList.of(Range.equal(BIGINT, 3L))), false))); assertEquals("SELECT s._1, s._2, s._3 FROM S3Object s WHERE (case s._3 when '' then null else CAST(s._3 AS INT) end = 3)", queryBuilder.buildSql(columns, tupleDomain)); }
Source:
<code>public String getCloudService() { <START> return getString("cloud.service", ""); <END> }</code><technical_language>change this line? original default is 'S3' is in properties file. I want people explicitly set properties in properties file, in java code</technical_language>

Target:
public String getCloudService() { return getString("cloud.service"); }
Source:
<code>public synchronized void start() throws IOException { if (rawDataChannel == null) { throw new IllegalStateException("Cannot start without message handler."); } if (bossGroup != null) { throw new IllegalStateException("Connector already started"); } if (workerGroup != null) { throw new IllegalStateException("Connector already started"); } bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(numberOfThreads); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.AUTO_READ, true).childHandler(new ChannelRegistry()); ChannelFuture channelFuture = bootstrap.bind(localAddress).syncUninterruptibly(); if (0 == localAddress.getPort()) { <START> channelFuture.addListener(new ChannelFutureListener() { <END> @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { InetSocketAddress listenAddress = (InetSocketAddress) future.channel().localAddress(); adjustPort(listenAddress.getPort()); } } }); try { wait(100); } catch (InterruptedException e) { } } }</code><technical_language>in listening asynchronously, call syncUninterruptibly above</technical_language>

Target:
public synchronized void start() throws IOException { if (rawDataChannel == null) { throw new IllegalStateException("Cannot start without message handler."); } if (bossGroup != null) { throw new IllegalStateException("Connector already started"); } if (workerGroup != null) { throw new IllegalStateException("Connector already started"); } bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(numberOfThreads); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .option(ChannelOption.SO_BACKLOG, 100).option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.AUTO_READ, true).childHandler(new ChannelRegistry()); ChannelFuture channelFuture = bootstrap.bind(localAddress).syncUninterruptibly(); if (channelFuture.isSuccess() && 0 == localAddress.getPort()) { InetSocketAddress listenAddress = (InetSocketAddress) channelFuture.channel().localAddress(); localAddress = new InetSocketAddress(localAddress.getAddress(), listenAddress.getPort()); listenUri = getListenUri(localAddress); } }
Source:
<code><START> ProcedureRunnerNT generateProcedureRunnerNT(AuthUser user, Connection ccxn, long clientHandle) <END> throws InstantiationException, IllegalAccessException { long id = nextProcedureRunnerId++; VoltNTProcedure procedure = null; procedure = m_procClz.newInstance(); ProcedureRunnerNT runner = new ProcedureRunnerNT(id, user, ccxn, clientHandle, procedure, m_procedureName, m_procMethod, m_paramTypes, m_priorityExecutorService, NTProcedureService.this, m_mailbox, m_statsCollector); return runner; }</code><technical_language>Similar name of "ProcedureRunnerNT", "generateNTProcedureRunner"</technical_language>

Target:
ProcedureRunnerNT generateProcedureRunnerNT(AuthUser user, Connection ccxn, long clientHandle) throws InstantiationException, IllegalAccessException { long id = nextProcedureRunnerId++; VoltNonTransactionalProcedure procedure = null; procedure = m_procClz.newInstance(); ProcedureRunnerNT runner = new ProcedureRunnerNT(id, user, ccxn, clientHandle, procedure, m_procedureName, m_procMethod, m_paramTypes, m_priorityExecutorService, NTProcedureService.this, m_mailbox, m_statsCollector); return runner; }
Source:
<code>private boolean hasSnapshotRepoId(DeploymentRepository snapshotRepo) { <START> return snapshotRepo.getId().equals("mulesoft-snapshots") && snapshotRepo.getUrl().equals("<LINK_0>") <END> && !snapshotRepo.isUniqueVersion(); }</code><technical_language>This needs check for id, URL is covered in method</technical_language>

Target:
private boolean hasSnapshotRepoId(DeploymentRepository snapshotRepo) { return snapshotRepo.getId().equals("mulesoft-snapshots"); }
Source:
<code>private static boolean isOwnDomain(String tenantDomain, String routingKey) { boolean isOwnDomain = false; if (tenantDomain != null) { <START> if (routingKey.length() >= tenantDomain.length() + 1 && routingKey.substring(0, <END> tenantDomain.length() + 1).equals(tenantDomain + "/")) { isOwnDomain = true; } else if (tenantDomain.equalsIgnoreCase("carbon.super")) { if (!routingKey.contains("/")) { isOwnDomain = true; } } } else { if (!routingKey.contains("/")) { isOwnDomain = true; } } return isOwnDomain; }</code><technical_language>(routingKey.length() >= tenantDomain.length() + 1) && (routingKey.substring(0,......</technical_language>

Target:
private static boolean isOwnDomain(String tenantDomain, String routingKey) { boolean isOwnDomain = false; if (tenantDomain != null) { if ((routingKey.length() >= tenantDomain.length() + 1) && routingKey.substring(0, tenantDomain.length() + 1).equals(tenantDomain + "/")) { isOwnDomain = true; } else if (tenantDomain.equalsIgnoreCase("carbon.super")) { if (!routingKey.contains("/")) { isOwnDomain = true; } } } else { if (!routingKey.contains("/")) { isOwnDomain = true; } } return isOwnDomain; }