auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void stopNavigation() { <START> clickRouteCancel(); <END> }</code><technical_language>Extract clickRouteCancel() stopNavigation() call stopNavigation() clickRouteCancel()</technical_language>

Target:
public void stopNavigation() { mapRouteInfoMenu.hide(); if (mapActivity.getRoutingHelper().isFollowingMode()) { mapActivity.getMapActions().stopNavigationActionConfirm(); } else { mapActivity.getMapActions().stopNavigationWithoutConfirm(); } }
Source:
<code>public final Map<String, Object> getGeocodedData(final String ip) { InetAddress ipAddress = null; Map<String, Object> geoData = getDefaultMap(); try { ipAddress = InetAddress.getByName(ip); } catch (UnknownHostException hEx) { Log.warn(hEx); return geoData; } CityResponse response = null; try { response = databaseReader.city(ipAddress); } catch (IOException iEx) { Log.warn(iEx); return geoData; } catch (GeoIp2Exception gEx) { Log.warn(gEx); return geoData; } if (response == null) return geoData; Continent continent = response.getContinent(); if (continent != null && continent.getName() != null) geoData.put(CONTINENT, continent.getName()); Country country = response.getCountry(); if (country != null && country.getIsoCode() != null) { geoData.put(COUNTRY_CODE, country.getIsoCode()); geoData.put(COUNTRY, country.getName()); } List<Subdivision> subdivisions = response.getSubdivisions(); if (subdivisions != null && subdivisions.size() > 0) { <START> geoData.put(SUB_DIVISION, subdivisions.get(0).getName()); <END> } City city = response.getCity(); if (city != null && city.getName() != null) geoData.put(CITY, city.getName()); Postal postal = response.getPostal(); if (postal != null && postal.getCode() != null) geoData.put(POSTAL_CODE, postal.getCode()); Location location = response.getLocation(); if (location != null) { geoData.put(LATITUDE, location.getLatitude()); geoData.put(LONGITUDE, location.getLongitude()); if (location.getTimeZone() != null) geoData.put(TIME_ZONE, location.getTimeZone()); } return geoData; }</code><technical_language>Hmm, is multiple subdivisions? ask Oliver if this is important data keep</technical_language>

Target:
public final Map<String, Object> getGeocodedData(final String ip) { InetAddress ipAddress = null; Map<String, Object> geoData = getDefaultMap(); try { ipAddress = InetAddress.getByName(ip); } catch (UnknownHostException hEx) { LOG.warn(hEx); return geoData; } CityResponse response = null; try { response = databaseReader.city(ipAddress); } catch (IOException iEx) { LOG.warn(iEx); return geoData; } catch (GeoIp2Exception gEx) { LOG.warn(gEx); return geoData; } if (response == null) return geoData; Continent continent = response.getContinent(); if (continent != null && continent.getName() != null) geoData.put(CONTINENT, continent.getName()); Country country = response.getCountry(); if (country != null && country.getIsoCode() != null) { geoData.put(COUNTRY_CODE, country.getIsoCode()); geoData.put(COUNTRY, country.getName()); } List<Subdivision> subdivisions = response.getSubdivisions(); if (subdivisions != null && subdivisions.size() > 0) { geoData.put(SUBDIVISION, subdivisions.get(0).getName()); } City city = response.getCity(); if (city != null && city.getName() != null) geoData.put(CITY, city.getName()); Postal postal = response.getPostal(); if (postal != null && postal.getCode() != null) geoData.put(POSTAL_CODE, postal.getCode()); Location location = response.getLocation(); if (location != null) { geoData.put(LATITUDE, location.getLatitude()); geoData.put(LONGITUDE, location.getLongitude()); if (location.getTimeZone() != null) geoData.put(TIMEZONE, location.getTimeZone()); } return geoData; }
Source:
<code>CosmosAsyncStoredProcedureResponse(ResourceResponse<StoredProcedure> response, CosmosAsyncContainer cosmosContainer) { super(response); if (response.getResource() != null) { super.setProperties(new CosmosStoredProcedureProperties(response)); storedProcedure = new CosmosAsyncStoredProcedure(this.getProperties().getId(), cosmosContainer); storedProcedureResponse = null; } else { <START> storedProcedureResponse = null; <END> storedProcedure = null; } }</code><technical_language>done if else, duplicate statement in if else</technical_language>

Target:
CosmosAsyncStoredProcedureResponse(ResourceResponse<StoredProcedure> response, CosmosAsyncContainer cosmosContainer) { super(response); if (response.getResource() != null) { super.setProperties(new CosmosStoredProcedureProperties(response)); storedProcedure = new CosmosAsyncStoredProcedure(this.getProperties().getId(), cosmosContainer); } else { storedProcedure = null; } storedProcedureResponse = null; }
Source:
<code>private Predicate createSearchPredicate(String filter, String searchTerm) { Predicate rootPredicate = Predicate.empty(); if (filter != null && !filter.trim().isEmpty()) { NugetODataFilterParserTemplate t = new NugetODataFilterParserTemplate(rootPredicate); rootPredicate = t.parseFilterExpression(filter); } <START> if (searchTerm != null && !searchTerm.trim().isEmpty()) { <END> rootPredicate.and(Predicate.of(ExpOperator.LIKE.of("artifactCoordinates.coordinates.Id", "%" + searchTerm + "%"))); } return rootPredicate; }</code><technical_language>Cosmetic: Curly braces new line</technical_language>

Target:
private Predicate createSearchPredicate(String filter, String searchTerm) { Predicate rootPredicate = Predicate.empty(); if (filter != null && !filter.trim().isEmpty()) { NugetODataFilterParserTemplate t = new NugetODataFilterParserTemplate(rootPredicate); rootPredicate = t.parseFilterExpression(filter); } if (searchTerm != null && !searchTerm.trim().isEmpty()) { rootPredicate.and(Predicate.of(ExpOperator.LIKE.of("artifactCoordinates.coordinates.id", "%" + searchTerm + "%"))); } return rootPredicate; }
Source:
<code>public EObject apply(EObject input) { if (input != null) { EObject container = input.eContainer(); <START> while (!(container instanceof RepresentationDescription || container instanceof RepresentationElementMapping || container instanceof RepresentationExtensionDescription)) { <END> container = container.eContainer(); } return container; } else { return null; } }</code><technical_language>! in while (!( container null, NPE occur in container = container.eContainer()</technical_language>

Target:
public EObject apply(EObject input) { if (input != null) { EObject container = input.eContainer(); while (container != null && !isRelevant(container)) { container = container.eContainer(); } return container; } else { return null; } }
Source:
<code>public void onFailure(SshPollValue val) { <START> log.error("Chef attribute query did not respond as expected. exitcode={} stdout={} stderr={}", new Object[]{val.getExitStatus(), val.getStdout(), val.getStderr()}); <END> for (AttributeSensor attribute : chefAttributeSensors) { if (!attribute.getName().startsWith(CHEF_ATTRIBUTE_PREFIX)) continue; entity.setAttribute(attribute, null); } }</code><technical_language>suggesting giving more info (e.g. connect to). stderr helpful though</technical_language>

Target:
public void onFailure(SshPollValue val) { log.error("Chef attribute query did not respond as expected. exitcode={} stdout={} stderr={}", new Object[]{val.getExitStatus(), val.getStdout(), val.getStderr()}); for (AttributeSensor attribute : chefAttributeSensors.values()) { if (!attribute.getName().startsWith(CHEF_ATTRIBUTE_PREFIX)) continue; entity.setAttribute(attribute, null); } }
Source:
<code>public static void copyToFileAndClose(InputStream is, File file) throws IOException { OutputStream os = null; try { file.getParentFile().mkdirs(); os = new BufferedOutputStream(new FileOutputStream(file)); ByteStreams.copy(is, os); } finally { CloseQuietly.close(is); <START> CloseQuietly.close(os); <END> } }</code><technical_language>try resources here</technical_language>

Target:
public static void copyToFileAndClose(InputStream is, File file) throws IOException { file.getParentFile().mkdirs(); try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { ByteStreams.copy(is, os); } finally { CloseQuietly.close(is); } }
Source:
<code>public static ImmutableList<EnumConstant> addEnum( final ImmutableList<EnumConstant> enumConstants, final String newEnumValue) { <START> ImmutableList.Builder<EnumConstant> builder = ImmutableList.builder(); <END> if (hasContent(enumConstants)) { builder.addAll(enumConstants); } builder.add(new EnumConstant(newEnumValue)); return builder.build(); }</code><technical_language>Missing final</technical_language>

Target:
public static ImmutableList<EnumConstant> addEnum( final ImmutableList<EnumConstant> enumConstants, final String newEnumValue) { final ImmutableList.Builder<EnumConstant> builder = ImmutableList.builder(); if (hasContent(enumConstants)) { builder.addAll(enumConstants); } builder.add(new EnumConstant(newEnumValue)); return builder.build(); }
Source:
<code>protected boolean handleEquivalences(Diff diff, boolean rightToLeft, Monitor monitor) { boolean continueMerge = true; for (Diff equivalent : diff.getEquivalence().getDifferences()) { if (diff instanceof ReferenceChange && equivalent instanceof ReferenceChange) { final ReferenceChange diffRC = (ReferenceChange)diff; final ReferenceChange equivalentRC = (ReferenceChange)equivalent; if ((diffRC.getReference().getEOpposite() == equivalentRC.getReference() || diffRC .getReference() == equivalentRC.getReference()) <START> && equivalent.getState() == DifferenceState.UNRESOLVED) { <END> final boolean mergeEquivalence = isOneToManyAndAdd(equivalentRC, rightToLeft) || isOneToOneAndSet(equivalentRC, rightToLeft); if (mergeEquivalence) { mergeDiff(equivalent, rightToLeft, monitor); continueMerge = false; } } } if (rightToLeft) { if (diff.getSource() == DifferenceSource.LEFT) { continueMerge = continueMerge && !any(equivalent.getImplies(), in(diff.getRequiredBy())); } else { continueMerge = continueMerge && !any(equivalent.getImpliedBy(), in(diff.getRequires())); } } else { if (diff.getSource() == DifferenceSource.LEFT) { continueMerge = continueMerge && !any(equivalent.getImpliedBy(), in(diff.getRequires())); } else { continueMerge = continueMerge && !any(equivalent.getImplies(), in(diff.getRequiredBy())); } } equivalent.setState(DifferenceState.MERGED); } return continueMerge; }</code><technical_language>I for this condition good extract final boolean variables for clauses improve understandability</technical_language>

Target:
protected boolean handleEquivalences(Diff diff, boolean rightToLeft, Monitor monitor) { boolean continueMerge = true; for (Diff equivalent : diff.getEquivalence().getDifferences()) { if (diff instanceof ReferenceChange && equivalent instanceof ReferenceChange) { final ReferenceChange diffRC = (ReferenceChange)diff; final ReferenceChange equivalentRC = (ReferenceChange)equivalent; final boolean isOppositeReference = diffRC.getReference().getEOpposite() == equivalentRC .getReference(); final boolean isSameReference = diffRC.getReference() == equivalentRC.getReference(); if ((isOppositeReference || isSameReference) && equivalent.getState() == DifferenceState.UNRESOLVED) { final boolean mergeEquivalence = isOneToManyAndAdd(equivalentRC, rightToLeft) || isOneToOneAndSet(equivalentRC, rightToLeft); if (mergeEquivalence) { mergeDiff(equivalent, rightToLeft, monitor); continueMerge = false; } } } if (rightToLeft) { if (diff.getSource() == DifferenceSource.LEFT) { continueMerge = continueMerge && !any(equivalent.getImplies(), in(diff.getRequiredBy())); } else { continueMerge = continueMerge && !any(equivalent.getImpliedBy(), in(diff.getRequires())); } } else { if (diff.getSource() == DifferenceSource.LEFT) { continueMerge = continueMerge && !any(equivalent.getImpliedBy(), in(diff.getRequires())); } else { continueMerge = continueMerge && !any(equivalent.getImplies(), in(diff.getRequiredBy())); } } equivalent.setState(DifferenceState.MERGED); } return continueMerge; }
Source:
<code>public static void assertEquals(Iterator<?> actual, Iterator<?> expected, String message) { <START> if (actual == null && expected == null) { <END> return; } if(actual == null || expected == null) { String msg = message != null ? message : "Iterators not equal: expected: " + expected + " and actual: " + actual; fail(msg); } if(actual == expected) { return; } int i = -1; while(actual.hasNext() && expected.hasNext()) { i++; Object e = expected.next(); Object a = actual.next(); String explanation = "Iterators differ at element [" + i + "]: " + e + " != " + a; String errorMessage = message == null ? explanation : message + ": " + explanation; assertEqualsImpl(a, e, errorMessage); } if(actual.hasNext()) { String explanation = "Actual iterator returned more elements than the expected iterator."; String errorMessage = message == null ? explanation : message + ": " + explanation; fail(errorMessage); } else if(expected.hasNext()) { String explanation = "Expected iterator returned more elements than the actual iterator."; String errorMessage = message == null ? explanation : message + ": " + explanation; fail(errorMessage); } }</code><technical_language>if (actual == expected)</technical_language>

Target:
public static void assertEquals(Iterator<?> actual, Iterator<?> expected, String message) { if(actual == expected) { return; } if(actual == null || expected == null) { String msg = message != null ? message : "Iterators not equal: expected: " + expected + " and actual: " + actual; fail(msg); } int i = -1; while(actual.hasNext() && expected.hasNext()) { i++; Object e = expected.next(); Object a = actual.next(); String explanation = "Iterators differ at element [" + i + "]: " + e + " != " + a; String errorMessage = message == null ? explanation : message + ": " + explanation; assertEqualsImpl(a, e, errorMessage); } if(actual.hasNext()) { String explanation = "Actual iterator returned more elements than the expected iterator."; String errorMessage = message == null ? explanation : message + ": " + explanation; fail(errorMessage); } else if(expected.hasNext()) { String explanation = "Expected iterator returned more elements than the actual iterator."; String errorMessage = message == null ? explanation : message + ": " + explanation; fail(errorMessage); } }
Source:
<code>public void updateDigitalTwin(String digitalTwinId, List<Object> digitalTwinUpdateOperations) { <START> updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, new RequestOptions(), Context.NONE).getValue(); <END> }</code><technical_language>need call .getValue() here, method value, return it. invoke API leave that</technical_language>

Target:
public void updateDigitalTwin(String digitalTwinId, List<Object> digitalTwinUpdateOperations) { updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, new UpdateDigitalTwinRequestOptions(), Context.NONE); }
Source:
<code>private EmptyByteBuf(ByteBufAllocator alloc, ByteOrder order) { ObjectUtil.checkNotNull(alloc, "alloc"); <START> this.alloc = alloc; <END> this.order = order; str = StringUtil.simpleClassName(this) + (order == ByteOrder.BIG_ENDIAN? "BE" : "LE"); }</code><technical_language>nit: merge lines checkNotNull return argument</technical_language>

Target:
private EmptyByteBuf(ByteBufAllocator alloc, ByteOrder order) { this.alloc = ObjectUtil.checkNotNull(alloc, "alloc"); this.order = order; str = StringUtil.simpleClassName(this) + (order == ByteOrder.BIG_ENDIAN? "BE" : "LE"); }
Source:
<code>private ToolStripButton getSchedulerLinkButton() { ToolStripButton schedulerButton = new ToolStripButton("Scheduler"); schedulerButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { <START> Window.open("/rm", "", ""); <END> } }); return schedulerButton; }</code><technical_language>I is a mistake, "/scheduler",</technical_language>

Target:
private ToolStripButton getSchedulerLinkButton() { ToolStripButton schedulerButton = new ToolStripButton("Scheduler"); schedulerButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open("/Scheduler", "", ""); } }); return schedulerButton; }
Source:
<code>public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) { LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory); if (clearHistory) { this.clearHistory(); } if (!openExternal) { <START> if (url.startsWith("file://") || pluginManager.shouldAllowNavigation(url)) { <END> loadUrlIntoView(url, true); return; } LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")"); } try { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, resourceApi.getMimeType(uri)); } else { intent.setData(uri); } cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } }</code><technical_language>Shoudl check for null -- avoid NPE</technical_language>

Target:
public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) { LOG.d(TAG, "showWebPage(%s, %b, %b, HashMap", url, openExternal, clearHistory); if (clearHistory) { this.clearHistory(); } if (!openExternal) { if (helper.shouldAllowNavigation(url)) { loadUrlIntoView(url, true); return; } LOG.w(TAG, "showWebPage: Cannot load URL into webview since it is not in white list. Loading into browser instead. (URL=" + url + ")"); } try { Intent intent = new Intent(Intent.ACTION_VIEW); Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, resourceApi.getMimeType(uri)); } else { intent.setData(uri); } cordova.getActivity().startActivity(intent); } catch (android.content.ActivityNotFoundException e) { LOG.e(TAG, "Error loading url " + url, e); } }
Source:
<code><START> public SerialPortParameters(int baudrate, int dataBits, int stopBits, int parity, int flowControl) { <END> setParams(baudrate, dataBits, stopBits, parity, flowControl); }</code><technical_language>This constructor verify values of parameter throw exception if is supported, i.e., of 0 (but want add other restrictions). /** * Sets serial port configuration parameters. * * @param baudrate Serial connection baud rate. * @param dataBits Serial connection data bits. * @param stopBits Serial connection stop bits. * @param parity Serial connection parity. * @param flowControl Serial connection flow control. * * @throws IllegalArgumentException if {@code baudrate < 0} * if {@code dataBits < 0} * if {@code stopBits < 0} * if {@code parity < 0} * if {@code flowControl < 0}. */ public void setParams(int baudrate, int dataBits, int stopBits, int parity, int flowControl) { if (baudrate < 0) throw new IllegalArgumentException("Baudrate 0"); if (dataBits < 0) throw new IllegalArgumentException("Number of data bits 0"); if (stopBits < 0) throw new IllegalArgumentException("Number of stop bits 0"); if (parity < 0) throw new IllegalArgumentException("Illegal parity value"); if (flowControl < 0) throw new IllegalArgumentException("Illegal flow control value"); this.baudrate = baudrate; this.dataBits = dataBits; this.stopBits = stopBits; this.parity = parity; this.flowControl = flowControl; }</technical_language>

Target:
public SerialPortParameters(int baudrate, int dataBits, int stopBits, int parity, int flowControl) { if (baudrate < 0) throw new IllegalArgumentException("Baudrate cannot be less than 0."); if (dataBits < 0) throw new IllegalArgumentException("Number of data bits cannot be less than 0."); if (stopBits < 0) throw new IllegalArgumentException("Number of stop bits cannot be less than 0."); if (parity < 0) throw new IllegalArgumentException("Illegal parity value."); if (flowControl < 0) throw new IllegalArgumentException("Illegal flow control value."); this.baudrate = baudrate; this.dataBits = dataBits; this.stopBits = stopBits; this.parity = parity; this.flowControl = flowControl; }
Source:
<code>public AbstractJob(String thingUID) { <START> checkArgument(thingUID != null, "Thing UID cannot be null"); <END> this.thingUID = thingUID; }</code><technical_language>instead of null I prefer null in error messages point caller of this method failure. instance returned a method null if null. A method parameter null time null guarantee correct behaviour of method</technical_language>

Target:
public AbstractJob(String thingUID) { checkArgument(thingUID != null, "The thingUID must not be null"); this.thingUID = thingUID; }
Source:
<code>public void updatePatientsList() { <START> new PatientDAO().getAllPatients().observeOn(AndroidSchedulers.mainThread()).subscribe(patientList -> { <END> final int NO_STRING_ID = R.string.last_vitals_none_label; boolean isFiltering = StringUtils.notNull(mQuery); if (isFiltering) { patientList = FilterUtil.getPatientsFilteredByQuery(patientList, mQuery); if (patientList.isEmpty()) { mFormEntryPatientListView.updateListVisibility(false, R.string.search_patient_no_result_for_query, mQuery); } else { mFormEntryPatientListView.updateListVisibility(true, NO_STRING_ID, null); } } else { if (patientList.isEmpty()) { mFormEntryPatientListView.updateListVisibility(false, R.string.search_patient_no_results, null); } else { mFormEntryPatientListView.updateListVisibility(true, NO_STRING_ID, null); } } mFormEntryPatientListView.updateAdapter(patientList); }); }</code><technical_language>do this match current setup subscribing unsebscribing ? addSubsrciptio() creating new</technical_language>

Target:
public void updatePatientsList() { addSubscription(new PatientDAO().getAllPatients() .observeOn(AndroidSchedulers.mainThread()) .subscribe(patientList -> { final int NO_STRING_ID = R.string.last_vitals_none_label; boolean isFiltering = StringUtils.notNull(mQuery); if (isFiltering) { patientList = FilterUtil.getPatientsFilteredByQuery(patientList, mQuery); if (patientList.isEmpty()) { mFormEntryPatientListView.updateListVisibility(false, R.string.search_patient_no_result_for_query, mQuery); } else { mFormEntryPatientListView.updateListVisibility(true, NO_STRING_ID, null); } } else { if (patientList.isEmpty()) { mFormEntryPatientListView.updateListVisibility(false, R.string.search_patient_no_results, null); } else { mFormEntryPatientListView.updateListVisibility(true, NO_STRING_ID, null); } } mFormEntryPatientListView.updateAdapter(patientList); })); }
Source:
<code><START> private synchronized BuildAction getBuildAction(IWorkbenchWindow window) { <END> if (buildAction == null) { buildAction = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD); } return buildAction; }</code><technical_language>This handler is application level. means multiple windows, need return build action for window add a window listener clear a window entry if window closes</technical_language>

Target:
private BuildAction getBuildAction(IWorkbenchWindow window) { BuildAction buildAction = (BuildAction) buildActions.get(window); if (buildAction != null) { return buildAction; } buildAction = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD); buildActions.put(window, buildAction); window.addPageListener(new IPageListener() { public void pageOpened(IWorkbenchPage page) { } public void pageClosed(IWorkbenchPage page) { IWorkbenchWindow closedWindow = page.getWorkbenchWindow(); buildActions.remove(closedWindow); closedWindow.removePageListener(this); } public void pageActivated(IWorkbenchPage page) { } }); return buildAction; }
Source:
<code>public void setInstalledCharEnd(int charEnd) throws CoreException { int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); <START> if (charEnd != existingValue) { <END> setAttribute(IMarker.CHAR_END, charEnd); setAttribute( IMarker.MESSAGE, getMarkerMessage() ); } }</code><technical_language>setInstalledLineNumber, this set RESET_INSTALLED_LOCATION</technical_language>

Target:
public void setInstalledCharEnd(int charEnd) throws CoreException { int existingValue = ensureMarker().getAttribute(IMarker.CHAR_END, -1); if (charEnd != existingValue) { setAttribute(IMarker.CHAR_END, charEnd); setAttribute(RESET_INSTALLED_LOCATION, Boolean.TRUE); setAttribute( IMarker.MESSAGE, getMarkerMessage() ); } }
Source:
<code><START> private static List<ElementLine> readLines(InputStream input) throws IOException { final List<String> rawLines = IOUtils.readLines(input, StandardCharsets.UTF_8).stream() .map(String::trim) .filter(StringUtils::isNotEmpty) .filter(line -> !line.startsWith("#")) .collect(Collectors.toList()); final List<ElementLine> lines = new ArrayList<>(); for (String rawLine : rawLines) { final String[] rawLineSplit = rawLine.split("="); ElementLine line = readLine(rawLineSplit); if (line != null) { lines.add(line); } } return lines; } <END></code><technical_language>this a normal property file? If so, read Properties class JDK. Properties, parse - Properties class do underlying I/O syntax checking for you</technical_language>

Target:
private static List<ElementLine> readLines(InputStream input) throws IOException { final Properties properties = new Properties(); properties.load(new InputStreamReader(input, StandardCharsets.UTF_8)); return properties.entrySet().stream() .map(entry -> Pair.of(trim(entry.getKey().toString()), trim(entry.getValue().toString()))) .filter(pair -> isNotEmpty(pair.getKey())) .map(pair -> new ElementLine(pair.getKey(), readLine(pair.getValue()))) .collect(Collectors.toList()); }
Source:
<code>private static double similarity(BufferedImage var, BufferedImage cont) throws Exception { double[] varArr = new double[var.getWidth()*var.getHeight()*3]; double[] contArr = new double[cont.getWidth()*cont.getHeight()*3]; <START> if (varArr.length!=contArr.length) <END> throw new Exception("The pictures are different sizes!"); for(int i = 0; i < var.getHeight(); i++) { for(int j = 0; j < var.getWidth(); j++) { varArr[i*var.getWidth() + j + 0] = new Color(var.getRGB(j, i)).getRed(); contArr[i*cont.getWidth() + j + 0] = new Color(cont.getRGB(j, i)).getRed(); varArr[i*var.getWidth() + j + 1] = new Color(var.getRGB(j, i)).getGreen(); contArr[i*cont.getWidth() + j + 1] = new Color(cont.getRGB(j, i)).getGreen(); varArr[i*var.getWidth() + j + 2] = new Color(var.getRGB(j, i)).getBlue(); contArr[i*cont.getWidth() + j + 2] = new Color(cont.getRGB(j, i)).getBlue(); } } double mins=0; double maxs=0; for(int i=0;i!=varArr.length;i++){ if (varArr[i]>contArr[i]){ mins+=contArr[i]; maxs+=varArr[i]; } else { mins+=varArr[i]; maxs+=contArr[i]; } } return mins/maxs; }</code><technical_language>aspect ratios considered well</technical_language>

Target:
private static double similarity(BufferedImage var, BufferedImage cont) { double[] varArr = new double[var.getWidth()*var.getHeight()*3]; double[] contArr = new double[cont.getWidth()*cont.getHeight()*3]; if (varArr.length!=contArr.length) throw new IllegalStateException("The pictures are different sizes!"); for(int i = 0; i < var.getHeight(); i++) { for(int j = 0; j < var.getWidth(); j++) { varArr[i*var.getWidth() + j + 0] = new Color(var.getRGB(j, i)).getRed(); contArr[i*cont.getWidth() + j + 0] = new Color(cont.getRGB(j, i)).getRed(); varArr[i*var.getWidth() + j + 1] = new Color(var.getRGB(j, i)).getGreen(); contArr[i*cont.getWidth() + j + 1] = new Color(cont.getRGB(j, i)).getGreen(); varArr[i*var.getWidth() + j + 2] = new Color(var.getRGB(j, i)).getBlue(); contArr[i*cont.getWidth() + j + 2] = new Color(cont.getRGB(j, i)).getBlue(); } } double mins=0; double maxs=0; for(int i=0;i!=varArr.length;i++){ if (varArr[i]>contArr[i]){ mins+=contArr[i]; maxs+=varArr[i]; } else { mins+=varArr[i]; maxs+=contArr[i]; } } return mins/maxs; }
Source:
<code>public void replaceOngoingState(List<ITmfStateInterval> newStateIntervals) { final int size = newStateIntervals.size(); fReadWriteLock.writeLock().lock(); try { fOngoingStateInfo = new ArrayList<>(size); fOngoingStateStartTimes = new ArrayList<>(size); fStateValueTypes = new ArrayList<>(size); for (ITmfStateInterval interval : newStateIntervals) { <START> if (interval != null) { <END> fOngoingStateInfo.add(interval.getStateValue()); fOngoingStateStartTimes.add(interval.getStartTime()); fStateValueTypes.add(interval.getStateValue().getType()); } else { addEmptyEntry(); } } } finally { fReadWriteLock.writeLock().unlock(); } }</code><technical_language>check parameter compile time yet, a replaceOngoingState insert null states. find culprit instead. do a checkNotNull for parameter is fine</technical_language>

Target:
public void replaceOngoingState(List<ITmfStateInterval> newStateIntervals) { final int size = newStateIntervals.size(); fRWLock.writeLock().lock(); try { fOngoingStateInfo = new ArrayList<>(size); fOngoingStateStartTimes = new ArrayList<>(size); fStateValueTypes = new ArrayList<>(size); for (ITmfStateInterval interval : newStateIntervals) { if (interval != null) { fOngoingStateInfo.add(interval.getStateValue()); fOngoingStateStartTimes.add(interval.getStartTime()); fStateValueTypes.add(interval.getStateValue().getType()); } else { addEmptyEntry(); } } } finally { fRWLock.writeLock().unlock(); } }
Source:
<code>public Page getOutput() { checkState(mergeSortProcessor != null, "mergeSources must be non-null when getting output"); if (closed) { return null; } while (!pageBuilder.isFull()) { PageWithPosition pageWithPosition = mergeSortProcessor.poll(); if (pageWithPosition == null) { break; <START> } <END> Page page = pageWithPosition.getPage(); int position = pageWithPosition.getPosition(); pageBuilder.declarePosition(); for (int i = 0; i < outputChannels.size(); i++) { Type type = outputTypes.get(i); Block block = page.getBlock(outputChannels.get(i)); type.appendTo(block, position, pageBuilder.getBlockBuilder(i)); } pageWithPosition.incrementPosition(); } if (pageBuilder.isEmpty()) { return null; } if (pageBuilder.isFull() || mergeSortProcessor.isFinished()) { Page page = pageBuilder.build(); operatorContext.recordGeneratedInput(page.getSizeInBytes(), page.getPositionCount()); pageBuilder.reset(); return page; } return null; }</code><technical_language>mergeSortProcessor page source? return null</technical_language>

Target:
public Page getOutput() { checkState(mergeSortProcessor != null, "mergeSources must be non-null when getting output"); if (closed) { return null; } while (!pageBuilder.isFull()) { PageWithPosition pageWithPosition = mergeSortProcessor.poll(); if (pageWithPosition == null) { break; } pageWithPosition.appendTo(pageBuilder, outputChannels, outputTypes); pageBuilderLocalMemoryContext.setBytes(pageBuilder.getRetainedSizeInBytes()); } if (pageBuilder.isEmpty()) { return null; } if (pageBuilder.isFull() || mergeSortProcessor.isFinished()) { Page page = pageBuilder.build(); operatorContext.recordGeneratedInput(page.getSizeInBytes(), page.getPositionCount()); pageBuilder.reset(); return page; } return null; }
Source:
<code>public void testGetFolderContentWithInvalidIdentifier() { final String NOT_EXISTING_ID = "01234567-1234-1234-1234-123456789012"; try { browserAPI.getFolderContent( APILocator.systemUser(), NOT_EXISTING_ID, 0, -1, "", null, null, true, false, false, false, "", false, false, 1 ); } catch ( Exception e ){ <START> Assert.assertTrue( e instanceof NotFoundInDbException ); <END> } }</code><technical_language>done this: @Test(expected = NotFoundInDbException.class)</technical_language>

Target:
public void testGetFolderContentWithInvalidIdentifier() throws DotDataException, DotSecurityException { final String NOT_EXISTING_ID = "01234567-1234-1234-1234-123456789012"; browserAPI.getFolderContent( APILocator.systemUser(), NOT_EXISTING_ID, 0, -1, "", null, null, true, false, false, false, "", false, false, 1 ); }
Source:
<code>protected ConstraintViolationSetAssert(Set<? extends ConstraintViolation<?>> actualViolations) { <START> super( new ArrayList(actualViolations) ); <END> this.actualViolations = actualViolations; }</code><technical_language>checked if IterableAssert sufficient a base class? avoid this conversion</technical_language>

Target:
protected ConstraintViolationSetAssert(Set<? extends ConstraintViolation<?>> actualViolations) { super( actualViolations ); this.actualViolations = actualViolations; }
Source:
<code>public Resource getResource(URI uri, boolean loadOnDemand) { checkNotDisposed(); final Resource cached = getURIResourceMap().get(uri); if (cached != null) { return cached; } final Resource resource; final IStorage storage = storageToURI.get(uri); if (loadOnDemand && storage != null) { resource = load(storage, uri, new NullProgressMonitor()); } else if (allowResourceLoad) { <START> resource = super.getResource(uri, true); <END> } else { ILoadOnDemandPolicy.Registry registry = EMFCompareRCPPlugin.getDefault() .getLoadOnDemandPolicyRegistry(); if (registry.hasAnyAuthorizingPolicy(uri)) { resource = super.getResource(uri, true); } else { resource = super.getResource(uri, false); } } return resource; }</code><technical_language>"true" pass of "loadOnDemand" (which false)</technical_language>

Target:
public Resource getResource(URI uri, boolean loadOnDemand) { checkNotDisposed(); final Resource cached = getURIResourceMap().get(uri); if (cached != null) { return cached; } final Resource resource; final IStorage storage = storageToURI.get(uri); if (loadOnDemand && storage != null) { resource = load(storage, uri, new NullProgressMonitor()); } else if (allowResourceLoad) { resource = super.getResource(uri, loadOnDemand); } else { ILoadOnDemandPolicy.Registry registry = EMFCompareRCPPlugin.getDefault() .getLoadOnDemandPolicyRegistry(); if (registry.hasAnyAuthorizingPolicy(uri)) { resource = super.getResource(uri, true); } else { resource = super.getResource(uri, false); } } return resource; }
Source:
<code>public void removeAllAttributes(PerunSession sess, Facility facility, boolean removeAlsoUserFacilityAttributes) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException { removeAllAttributes(sess, facility); if (removeAlsoUserFacilityAttributes) { List<Attribute> userFacilityAttributes = getUserFacilityAttributesForAnyUser(sess, facility); getAttributesManagerImpl().removeAllUserFacilityAttributesForAnyUser(sess, facility); <START> log.info("{} removed all attributes from any user facility {}.",sess.getLogId(), facility.getId()); <END> getPerunBl().getAuditer().log(sess, "All user-facility attributes removed for for any user.", facility); for (Attribute attribute : userFacilityAttributes) attribute.setValue(null); List<User> facilityUsers = perunBl.getFacilitiesManagerBl().getAllowedUsers(sess, facility); for (User user : facilityUsers) { try { checkAttributesValue(sess, facility, user, userFacilityAttributes); this.checkAttributesDependencies(sess, facility, user, userFacilityAttributes); } catch (WrongAttributeAssignmentException ex) { throw new ConsistencyErrorException(ex); } for (Attribute attribute : userFacilityAttributes) { try { getAttributesManagerImpl().changedAttributeHook(sess, facility, user, new Attribute(attribute)); } catch (WrongAttributeValueException | WrongReferenceAttributeValueException ex) { throw new InternalErrorException(ex); } } } } }</code><technical_language>user facility -> user facility {}</technical_language>

Target:
public void removeAllAttributes(PerunSession sess, Facility facility, boolean removeAlsoUserFacilityAttributes) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException { removeAllAttributes(sess, facility); if (removeAlsoUserFacilityAttributes) { List<Attribute> userFacilityAttributes = getUserFacilityAttributesForAnyUser(sess, facility); getAttributesManagerImpl().removeAllUserFacilityAttributesForAnyUser(sess, facility); log.info("{} removed all attributes from any user on facility {}.",sess.getLogId(), facility.getId()); getPerunBl().getAuditer().log(sess, "All user-facility attributes removed for for any user.", facility); for (Attribute attribute : userFacilityAttributes) attribute.setValue(null); List<User> facilityUsers = perunBl.getFacilitiesManagerBl().getAllowedUsers(sess, facility); for (User user : facilityUsers) { try { checkAttributesValue(sess, facility, user, userFacilityAttributes); this.checkAttributesDependencies(sess, facility, user, userFacilityAttributes); } catch (WrongAttributeAssignmentException ex) { throw new ConsistencyErrorException(ex); } for (Attribute attribute : userFacilityAttributes) { try { getAttributesManagerImpl().changedAttributeHook(sess, facility, user, new Attribute(attribute)); } catch (WrongAttributeValueException | WrongReferenceAttributeValueException ex) { throw new InternalErrorException(ex); } } } } }
Source:
<code>public void readFullPage() throws Exception { int fileSize = PAGE_SIZE; <START> byte[] testData = generateData(fileSize); <END> ByteArrayCacheManager manager = new ByteArrayCacheManager(); LocalCacheFileInStream stream = setupWithSingleFile(testData, manager); byte[] cacheMiss = new byte[fileSize]; Assert.assertEquals(fileSize, stream.read(cacheMiss)); Assert.assertArrayEquals(testData, cacheMiss); Assert.assertEquals(0, manager.mPagesServed); Assert.assertEquals(1, manager.mPagesCached); stream.seek(0); byte[] cacheHit = new byte[fileSize]; Assert.assertEquals(fileSize, stream.read(cacheHit)); Assert.assertArrayEquals(testData, cacheHit); Assert.assertEquals(1, manager.mPagesServed); }</code><technical_language>nit: ByteUtils.getIncreasingByteArray</technical_language>

Target:
public void readFullPage() throws Exception { int fileSize = PAGE_SIZE; byte[] testData = BufferUtils.getIncreasingByteArray(fileSize); ByteArrayCacheManager manager = new ByteArrayCacheManager(); LocalCacheFileInStream stream = setupWithSingleFile(testData, manager); byte[] cacheMiss = new byte[fileSize]; Assert.assertEquals(fileSize, stream.read(cacheMiss)); Assert.assertArrayEquals(testData, cacheMiss); Assert.assertEquals(0, manager.mPagesServed); Assert.assertEquals(1, manager.mPagesCached); stream.seek(0); byte[] cacheHit = new byte[fileSize]; Assert.assertEquals(fileSize, stream.read(cacheHit)); Assert.assertArrayEquals(testData, cacheHit); Assert.assertEquals(1, manager.mPagesServed); }
Source:
<code>private void convertRegistryIdsToRegistries() { if (StringUtils.isEmpty(registryIds) && (registries == null || registries.isEmpty())) { Set<String> configedRegistries = new HashSet<>(); configedRegistries.addAll(getSubProperties(Environment.getInstance().getExternalConfigurationMap(), Constants.REGISTRIES_SUFFIX)); configedRegistries.addAll(getSubProperties(Environment.getInstance().getAppExternalConfigurationMap(), Constants.REGISTRIES_SUFFIX)); registryIds = String.join(",", configedRegistries); } if (StringUtils.isEmpty(registryIds)) { if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); registries.add(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); } } else { String[] arr = Constants.COMMA_SPLIT_PATTERN.split(registryIds); if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); } Arrays.stream(arr).forEach(id -> { if (registries.stream().noneMatch(reg -> reg.getId().equals(id))) { <START> RegistryConfig registryConfig = new RegistryConfig(RegistryConfig.NO_AVAILABLE); <END> registryConfig.setId(id); registries.add(registryConfig); } }); if (registries.size() > arr.length) { throw new IllegalStateException("Too much registries found, the registries assigned to this service " + "are :" + registryIds + ", but got " + registries.size() + " registries!"); } } }</code><technical_language>I give RegistryConfig a default RegistryConfig.NO_AVAILABLE, instead leave empty. try refresh this RegistryConfig later, if user fails set right item for RegistryConfig, receive Exception checking isValid. if give this default value, pass isValid register URL Registry Center unexpected behaviour</technical_language>

Target:
private void convertRegistryIdsToRegistries() { if (StringUtils.isEmpty(registryIds) && (registries == null || registries.isEmpty())) { Set<String> configedRegistries = new HashSet<>(); configedRegistries.addAll(getSubProperties(Environment.getInstance().getExternalConfigurationMap(), Constants.REGISTRIES_SUFFIX)); configedRegistries.addAll(getSubProperties(Environment.getInstance().getAppExternalConfigurationMap(), Constants.REGISTRIES_SUFFIX)); registryIds = String.join(",", configedRegistries); } if (StringUtils.isEmpty(registryIds)) { if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); registries.add(new RegistryConfig()); } } else { String[] arr = Constants.COMMA_SPLIT_PATTERN.split(registryIds); if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); } Arrays.stream(arr).forEach(id -> { if (registries.stream().noneMatch(reg -> reg.getId().equals(id))) { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setId(id); registries.add(registryConfig); } }); if (registries.size() > arr.length) { throw new IllegalStateException("Too much registries found, the registries assigned to this service " + "are :" + registryIds + ", but got " + registries.size() + " registries!"); } } }
Source:
<code><START> public void testAlleleFractionPlotting() throws IOException { <END> final File SNP_COUNTS_FILE = new File("src/test/resources/org/broadinstitute/hellbender/utils/plotter/snps.tsv"); final File SEGMENTS_FILE = new File("src/test/resources/org/broadinstitute/hellbender/utils/plotter/allelic.seg"); String sampleName = "HCC1143"; File tDir = IOUtils.tempDir("Test", "Plotting"); System.out.println(tDir); AlleleFractionSegmentedPlotter.writeSegmentedAlleleFractionPlot(sampleName, SNP_COUNTS_FILE.getAbsolutePath(), SEGMENTS_FILE.getAbsolutePath(), tDir.getAbsolutePath()+"/", false); Assert.assertTrue(new File(tDir + "/" + sampleName + "_FullGenome.png").exists()); Assert.assertTrue(new File(tDir + "/" + sampleName + "_FullGenome.png").length() > 0); }</code><technical_language>I do tests throw IOExceptions. I argue catch IOException in test use: java try { //.....snip.... } catch (final IOException ioe) { Assert.fail("Could run test due problems a file", ioe); }</technical_language>

Target:
public void testAlleleFractionPlotting() throws IOException { final File SNP_COUNTS_FILE = new File("src/test/resources/org/broadinstitute/hellbender/utils/plotter/snps.tsv"); final File SEGMENTS_FILE = new File("src/test/resources/org/broadinstitute/hellbender/utils/plotter/allelic.seg"); String sampleName = "HCC1143"; File tDir = IOUtils.tempDir("Test", "Plotting"); AlleleFractionSegmentedPlotter.writeSegmentedAlleleFractionPlot(sampleName, SNP_COUNTS_FILE.getAbsolutePath(), SEGMENTS_FILE.getAbsolutePath(), tDir.getAbsolutePath()+"/", false); Assert.assertTrue(new File(tDir + "/" + sampleName + "_FullGenome.png").exists()); Assert.assertTrue(new File(tDir + "/" + sampleName + "_FullGenome.png").length() > 0); }
Source:
<code><START> private void marshallDiagramWithNewMarshaller() { <END> try { new_diagram = unmarshall(newMarshaller, getBpmnTaskFilePath()); new_roundTripDiagram = unmarshall(newMarshaller, getStream(newMarshaller.marshall(new_diagram))); } catch (Exception e) { e.printStackTrace(); } }</code><technical_language>throw exception instead of catch? is stop test unmarshall thows exception, wdyt</technical_language>

Target:
private void marshallDiagramWithNewMarshaller() throws Exception { setNewDiagram(unmarshall(newMarshaller, getBpmnTaskFilePath())); setNewRoundTripDiagram(unmarshall(newMarshaller, getStream(newMarshaller.marshall(getNewDiagram())))); }
Source:
<code>private ServiceInfo getAssertionConsumerServiceInfoByUrl(AuthnRequest request) { String assertionConsumerServiceURL = request.getAssertionConsumerServiceURL(); List<ServiceInfo> infos = assertionConsumerServices .values() .stream() .filter(service -> assertionConsumerServiceURL.equals(service.getUrl())) .collect(Collectors.toList()); ServiceInfo si = null; if (!infos.isEmpty()) { si = infos .stream() <START> .filter(service -> service.getBinding().getUri().equals(SamlProtocol.POST_BINDING)) <END> .findFirst() .orElse(null); } if (si != null) { return si; } else { return new ServiceInfo( assertionConsumerServiceURL, Binding.from(request.getProtocolBinding()), null); } }</code><technical_language>If consistent logic line 126 127, filter POST artifact bindings supportedBindings</technical_language>

Target:
private ServiceInfo getAssertionConsumerServiceInfoByUrl(AuthnRequest request) { return getACS(s -> request.getAssertionConsumerServiceURL().equals(s.getUrl())); }
Source:
<code>protected void executeCommand() { StoragePoolIsoMap map = getStoragePoolIsoMap(); <START> changeStorageDomainStatusInTransaction(map,StorageDomainStatus.Locked); <END> boolean hasConnectStorageSucceeded = connectToStorage(); VDSReturnValue returnValueUpdatedStorageDomain = null; if(!hasConnectStorageSucceeded) { setSucceeded(false); VdcFault f = new VdcFault(); f.setError(VdcBllErrors.StorageServerConnectionError); getReturnValue().setFault(f); changeStorageDomainStatusInTransaction(map,StorageDomainStatus.Maintenance); return; } returnValueUpdatedStorageDomain = updateStatsForDomain(); if (returnValueUpdatedStorageDomain.getSucceeded()) { final StorageDomain updatedStorageDomain = (StorageDomain) returnValueUpdatedStorageDomain.getReturnValue(); TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { getStorageConnDao().update(getParameters().getStorageServerConnection()); getStorageDomainDynamicDao().update(updatedStorageDomain.getStorageDynamicData()); return null; } }); setSucceeded(true); } changeStorageDomainStatusInTransaction(map,StorageDomainStatus.Maintenance); }</code><technical_language>space comma</technical_language>

Target:
protected void executeCommand() { StoragePoolIsoMap map = getStoragePoolIsoMap(); changeStorageDomainStatusInTransaction(map, StorageDomainStatus.Locked); boolean hasConnectStorageSucceeded = connectToStorage(); VDSReturnValue returnValueUpdatedStorageDomain = null; if(!hasConnectStorageSucceeded) { setSucceeded(false); VdcFault f = new VdcFault(); f.setError(VdcBllErrors.StorageServerConnectionError); getReturnValue().setFault(f); return; } returnValueUpdatedStorageDomain = updateStatsForDomain(); if (returnValueUpdatedStorageDomain.getSucceeded()) { final StorageDomain updatedStorageDomain = (StorageDomain) returnValueUpdatedStorageDomain.getReturnValue(); executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { getStorageConnDao().update(getParameters().getStorageServerConnection()); getStorageDomainDynamicDao().update(updatedStorageDomain.getStorageDynamicData()); return null; } }); setSucceeded(true); } updateStatus(map, StorageDomainStatus.Maintenance); }
Source:
<code>private void deleteNotifications(List<String> ids) { if (ids.isEmpty()) { return; } List<Filter> idsToDelete = new ArrayList<>(); <START> ids.forEach(id -> idsToDelete.add(filterBuilder.attribute("id").is().equalTo().text(id))); <END> try { persistentStore.delete( PersistenceType.NOTIFICATION_TYPE.toString(), ECQL.toCQL(filterBuilder.anyOf(idsToDelete))); } catch (PersistenceException e) { LOGGER.info( "PersistenceException while trying to delete persisted notifications with ids ", ids, e); } }</code><technical_language>List<Filter> idsToDelete = ids .stream() .map(filterBuilder.attribute("id").is().equalTo().text(id)) .collect(Collectors.toList());</technical_language>

Target:
private void deleteNotifications(List<String> ids) { if (ids.isEmpty()) { LOGGER.debug("Received empty list of notification ids to delete"); return; } List<Filter> idsToDelete = ids.stream() .map(id -> filterBuilder.attribute("id").is().equalTo().text(id)) .collect(Collectors.toList()); try { persistentStore.delete( PersistenceType.NOTIFICATION_TYPE.toString(), ECQL.toCQL(filterBuilder.anyOf(idsToDelete))); } catch (PersistenceException e) { LOGGER.debug( "PersistenceException while trying to delete persisted notifications with ids ", ids, e); } }