auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void <START> onScrollChanged(int <END> oldScrollY, int scrollY, boolean isHumanScroll) { if (webview == null) { return; } onScrolled(oldScrollY, scrollY); if (scrollY <= webview.getHeight()) { ensureDisplayed(); return; } int animMargin = 0; int scrollDelta = scrollY - oldScrollY; if (!isHumanScroll) { animMargin = 0; } else if (gravity == Gravity.BOTTOM) { if (oldScrollY < scrollY) { animMargin = Math.min(hideableView.getHeight(), (int) hideableView.getTranslationY() + scrollDelta); } else { animMargin = Math.max(0, (int) hideableView.getTranslationY() + scrollDelta); } } else if (gravity == Gravity.TOP) { if (oldScrollY > scrollY) { animMargin = Math.min(0, (int) hideableView.getTranslationY() - scrollDelta); } else { animMargin = Math.max(-hideableView.getHeight(), (int) hideableView.getTranslationY() - scrollDelta); } } hideableView.setTranslationY(animMargin); }</code><technical_language>Previous implementation is slimmer: if (webView == null) { return; } if (scrollY <= webView.getHeight()) { // For screenful, ensure exists. ViewAnimations.ensureTranslationY(pageActions, 0); return; } int animMargin; int scrollDelta = scrollY - oldScrollY; int newMargin = (int) pageActions.getTranslationY() + scrollDelta; if (oldScrollY < scrollY) { // Scroll page action toolbar int minMargin = pageActions.getHeight(); animMargin = Math.min(minMargin, newMargin); } else { // Scroll page action toolbar int minMargin = 0; animMargin = Math.max(minMargin, newMargin); } pageActions.setTranslationY(animMargin);</technical_language>

Target:
public void onScrollChanged(int oldScrollY, int scrollY, boolean isHumanScroll) { if (webView == null) { return; } onScrolled(oldScrollY, scrollY); if (scrollY <= webView.getHeight()) { ensureDisplayed(); return; } int animMargin = 0; int scrollDelta = scrollY - oldScrollY; if (!isHumanScroll) { animMargin = 0; } else if (gravity == Gravity.BOTTOM) { if (oldScrollY < scrollY) { animMargin = Math.min(hideableView.getHeight(), (int) hideableView.getTranslationY() + scrollDelta); } else { animMargin = Math.max(0, (int) hideableView.getTranslationY() + scrollDelta); } } else if (gravity == Gravity.TOP) { if (oldScrollY > scrollY) { animMargin = Math.min(0, (int) hideableView.getTranslationY() - scrollDelta); } else { animMargin = Math.max(-hideableView.getHeight(), (int) hideableView.getTranslationY() - scrollDelta); } } hideableView.setTranslationY(animMargin); }
Source:
<code>public ValidationResult isLunDiskVisible(final LUNs lun, VDS vds) { GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vds.getId(), lun.getLunType()); List<LUNs> luns = (List<LUNs>) getVdsBroker().RunVdsCommand( <START> VDSCommandType.GetDeviceList, parameters).getReturnValue(); <END> boolean lunExists = CollectionUtils.exists(luns, new Predicate() { @Override public boolean evaluate(Object o) { return ((LUNs) o).getId().equals(lun.getId()); } }); return lunExists ? ValidationResult.VALID : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_NOT_VALID); }</code><technical_language>do this running ConnectStorageServer first</technical_language>

Target:
public ValidationResult isLunDiskVisible(final LUNs lun, VDS vds) { List<LUNs> luns = executeGetDeviceList(vds.getId(), lun.getLunType()); boolean lunExists = CollectionUtils.exists(luns, new Predicate() { @Override public boolean evaluate(Object o) { return ((LUNs) o).getId().equals(lun.getId()); } }); return lunExists ? ValidationResult.VALID : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_DISK_LUN_INVALID); }
Source:
<code>public String evaluate(DeferredObject[] arguments) throws HiveException{ String text; String lang = "en"; if (arguments.length >= 0 && inputsOI != null) { text = inputsOI[0].getPrimitiveJavaObject(arguments[0].get()); if (arguments.length > 1) { lang = inputsOI[1].getPrimitiveJavaObject(arguments[1].get()); } if (text == null) { return EMPTY; } List<String> words = new ArrayList<>(); try ( Analyzer analyzer = analyzersCache.get(lang); TokenStream ts = <START> analyzer.tokenStream(EMPTY, <END> new StringReader(text)); ) { ts.reset(); CharTermAttribute cattr = ts.getAttribute(CharTermAttribute.class); while (ts.incrementToken()) { words.add(cattr.toString()); } } catch (IOException e) { return text; } return Joiner.on(" ").join(words); } return EMPTY; }</code><technical_language>throw NPE if lang is unknown add a null check set analyzer = this.defaultAnalyzer</technical_language>

Target:
public String evaluate(DeferredObject[] arguments) throws HiveException{ String text; String lang = "en"; if (arguments.length >= 0 && inputsOI != null) { text = inputsOI[0].getPrimitiveJavaObject(arguments[0].get()); if (arguments.length > 1) { lang = inputsOI[1].getPrimitiveJavaObject(arguments[1].get()); } if (text == null) { return EMPTY; } List<String> words = new ArrayList<>(); Analyzer analyzer = analyzersCache.get(lang); if (analyzer == null ) { analyzer = defaultAnalyzer; } try ( TokenStream ts = analyzer.tokenStream(EMPTY, new StringReader(text)); ) { ts.reset(); CharTermAttribute cattr = ts.getAttribute(CharTermAttribute.class); while (ts.incrementToken()) { words.add(cattr.toString()); } } catch (IOException e) { return text; } return Joiner.on(" ").join(words); } return EMPTY; }
Source:
<code>private File compileJava(File source, File... extraDeps) { JavaCompile compile = project.getTasks().create(getNextCompileName(), JavaCompile.class); try { File output = project.file("build/" + compile.getName() + "/"); if (output.exists()) { FileUtils.cleanDirectory(output); } else { output.mkdirs(); } Set<File> files = Sets.newHashSet(this.extraDataFiles); for (File ext : extraDeps) files.add(ext); compile.setClasspath(project.files(files)); if (parent != null) { compile.setSourceCompatibility(parent.getConfig().getSourceCompatibility()); compile.setTargetCompatibility(parent.getConfig().getTargetCompatibility()); } else { final JavaPluginConvention java = project.getConvention().findPlugin(JavaPluginConvention.class); if (java != null) { compile.setSourceCompatibility(java.getSourceCompatibility().toString()); compile.setTargetCompatibility(java.getTargetCompatibility().toString()); } } compile.setDestinationDir(output); compile.setSource(source.isDirectory() ? project.fileTree(source) : project.zipTree(source)); compile.getOutputs().setHistory(new TaskExecutionHistory() { @Override public Set<File> getOutputFiles() { return Sets.newHashSet(); } @Nullable @Override public OverlappingOutputs getOverlappingOutputs() { return null; } @Nullable @Override public OriginTaskExecutionMetadata getOriginExecutionMetadata() { return null; } }); Method compileMethod = JavaCompile.class.getDeclaredMethod("compile"); compileMethod.setAccessible(true); <START> compileMethod.invoke(compile); <END> return output; } catch (Exception e) { e.printStackTrace(); return null; } finally { project.getTasks().remove(compile); } }</code><technical_language>Considering compile function is protected, a subclass of JavaCompile hard link get a compile error instead of runtime error if Gradle changes</technical_language>

Target:
private File compileJava(File source, File... extraDeps) { HackyJavaCompile compile = project.getTasks().create(getNextCompileName(), HackyJavaCompile.class); try { File output = project.file("build/" + compile.getName() + "/"); if (output.exists()) { FileUtils.cleanDirectory(output); } else { output.mkdirs(); } Set<File> files = Sets.newHashSet(this.extraDataFiles); for (File ext : extraDeps) files.add(ext); compile.setClasspath(project.files(files)); if (parent != null) { compile.setSourceCompatibility(parent.getConfig().getSourceCompatibility()); compile.setTargetCompatibility(parent.getConfig().getTargetCompatibility()); } else { final JavaPluginConvention java = project.getConvention().findPlugin(JavaPluginConvention.class); if (java != null) { compile.setSourceCompatibility(java.getSourceCompatibility().toString()); compile.setTargetCompatibility(java.getTargetCompatibility().toString()); } } compile.setDestinationDir(output); compile.setSource(source.isDirectory() ? project.fileTree(source) : project.zipTree(source)); compile.doHackyCompile(); return output; } catch (Exception e) { e.printStackTrace(); return null; } finally { project.getTasks().remove(compile); } }
Source:
<code>public void checkPreviewUpdatedAfterDestroyRecreate() { waitFor(mActivityRule.getActivity().mPreviewIdlingResource); pressBackButton(); mIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); mActivityRule.getActivity().startActivity(mIntent); <START> waitFor(new ElapsedTimeIdlingResource(LAUNCH_TIMEOUT_MS)); <END> Assert.assertTrue(mActivityRule.getActivity().mPreviewIdlingResource.isIdleNow()); }</code><technical_language>Is wait for mPreviewIdlingResource set a timeout for test? This if wrong wait for a 3 secs</technical_language>

Target:
public void checkPreviewUpdatedAfterDestroyRecreate() { waitFor(mActivityRule.getActivity().mPreviewIdlingResource); pressBackButton(); resetPreviewIdlingResource(); mIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); mActivityRule.launchActivity(mIntent); waitFor(mActivityRule.getActivity().mPreviewIdlingResource); }
Source:
<code>int computeStepCount(final int start) { if (start <= 0) throw new IllegalArgumentException("Only natural numbers are allowed"); if (start == 1) return 0; <START> final int next = start % 2 == 0 ? start / 2 : 3 * start + 1; <END> return 1 + computeStepCount(next); }</code><technical_language>Some brackets this a bit easier read</technical_language>

Target:
int computeStepCount(final int start) { if (start <= 0) throw new IllegalArgumentException("Only natural numbers are allowed"); if (start == 1) return 0; final int next; if (start % 2 == 0) { next = start / 2; } else { next = 3 * start + 1; } return 1 + computeStepCount(next); }
Source:
<code>public boolean wantsBlood() { <START> return bloodTimer > 0; <END> }</code><technical_language>blood timer is increased. Also, suck blood, do need this</technical_language>

Target:
public boolean wantsBlood() { return false; }
Source:
<code>public StitchList(EntityDictionary entityDictionary) { <START> this.objectLookups = new ConcurrentHashMap<>(); <END> this.todoList = Collections.synchronizedList(new ArrayList<>()); this.entityDictionary = entityDictionary; }</code><technical_language>classes accessed a single thread. I need overhead of a concurrent hash map</technical_language>

Target:
public StitchList(EntityDictionary entityDictionary) { this.objectLookups = new HashMap<>(); this.todoList = new ArrayList<>(); this.entityDictionary = entityDictionary; }
Source:
<code>public Schema apply(Schema originalSchema) throws SchemaSyncError { Database database = originalSchema.findDatabase(dbName); if ( database != null && !ifNotExists) { throw new SchemaSyncError("Unexpectedly asked to create existing database " + dbName); <START> } <END> Schema newSchema = originalSchema.copy(); database = new Database(dbName, null); newSchema.getDatabases().add(database); return newSchema; }</code><technical_language>else return newSchema? edit: if database !=null, is</technical_language>

Target:
public Schema apply(Schema originalSchema) throws SchemaSyncError { Database database = originalSchema.findDatabase(dbName); if ( database != null ) { if ( ifNotExists ) return originalSchema; else throw new SchemaSyncError("Unexpectedly asked to create existing database " + dbName); } Schema newSchema = originalSchema.copy(); database = new Database(dbName, null); newSchema.getDatabases().add(database); return newSchema; }
Source:
<code>public <R extends HttpRequest> R bindToRequest(R request, Object input) { <START> checkArgument(input instanceof String); <END> String notes = (String)checkNotNull(input, "input"); request.setPayload(buildJson(notes)); return request; }</code><technical_language>Is null instance of a String? Consider null check first</technical_language>

Target:
public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof String); String notes = (String)input; request.setPayload(buildJson(notes)); return request; }
Source:
<code>public String getFailedTotalLow() { <START> return thresholds.failedTotalNormal; <END> }</code><technical_language>totalLow</technical_language>

Target:
public String getFailedTotalLow() { return thresholds.failedTotalLow; }
Source:
<code><START> public static <A> String join(final String delimiter, final Iterable<A> iterable) { <END> final StringBuilder sb = new StringBuilder(); for (final A i : iterable) { if (sb.length() > 0) sb.append(delimiter); sb.append(i.toString()); } return sb.toString(); }</code><technical_language>i fault for this. android is slow. caution is null checking</technical_language>

Target:
public static <A> String join(final String delimiter, final Iterable<A> iterable) { if (delimiter == null || iterable == null) { throw new IllegalArgumentException("join argument is null. delimiter: " + delimiter + " iterable: " + iterable); } final StringBuilder sb = new StringBuilder(); for (final A i : iterable) { if (i == null) continue; if (sb.length() > 0) sb.append(delimiter); sb.append(i.toString()); } return sb.toString(); }
Source:
<code><START> public static int StaticConditionNulls() { <END> Object a = null; Object b = null; return (a == b) ? 5 : 2; }</code><technical_language>This Jack optimize out (we're dx for Checker tests). acquire nulls inlined method test constant folding? more future-proof</technical_language>

Target:
public static int StaticConditionNulls() { Object a = getNull(); Object b = getNull(); return (a == b) ? 5 : 2; }
Source:
<code>private void mapFailedTestToTestReport(StringBuilder builder, CaseResult failedTest) { builder.append("## <code>").append(failedTest.getTransformedFullDisplayName().trim()).append("</code>") .append("\n"); if (StringUtils.isNotBlank(failedTest.getErrorDetails())) { <START> builder.append("<pre><code>").append(failedTest.getErrorDetails().trim()).append("</code></pre>") <END> .append("\n"); } if (StringUtils.isNotBlank(failedTest.getErrorStackTrace())) { builder.append("<details><summary>Stack trace</summary>").append("\n") .append("<pre><code>").append(failedTest.getErrorStackTrace().trim()).append("</code></pre>") .append("</details>") .append("\n"); } if (StringUtils.isNotBlank(failedTest.getStderr())) { builder.append("<details><summary>Standard error</summary>").append("\n") .append("<pre><code>").append(failedTest.getStderr().trim()).append("</code></pre>") .append("</details>") .append("\n"); } if (StringUtils.isNotBlank(failedTest.getStdout())) { builder.append("<details><summary>Standard out</summary>").append("\n") .append("<pre><code>").append(failedTest.getStdout().trim()).append("</code></pre>") .append("</details>") .append("\n"); } builder.append("\n"); }</code><technical_language>Is this valid markdown? I expect 3 ticks for code blocks</technical_language>

Target:
private void mapFailedTestToTestReport(StringBuilder builder, CaseResult failedTest) { builder.append("## `").append(failedTest.getTransformedFullDisplayName().trim()).append("`") .append("\n"); if (StringUtils.isNotBlank(failedTest.getErrorDetails())) { builder.append(codeTextFencedBlock(failedTest.getErrorDetails())) .append("\n"); } if (StringUtils.isNotBlank(failedTest.getErrorStackTrace())) { builder.append("<details><summary>Stack trace</summary>\n") .append(codeTextFencedBlock(failedTest.getErrorStackTrace())) .append("</details>\n"); } if (StringUtils.isNotBlank(failedTest.getStderr())) { builder.append("<details><summary>Standard error</summary>\n") .append(codeTextFencedBlock(failedTest.getStderr())) .append("</details>\n"); } if (StringUtils.isNotBlank(failedTest.getStdout())) { builder.append("<details><summary>Standard out</summary>\n") .append(codeTextFencedBlock(failedTest.getStdout())) .append("</details>\n"); } builder.append("\n"); }
Source:
<code>public boolean equals(Object o) { if (!(o instanceof DefaultUdtValue)) return false; <START> DefaultUdtValue that = (DefaultUdtValue) o; <END> if (!type.equals(that.type)) return false; if (size() != that.size()) return false; if (size() > 0) { for (int i = 0; i < size(); i++) { if (this.getBytesUnsafe(i) == null || that.getBytesUnsafe(i) == null) { if (this.getBytesUnsafe(i) != that.getBytesUnsafe(i)) { return false; } } else if (!getBytesUnsafe(i).equals(that.getBytesUnsafe(i))) return false; } } return true; }</code><technical_language>IntelliJ generated equals hashCode methods more straight depends ByteBuffer.equals(): java @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DefaultUdtValue = (DefaultUdtValue) o; return Objects.equals(type, that.type) && Arrays.equals(values, that.values); } @Override public int hashCode() { int result = Objects.hash(type); result = 31 * result + Arrays.hashCode(values); return result; }</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof UdtValue)) { return false; } UdtValue that = (UdtValue) o; if (!this.protocolVersion().equals(that.protocolVersion())) { return false; } if (!type.equals(that.getType())) { return false; } for (int i = 0; i < values.length; i++) { DataType innerThisType = type.getFieldTypes().get(i); DataType innerThatType = that.getType().getFieldTypes().get(i); Object thisValue = that.codecRegistry() .codecFor(innerThisType) .decode(this.getBytesUnsafe(i), this.protocolVersion()); Object thatValue = this.codecRegistry() .codecFor(innerThatType) .decode(that.getBytesUnsafe(i), that.protocolVersion()); if (!Objects.equals(thisValue, thatValue)) { return false; } } return true; }
Source:
<code>private RefactoringWizard(RefactoringContext refactoringContext, Refactoring refactoring, int flags) { Assert.isTrue(flags < LAST); if ((flags & DIALOG_BASED_USER_INTERFACE) == 0) flags |= WIZARD_BASED_USER_INTERFACE; Assert.isTrue((flags & DIALOG_BASED_USER_INTERFACE) != 0 || (flags & WIZARD_BASED_USER_INTERFACE) != 0); fRefactoringContext= refactoringContext; fRefactoring= refactoring; fFlags= flags; setNeedsProgressMonitor(true); setChangeCreationCancelable(true); <START> setDefaultPageImageDescriptor(RefactoringPluginImages.DESC_WIZBAN_REFACTOR); <END> }</code><technical_language>setWindowTitle more</technical_language>

Target:
private RefactoringWizard(RefactoringContext refactoringContext, Refactoring refactoring, int flags) { Assert.isTrue(flags < LAST); if ((flags & DIALOG_BASED_USER_INTERFACE) == 0) flags |= WIZARD_BASED_USER_INTERFACE; Assert.isTrue((flags & DIALOG_BASED_USER_INTERFACE) != 0 || (flags & WIZARD_BASED_USER_INTERFACE) != 0); fRefactoringContext= refactoringContext; fRefactoring= refactoring; fFlags= flags; setNeedsProgressMonitor(true); setChangeCreationCancelable(true); setWindowTitle(RefactoringUIMessages.RefactoringWizard_title); setDefaultPageImageDescriptor(RefactoringPluginImages.DESC_WIZBAN_REFACTOR); }
Source:
<code>public void update() { updateFullScale(); <START> if (get(new ResourceUrn("engine:sceneOpaque")).dimensions().areDifferentFrom(fullScale)) { <END> disposeAllFBOs(); createFBOs(); notifySubscribers(); WorldRendererImpl worldRendererImpl = ((WorldRendererImpl)context.get(WorldRenderer.class)); worldRendererImpl.initRenderGraph(); } }</code><technical_language>get FBO in a line IF, it. do ResourceUrn</technical_language>

Target:
public void update() { updateFullScale(); FBO sceneOpaqueFbo = get(READONLY_GBUFFER); if (sceneOpaqueFbo.dimensions().areDifferentFrom(fullScale)) { disposeAllFBOs(); createFBOs(); notifySubscribers(); } }
Source:
<code>private int[] getSourceBands(final ImageSegment imageSegment) { List<Integer> imageBands = new ArrayList<Integer>(); for (int i = 0; i < imageSegment.getNumBands(); i++) { ImageBand band = imageSegment.getImageBandZeroBase(i); if (null != band.getImageRepresentation()) { switch (band.getImageRepresentation()) { case "R": case "G": case "B": imageBands.add(i); break; default: break; } } } <START> if (imageBands.isEmpty()) { <END> for (int i = 0; i < imageSegment.getNumBands(); i++) { ImageBand band = imageSegment.getImageBandZeroBase(i); if (null != band.getImageRepresentation()) { switch (band.getImageRepresentation()) { case "LU": imageBands.add(i); break; default: break; } } } } if (imageBands.isEmpty()) { for (int i = 0; i < imageSegment.getNumBands(); i++) { ImageBand band = imageSegment.getImageBandZeroBase(i); if (null != band.getImageRepresentation()) { switch (band.getImageRepresentation()) { case "M": imageBands.add(i); break; default: break; } } } } int[] imageBandAry = new int[imageBands.size()]; for (int i = 0; i < imageBands.size(); i++) { imageBandAry[i] = imageBands.get(i); } return imageBandAry; }</code><technical_language>do for LU M bands RGB. add LU M switch statement R,G B</technical_language>

Target:
int[] getSourceBands(final ImageSegment imageSegment) { List<Integer> imageBands = new ArrayList<Integer>(); for (String[] bandsToFind : BAND_PRIORITY) { if (!imageBands.isEmpty()) { break; } for (int i = 0; i < imageSegment.getNumBands(); i++) { ImageBand band = imageSegment.getImageBandZeroBase(i); if (null != band.getImageRepresentation()) { if (Arrays.asList(bandsToFind).contains(band.getImageRepresentation())) { imageBands.add(i); } } } } int[] imageBandAry = new int[imageBands.size()]; for (int i = 0; i < imageBands.size(); i++) { imageBandAry[i] = imageBands.get(i); } return imageBandAry; }
Source:
<code>public ItemDropHandler getItemHandler() { return (e, p, item) -> { if (isItem(item.getItemStack())) { <START> if (!Slimefun.hasUnlocked(p, SlimefunItems.ENCHANTMENT_RUNE, true)) { <END> return true; } Slimefun.runSync(() -> activate(p, e, item), 20L); return true; } return false; }; }</code><technical_language>need for unncessary expensive call ItemStack here, this here</technical_language>

Target:
public ItemDropHandler getItemHandler() { return (e, p, item) -> { if (isItem(item.getItemStack())) { if (!Slimefun.hasUnlocked(p, this, true)) { return true; } Slimefun.runSync(() -> activate(p, e, item), 20L); return true; } return false; }; }
Source:
<code>public List<Concept> findPossibleValues(String searchText) { List<Concept> concepts = new ArrayList<>(); try { for (ConceptSearchResult searchResult : Context.getConceptService().getConcepts(searchText, Collections.singletonList(Context.getLocale()), false, null, null, null, null, null, null, null)) { concepts.add(searchResult.getConcept()); } } catch (Exception e) { <START> throw new RuntimeException(e); <END> } return concepts; }</code><technical_language>code formatter? <LINK_0></technical_language>

Target:
public List<Concept> findPossibleValues(String searchText) { List<Concept> concepts = new ArrayList<>(); try { for (ConceptSearchResult searchResult : Context.getConceptService().getConcepts(searchText, Collections.singletonList(Context.getLocale()), false, null, null, null, null, null, null, null)) { concepts.add(searchResult.getConcept()); } } catch (Exception e) { log.error("Error", e); } return concepts; }
Source:
<code>public static void main(String[] args) { SeqWareWebServiceClient workflowClient = clients.get("workflow"); String numClientsJSON = workflowClient.countREST(); System.out.println("Number of workflows: " + numClientsJSON); SeqWareWebServiceClient sampleClient = clients.get("sample"); String numSamples = sampleClient.countREST(); System.out.println("Number of samples: " + numSamples); List<Sample> samples = (List<Sample>) getSamplesByName("Fifty"); System.out.println(samples.size()); System.out.println("Sample ID: " + samples.get(0).getSampleId()); List<Sample> samples2 = sampleClient.<Sample>getEntitiesWhereFieldMatchesValue(Sample.class,"name", "Fifty"); System.out.println(samples2.size()); System.out.println("Sample ID: " + samples2.get(0).getSampleId()); List<Sample> samples3 = sampleClient.<Sample>getEntitiesWhereFieldMatchesValue(Sample.class,"title", "FiftyFifty"); System.out.println(samples3.size()); System.out.println("Sample ID: " + samples3.get(0).getSampleId()); createStudy(); createLane(); createExperiment(); try { clients.get("studytype").skip("1"); } catch (UniformInterfaceException e) { <START> System.out.println("Exception Message: "+e.getMessage()); <END> System.out.println("Exception Response Entity: "+e.getResponse().getEntity(String.class)); } createSamples(); }</code><technical_language>exact error message a custom message coming "skip" operation, basically tells user a studyType is a skippable entity (that another new annotation: @SkippableEntity. generic "skip/unskip" functionality, system needs entities skippable). In test client, demonstrating message</technical_language>

Target:
public static void main(String[] args) { SeqWareWebServiceClient workflowClient = clients.get("workflow"); String numClientsJSON = workflowClient.countREST(); System.out.println("Number of workflows: " + numClientsJSON); SeqWareWebServiceClient sampleClient = clients.get("sample"); String numSamples = sampleClient.countREST(); System.out.println("Number of samples: " + numSamples); List<Sample> samples = (List<Sample>) getSamplesByName("Fifty"); System.out.println(samples.size()); System.out.println("Sample ID: " + samples.get(0).getSampleId()); List<Sample> samples2 = sampleClient.<Sample>getEntitiesWhereFieldMatchesValue(Sample.class,"name", "Fifty"); System.out.println(samples2.size()); System.out.println("Sample ID: " + samples2.get(0).getSampleId()); List<Sample> samples3 = sampleClient.<Sample>getEntitiesWhereFieldMatchesValue(Sample.class,"title", "FiftyFifty"); System.out.println(samples3.size()); System.out.println("Sample ID: " + samples3.get(0).getSampleId()); createStudy(); createLane(); String studyId = "13"; List<Sample> studySamples = getSamplesForStudy(studyId); System.out.println("# samples in study "+studyId+": "+studySamples.size()); System.out.println(studySamples); try { clients.get("studytype").skip("1"); } catch (UniformInterfaceException e) { System.out.println("Exception Message: "+e.getMessage()); System.out.println("Exception Response Entity: "+e.getResponse().getEntity(String.class)); } createSamples(); createWorkflowRun(); }
Source:
<code>String getSqlStatement() { StringBuilder statement = new StringBuilder(); statement.append(getSelectClause()) .append(getJoinClause()) .append(getWhereClause()); if (isOrderedQuery()) { statement.append(getOrderClause()); if (!orderCriteria.isEmpty()) { <START> statement.append(getLimitClause()); <END> } } return statement.toString(); }</code><technical_language>is limit ordered query? I want limit a query order. Also, isOrderedQuery() "if (!orderCriteria.isEmpty()) {" redundant of other</technical_language>

Target:
public String getSqlStatement() throws IOException { return getPreparedStatement().toString(); }
Source:
<code>public static Optional<String> getHost(Element element) { String url = element.getAttributeValue( <START> SupportedElements.valueOf(element.getName().toUpperCase()).attribute); <END> URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { return Optional.empty(); } return Optional.of(uri.getHost()); }</code><technical_language>Locale.ROOT rely default locale (e.g. i problems in some locales)</technical_language>

Target:
public static Optional<String> getHost(Element element) { String url = element.getAttributeValue( SupportedElements.valueOf(element.getName().toUpperCase(Locale.ROOT)) .attribute); URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { return Optional.empty(); } return Optional.of(uri.getHost()); }
Source:
<code>public void createStore() { <START> dataStore = DataStoreFactory.createDataStore(new MemoryRequiredNameSpaceOptions(counter + "")); <END> final Index index = new IndexImpl( new MockComponents.MockIndexStrategy(), new MockComponents.TestIndexModel("test1")); final DataTypeAdapter<Integer> adapter = new MockComponents.MockAbstractDataAdapter(MOCK_DATA_TYPE_1); dataStore.addType(adapter, index); counter++; }</code><technical_language>is properly deleting everything, clean this remove this class</technical_language>

Target:
public void createStore() { dataStore = DataStoreFactory.createDataStore(new MemoryRequiredOptions()); final Index index = new IndexImpl( new MockComponents.MockIndexStrategy(), new MockComponents.TestIndexModel("test1")); final DataTypeAdapter<Integer> adapter = new MockComponents.MockAbstractDataAdapter(MOCK_DATA_TYPE_1); dataStore.addType(adapter, index); counter++; }
Source:
<code>public void treeMadeExpectedSplits() { final List<Instance<AttributesMap>> instances = Lists.newArrayList(); AttributesMap attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", true); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 1.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", true); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", false); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", false); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); TreeBuilder treeBuilder = new TreeBuilder().minCategoricalAttributeValueOccurances(0).minLeafInstances(0); Tree tree = treeBuilder.buildPredictiveModel(instances); AttributesMap attributes = new AttributesMap(); attributes.put("a", true); Assert.assertEquals(tree.getProbability(attributes, 1.0),.5); <START> attributes = new AttributesMap(); <END> attributes.put("a", false); Assert.assertEquals(tree.getProbability(attributes, 0.0), 1.0); }</code><technical_language>reason create a new AttributesMap(), overwrite "a"</technical_language>

Target:
public void treeMadeExpectedSplits() { final List<Instance<AttributesMap>> instances = Lists.newArrayList(); AttributesMap attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", true); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 1.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", true); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", false); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); attributesMap = AttributesMap.newHashMap(); attributesMap.put("a", false); instances.add(new InstanceImpl<AttributesMap>(attributesMap, 0.0)); TreeBuilder treeBuilder = new TreeBuilder().minCategoricalAttributeValueOccurances(0).minLeafInstances(0); Tree tree = treeBuilder.buildPredictiveModel(instances); AttributesMap attributes = new AttributesMap(); attributes.put("a", true); Assert.assertEquals(tree.getProbability(attributes, 1.0),.5); attributes.put("a", false); Assert.assertEquals(tree.getProbability(attributes, 0.0), 1.0); }
Source:
<code>private List<String> visitInvocationArguments(AbstractInvocation invocation) { List<String> argumentNames = new ArrayList<>(); for (ExpressionStatement argument : invocation.getArguments()) { if (invocation instanceof FunctionInvocation && ((FunctionInvocation) invocation).useNamedArguments()) { if (!(argument instanceof NamedArgument)) { throw new IllegalArgumentException("Invocation " + invocation.getName() + " must have either all or none of its arguments named"); } NamedArgument namedArgument = (NamedArgument) argument; argumentNames.add(namedArgument.getName()); argument = namedArgument.getExpression(); } argument.accept(this); <START> } <END> return argumentNames; }</code><technical_language>lost a branch here</technical_language>

Target:
private List<String> visitInvocationArguments(AbstractInvocation invocation) { List<String> argumentNames = new ArrayList<>(); for (ExpressionStatement argument : invocation.getArguments()) { if (invocation.usesNamedArguments()) { NamedArgument namedArgument = (NamedArgument) argument; argumentNames.add(namedArgument.getName()); argument = namedArgument.getExpression(); } argument.accept(this); } return argumentNames; }
Source:
<code>for (OsType type : OsType.values()) { <START> osTypeValues.add(type.value().toLowerCase()); <END> }</code><technical_language>value() returns .name().toLowerCase()</technical_language>

Target:
for (OsType type : OsType.values()) { osTypeValues.add(type.value()); }
Source:
<code>public void run() { <START> dataLakeFileClient.append(TestDataCreationHelper.createRandomInputStream(options.getSize()), <END> 0, options.getSize()); }</code><technical_language>I this slightly optimized creating input stream resetting operation: java protected final InputStream inputStream; public AppendFileDatalakeTest(PerfStressOptions options) { inputStream = TestDataCreationHelper.createRandomInputStream(options.getSize()); inputStream.mark(); } public void run() { inputStream.reset(); dataLakeFileClient.append(inputStream, 0, options.getSize()); }</technical_language>

Target:
public void run() { inputStream.reset(); dataLakeFileClient.append(TestDataCreationHelper.createRandomInputStream(options.getSize()), 0, options.getSize()); }
Source:
<code>public void onCompleted() { RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() { @Override public OpenLocalBlockResponse call() throws Exception { if (mLockId != BlockLockManager.INVALID_LOCK_ID) { try { mWorker.unlockBlock(mLockId); } catch (BlockDoesNotExistException e) { <START> LOG.warn("Failed to unlock lock with error {}.", mLockId, e.getMessage()); <END> } mLockId = BlockLockManager.INVALID_LOCK_ID; } else if (mRequest != null) { LOG.warn("Close a closed block {}.", mRequest.getBlockId()); } return null; } @Override public void exceptionCaught(Throwable e) { mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e)); mLockId = BlockLockManager.INVALID_LOCK_ID; } }, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s", mSessionId, mRequest); }</code><technical_language>For locks, convention, do log, lockid block id? log in</technical_language>

Target:
public void onCompleted() { RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() { @Override public OpenLocalBlockResponse call() throws Exception { if (mLockId != BlockLockManager.INVALID_LOCK_ID) { try { mWorker.unlockBlock(mLockId); } catch (BlockDoesNotExistException e) { LOG.warn("Failed to unlock lock of block with error {}.", mLockId, mRequest.getBlockId(), e.getMessage()); } mLockId = BlockLockManager.INVALID_LOCK_ID; } else if (mRequest != null) { LOG.warn("Close a closed block {}.", mRequest.getBlockId()); } return null; } @Override public void exceptionCaught(Throwable e) { mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e)); mLockId = BlockLockManager.INVALID_LOCK_ID; } }, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s", mSessionId, mRequest); }
Source:
<code>public VergeRangersEffect() { <START> super(FILTER_CARD_LAND); <END> staticText = "As long as an opponent controls more lands than you, you may play lands from the top of your library."; }</code><technical_language>StaticFilters.*** prefix time (e.g. StaticFilters.FILTER_CARD_LAND)</technical_language>

Target:
public VergeRangersEffect() { super(StaticFilters.FILTER_CARD_LAND); staticText = "As long as an opponent controls more lands than you, you may play lands from the top of your library."; }
Source:
<code>public boolean validatePMAgentPort() { String portStr = null; Integer port = getParameters().getAgent().getPort(); if (port == null) { if (getParameters().getAgent().getOptionsMap().containsKey(PORT)) { portStr = getParameters().getAgent().getOptionsMap().get(PORT); } else { return true; } } portStr = portStr == null ? getParameters().getAgent().getPort().toString() : portStr; <START> return portStr.equals("") || ValidationUtils.validatePort(port); <END> }</code><technical_language>miss a validation for port if provided getParameters().getAgent().getOptionsMap().get(PORT)</technical_language>

Target:
public boolean validatePMAgentPort() { String portStr = null; Integer port = getParameters().getAgent().getPort(); if (port == null) { if (getParameters().getAgent().getOptionsMap().containsKey(PORT)) { portStr = getParameters().getAgent().getOptionsMap().get(PORT); if (StringUtils.isNumeric(portStr)) { port = Integer.parseInt(portStr); } else { return false; } } else { return true; } } portStr = portStr == null ? getParameters().getAgent().getPort().toString() : portStr; return portStr.equals("") || ValidationUtils.validatePort(port); }
Source:
<code>public static void setup() { CqlSession session = SESSION_RULE.session(); for (String query : createStatements(CCM_RULE)) { session.execute( SimpleStatement.builder(query).setExecutionProfile(SESSION_RULE.slowProfile()).build()); } InventoryMapper mapper = InventoryMapper.builder(SESSION_RULE.session()) <START> .withResultProducers( <END> new VoidListenableFutureProducer(), new SingleEntityListenableFutureProducer()) .build(); dao = mapper.productDao(SESSION_RULE.keyspace()); }</code><technical_language>yes, I agree this is related. need provide mapperResultsProducers suggestion hide client: (this call .withResultProducers(new MutinyMappedResultProducer(), new UniMappedResultSetProducer()))</technical_language>

Target:
public static void setup() { CqlSession session = SESSION_RULE.session(); for (String query : createStatements(CCM_RULE)) { session.execute( SimpleStatement.builder(query).setExecutionProfile(SESSION_RULE.slowProfile()).build()); } InventoryMapper mapper = InventoryMapper.builder(SESSION_RULE.session()).build(); dao = mapper.productDao(SESSION_RULE.keyspace()); }
Source:
<code>public void addSchemaUrl(String schemaName) { <START> new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC) <END> .until(visibilityOf(addSchemaUrlInput)); addSchemaUrlInput.sendKeys(schemaName); new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC) .until(visibilityOfElementLocated(By.id("askValue-dialog-ok"))) .click(); }</code><technical_language>"SeleniumWebDriverHelper"</technical_language>

Target:
public void addSchemaUrl(String schemaName) { webDriverHelper.waitVisibility(addSchemaUrlInput); addSchemaUrlInput.sendKeys(schemaName); webDriverHelper.waitAndClick(By.id("askValue-dialog-ok")); }
Source:
<code>public static Thread runInDaemonThread(final Runnable runnable, DaemonToken token) { if (!ModuleFactory.isTokenValid(token)) { throw new ContextAuthenticationException("Invalid token " + token); } DaemonThread thread = new DaemonThread() { @Override public void run() { isDaemonThread.set(true); try { Context.openSession(); <START> new Thread(runnable).start(); <END> } finally { Context.closeSession(); } } }; thread.start(); return thread; }</code><technical_language>This is intended start method is called below. Please revert it. need annotate run method (line 270) with: @SuppressWarnings("squid:3AS1217") //We intentionally do start a new thread yet, wrap run call in a session</technical_language>

Target:
public static Thread runInDaemonThread(final Runnable runnable, DaemonToken token) { if (!ModuleFactory.isTokenValid(token)) { throw new ContextAuthenticationException("Invalid token " + token); } DaemonThread thread = new DaemonThread() { @Override public void run() { isDaemonThread.set(true); try { Context.openSession(); runnable.run(); } finally { Context.closeSession(); } } }; thread.start(); return thread; }
Source:
<code>public void invalidateAll(boolean async) { if (!lock.tryLock()) { return; } try { <START> if (async) { <END> executorService.execute(new Runnable() { @Override public void run() { cache.invalidateAll(builderFactory); } }); } else { cache.invalidateAll(builderFactory); } } finally { lock.unlock(); } }</code><technical_language>move if (async) lock-unlock pay synchronization penalty if need to</technical_language>

Target:
public void invalidateAll(boolean async) { if (async) { executorService.execute(new Runnable() { @Override public void run() { safeInvalidateAll(builderFactory); } }); } else { safeInvalidateAll(builderFactory); } }
Source:
<code>public static int primaryKeyOid(RelationInfo relationInfo) { <START> var primaryKey = relationInfo.primaryKey().stream().map(ColumnIdent::name).collect(Collectors.joining()); <END> var b = new BytesRef(Type.PRIMARY_KEY.toString() + relationInfo.ident().fqn() + primaryKey); return murmurhash3_x86_32(b.bytes, b.offset, b.length, 0); }</code><technical_language>suggestion var primaryKey = Lists2.joinOn(" ", relationInfo.primaryKey(), ColumnIdent::name);</technical_language>

Target:
public static int primaryKeyOid(RelationInfo relationInfo) { var primaryKey = Lists2.joinOn(" ", relationInfo.primaryKey(), ColumnIdent::name); var b = new BytesRef(Type.PRIMARY_KEY.toString() + relationInfo.ident().fqn() + primaryKey); return murmurhash3_x86_32(b.bytes, b.offset, b.length, 0); }
Source:
<code><START> public EdxRatingBar(Context context, AttributeSet attrs) { <END> super(context, attrs); }</code><technical_language>I a silly question. methods for</technical_language>

Target:
public EdxRatingBar(Context context, AttributeSet attrs) { super(context, attrs); init(); }
Source:
<code>public static String subscribeQueue(AmazonSNS sns, AmazonSQS sqs, String snsTopicArn, String sqsQueueUrl, boolean extendPolicy) throws AmazonClientException, AmazonServiceException { List<String> sqsAttrNames = Arrays.asList(QueueAttributeName.QueueArn.toString(), QueueAttributeName.Policy.toString()); Map<String, String> sqsAttrs = sqs.getQueueAttributes(sqsQueueUrl, sqsAttrNames).getAttributes(); String sqsQueueArn = sqsAttrs.get(QueueAttributeName.QueueArn.toString()); String policyJson = sqsAttrs.get(QueueAttributeName.Policy.toString()); <START> Policy policy = extendPolicy || policyJson == null || policyJson.length() == 0 <END> ? Policy.fromJson(policyJson) : new Policy(); policy.getStatements().add(new Statement(Effect.Allow) .withId("topic-subscription-" + snsTopicArn) .withPrincipals(Principal.AllUsers) .withActions(SQSActions.SendMessage) .withResources(new Resource(sqsQueueArn)) .withConditions(ConditionFactory.newSourceArnCondition(snsTopicArn))); Map<String, String> newAttrs = new HashMap<String, String>(); newAttrs.put(QueueAttributeName.Policy.toString(), policy.toJson()); sqs.setQueueAttributes(new SetQueueAttributesRequest(sqsQueueUrl, newAttrs)); SubscribeResult subscribeResult = sns.subscribe(snsTopicArn, "sqs", sqsQueueArn); return subscribeResult.getSubscriptionArn(); }</code><technical_language>missing want extend policy if flag is set, policyJson is null empty</technical_language>

Target:
public static String subscribeQueue(AmazonSNS sns, AmazonSQS sqs, String snsTopicArn, String sqsQueueUrl, boolean extendPolicy) throws AmazonClientException, AmazonServiceException { List<String> sqsAttrNames = Arrays.asList(QueueAttributeName.QueueArn.toString(), QueueAttributeName.Policy.toString()); Map<String, String> sqsAttrs = sqs.getQueueAttributes(sqsQueueUrl, sqsAttrNames).getAttributes(); String sqsQueueArn = sqsAttrs.get(QueueAttributeName.QueueArn.toString()); String policyJson = sqsAttrs.get(QueueAttributeName.Policy.toString()); Policy policy = extendPolicy && policyJson != null && policyJson.length() > 0 ? Policy.fromJson(policyJson) : new Policy(); policy.getStatements().add(new Statement(Effect.Allow) .withId("topic-subscription-" + snsTopicArn) .withPrincipals(Principal.AllUsers) .withActions(SQSActions.SendMessage) .withResources(new Resource(sqsQueueArn)) .withConditions(ConditionFactory.newSourceArnCondition(snsTopicArn))); Map<String, String> newAttrs = new HashMap<String, String>(); newAttrs.put(QueueAttributeName.Policy.toString(), policy.toJson()); sqs.setQueueAttributes(new SetQueueAttributesRequest(sqsQueueUrl, newAttrs)); SubscribeResult subscribeResult = sns.subscribe(snsTopicArn, "sqs", sqsQueueArn); return subscribeResult.getSubscriptionArn(); }
Source:
<code>public void theGetRetrieveConfigurationRequestIsReceived() throws Throwable { this.correlationUidPattern = Pattern.compile(this.organisationId.getOrganisationId() + "\\|\\|\\|\\S{17}\\|\\|\\|\\S{17}"); this.testCase = this.wsdlProjectFactory.createWsdlTestCase(SOAP_PROJECT_XML, TEST_SUITE_XML, TEST_CASE_XML); PROPERTIES_MAP.put("DeviceIdentificationE", this.deviceId.getDeviceId()); PROPERTIES_MAP.put("OrganisationIdentification", this.organisationId.getOrganisationId()); final TestCaseResult runTestStepByName = this.testCaseRunner.runWsdlTestCase(this.testCase, PROPERTIES_MAP, TEST_CASE_NAME_REQUEST); final TestStepResult runTestStepByNameResult = runTestStepByName.getRunTestStepByName(); final WsdlTestCaseRunner wsdlTestCaseRunner = runTestStepByName.getResults(); assertEquals(TestStepStatus.OK, runTestStepByNameResult.getStatus()); for (final TestStepResult tcr : wsdlTestCaseRunner.getResults()) { this.response = ((MessageExchange) tcr).getResponseContent(); this.correlationUidMatcher = this.correlationUidPattern.matcher(this.response); } <START> this.correlationUidMatcher.find(); <END> this.correlationUid = this.correlationUidMatcher.group(); }</code><technical_language>asserttrue...</technical_language>

Target:
public void theGetRetrieveConfigurationRequestIsReceived() throws Throwable { this.correlationUidPattern = Pattern.compile(this.organisationId.getOrganisationId() + "\\|\\|\\|\\S{17}\\|\\|\\|\\S{17}"); this.testCase = this.wsdlProjectFactory.createWsdlTestCase(SOAP_PROJECT_XML, TEST_SUITE_XML, TEST_CASE_XML); PROPERTIES_MAP.put("DeviceIdentificationE", this.deviceId.getDeviceId()); PROPERTIES_MAP.put("OrganisationIdentification", this.organisationId.getOrganisationId()); final TestCaseResult runTestStepByName = this.testCaseRunner.runWsdlTestCase(this.testCase, PROPERTIES_MAP, TEST_CASE_NAME_REQUEST); final TestStepResult runTestStepByNameResult = runTestStepByName.getRunTestStepByName(); final WsdlTestCaseRunner wsdlTestCaseRunner = runTestStepByName.getResults(); assertEquals(TestStepStatus.OK, runTestStepByNameResult.getStatus()); for (final TestStepResult tcr : wsdlTestCaseRunner.getResults()) { this.response = ((MessageExchange) tcr).getResponseContent(); this.correlationUidMatcher = this.correlationUidPattern.matcher(this.response); } assertTrue(this.correlationUidMatcher.find()); this.correlationUid = this.correlationUidMatcher.group(); }