auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static LatokenOrderSide parse(String s) { try { return LatokenOrderSide.valueOf(s); } catch (Exception e) { <START> throw new RuntimeException("Unknown LatokenOrderSide " + s + "."); <END> } }</code><technical_language>ExchangeException</technical_language>

Target:
public static LatokenOrderSide parse(String s) { try { return LatokenOrderSide.valueOf(s); } catch (Exception e) { throw new ExchangeException("Unknown LatokenOrderSide " + s + "."); } }
Source:
<code>public static GraphicalEditPart lookForTargetEditPart(GraphicalEditPart targetEditPart, View view){ <START> List children <END> = targetEditPart.getChildren(); PreferencesHint prefs = ((IDiagramPreferenceSupport) targetEditPart.getRoot()).getPreferencesHint(); CreateViewRequest request = new CreateViewRequest(view.getElement(), prefs); for (Object object : children) { if (object instanceof GraphicalEditPart) { GraphicalEditPart graphicalEditPart = (GraphicalEditPart) object; Command command = graphicalEditPart.getCommand(request); if (command != null) { return graphicalEditPart; } } } return null; }</code><technical_language>please add <?> avoid warning</technical_language>

Target:
public static GraphicalEditPart lookForTargetEditPart(GraphicalEditPart targetEditPart, View view){ List<?> children = targetEditPart.getChildren(); PreferencesHint prefs = ((IDiagramPreferenceSupport) targetEditPart.getRoot()).getPreferencesHint(); CreateViewRequest request = new CreateViewRequest(view.getElement(), prefs); for (Object object : children) { if (object instanceof GraphicalEditPart) { GraphicalEditPart graphicalEditPart = (GraphicalEditPart) object; Command command = graphicalEditPart.getCommand(request); if (command != null) { return graphicalEditPart; } } } return null; }
Source:
<code>public void resourceChanged(IResourceChangeEvent event) { IResource resource = event.getResource(); if (event.getType() == IResourceChangeEvent.PRE_DELETE && resource != null && resource.getType() == IResource.PROJECT) { IProject aboutToBeDeleted = (IProject) resource; IContainer parent = getParent(aboutToBeDeleted); if (parent != null) { parentsToRefresh.add(parent); } } else if (event.getType() == IResourceChangeEvent.POST_CHANGE) { IResourceDelta delta = event.getDelta(); if (delta != null) { resource = delta.getResource(); if (delta.getKind() == IResourceDelta.CHANGED && resource != null && resource.getType() == IResource.ROOT) { for (IResourceDelta childDelta : event.getDelta().getAffectedChildren()) { IResource childResource = childDelta.getResource(); if (childResource != null && childResource.getType() == IResource.PROJECT && childDelta.getKind() == IResourceDelta.ADDED) { IProject newProject = (IProject) childResource; IContainer parent = getParent(newProject); if (parent != null) { parentsToRefresh.add(parent); } } } } } if (!parentsToRefresh.isEmpty()) { <START> this.viewer.getTree().getDisplay().asyncExec(new <END> Runnable() { @Override public void run() { for (IContainer parent : parentsToRefresh) { NestedProjectsContentProvider.this.viewer.refresh(parent); } parentsToRefresh.clear(); } }); } } }</code><technical_language>This fail if tree is disposed view is closed already. Better: PlatformUI.getWorkbench().getDisplay() is there</technical_language>

Target:
public void resourceChanged(IResourceChangeEvent event) { final Set<IContainer> parentsToRefresh = new LinkedHashSet<>(); IResource resource = event.getResource(); if (event.getType() == IResourceChangeEvent.PRE_DELETE && resource != null && resource.getType() == IResource.PROJECT) { IProject aboutToBeDeleted = (IProject) resource; IContainer parent = getParent(aboutToBeDeleted); if (parent != null) { parentsToRefresh.add(parent); } } else if (event.getType() == IResourceChangeEvent.POST_CHANGE) { IResourceDelta delta = event.getDelta(); if (delta != null) { resource = delta.getResource(); if (delta.getKind() == IResourceDelta.CHANGED && resource != null && resource.getType() == IResource.ROOT) { for (IResourceDelta childDelta : event.getDelta().getAffectedChildren()) { IResource childResource = childDelta.getResource(); if (childResource != null && childResource.getType() == IResource.PROJECT && childDelta.getKind() == IResourceDelta.ADDED) { IProject newProject = (IProject) childResource; IContainer parent = getParent(newProject); if (parent != null) { parentsToRefresh.add(parent); } } } } } if (!parentsToRefresh.isEmpty()) { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { if (viewer.getTree() == null || viewer.getTree().isDisposed()) { return; } for (IContainer parent : parentsToRefresh) { NestedProjectsContentProvider.this.viewer.refresh(parent); } } }); } } }
Source:
<code>public Object instantiate(Target<?> target, Parameters parameters) { try { Parameter parameter = parameters.namedAfter(target); if(!List.class.equals(target.getClassType())) { return converterForTarget(target).convert(parameter.getValue(), target.getClassType()); } <START> return multiInstantiator.instantiate(target, parameters); <END> } catch (ConversionException ex) { errors.add(ex.getValidationMessage().withCategory(target.getName())); } catch (IllegalStateException e) { return setPropertiesAfterConversions(target, parameters); } return null; }</code><technical_language>invert this. java if (List.class.isAssignableFrom(target.getClassType())) { return multiInstantiator.instantiate(target, parameters); } return conver...</technical_language>

Target:
public Object instantiate(Target<?> target, Parameters parameters) { try { Parameter parameter = parameters.namedAfter(target); if(isSupportedCollection(target)) { return multiInstantiator.instantiate(target, parameters); } return converterForTarget(target).convert(parameter.getValue(), target.getClassType()); } catch (ConversionException ex) { errors.add(ex.getValidationMessage().withCategory(target.getName())); } catch (IllegalStateException e) { return setPropertiesAfterConversions(target, parameters); } return null; }
Source:
<code>protected void check() throws IOException, ServletException { String exe = fixEmpty(request.getParameter("value")); if(exe==null) { ok(); return; } if(exe.indexOf(File.separatorChar)>=0) { File f = new File(exe); if(f.exists()) { checkExecutable(f); return; } File fexe = new File(exe+".exe"); if(fexe.exists()) { checkExecutable(fexe); return; } error("There's no such file: "+exe); } else { String path = EnvVars.masterEnvVars.get("PATH"); String tokenizedPath; String delimiter = null; if(path!=null) { StringBuilder tokenizedPathBuilder = new StringBuilder(); for (String _dir : Util.tokenize(path.replace("\\", "\\\\"),File.pathSeparator)) { Exception e = hudson.util.DOSToUnixPathHelper.validate(delimiter, tokenizedPathBuilder, _dir, exe, exe1 -> { <START> try { <END> checkExecutable(exe1); return null; } catch (IOException ioe) { return ioe; } catch (ServletException se) { return se; } }); if (e != null) { if (e instanceof IOException) throw (IOException)e; if (e instanceof ServletException) throw (ServletException)e; } } tokenizedPathBuilder.append('.'); tokenizedPath = tokenizedPathBuilder.toString(); } else { tokenizedPath = "unavailable."; } error("There's no such executable "+exe+" in PATH: "+tokenizedPath); } }</code><technical_language>change this assignments delimiter is ignored, tokenized path is joined delimiters. maintain functionality, for loop needs extracted instead of body</technical_language>

Target:
protected void check() throws IOException, ServletException { String exe = fixEmpty(request.getParameter("value")); FormFieldValidator.Executable self = this; Exception exceptions[] = {null}; DOSToUnixPathHelper.iteratePath(exe, new DOSToUnixPathHelper.Helper() { @Override public void ok() { try { self.ok(); } catch (Exception e) { exceptions[0] = e; } } @Override public void checkExecutable(File fexe) { try { self.checkExecutable(fexe); } catch (Exception e) { exceptions[0] = e; } } @Override public void error(String string) { try { self.error(string); } catch (Exception e) { exceptions[0] = e; } } @Override public void validate(File fexe) { try { self.checkExecutable(fexe); } catch (IOException ioe) { exceptions[0] = ioe; } catch (ServletException se) { exceptions[0] = se; } } }); Exception e = exceptions[0]; if (e != null) { if (e instanceof IOException) throw (IOException)e; if (e instanceof ServletException) throw (ServletException)e; } }
Source:
<code>public boolean nextRecord(Record record) throws IOException { if (it.hasNext()) { record.clear(); Object b = it.next(); if (b.getClass().isArray()) { for (Object s : (Object[])b){ record.addField(ValueUtil.toStratosphere(s)); } } else if (b instanceof Collection) { @SuppressWarnings("unchecked") Iterator<Object> tmp_it = ((Collection<Object>) b).iterator(); while (tmp_it.hasNext()) <START> { <END> Object s = tmp_it.next(); record.addField(ValueUtil.toStratosphere(s)); } } else { record.setField(0, ValueUtil.toStratosphere(b)); } return true; } else { return false; } }</code><technical_language>Please style for loops (opening parentheses in line) while (..) { ... }</technical_language>

Target:
public boolean nextRecord(Record record) throws IOException { if (it.hasNext()) { record.clear(); Object b = it.next(); if (b.getClass().isArray()) { for (Object s : (Object[])b){ record.addField(ValueUtil.toStratosphere(s)); } } else if (b instanceof Collection) { @SuppressWarnings("unchecked") Iterator<Object> tmpIter = ((Collection<Object>) b).iterator(); while (tmpIter.hasNext()) { Object s = tmpIter.next(); record.addField(ValueUtil.toStratosphere(s)); } } else { record.setField(0, ValueUtil.toStratosphere(b)); } return true; } else { return false; } }
Source:
<code>private ApiResultWrapper createACourseSISId(String courseId) { M_log.debug("createACourseSISId() call"); String courseSISId = Utils.generateSisCourseId(); String url = Utils.urlConstructor("/courses/", courseId, "/?course[sis_course_id]=" + courseSISId); ApiResultWrapper arw = Utils.makeApiCall(new HttpPut(url)); String msg = String.format("couldn't create course_sis_id for course %s, with status code %s, due to: %s", courseId, arw.getStatus(), (arw.getApiResp().isEmpty()) ? arw.getMessage() : arw.getApiResp()); <START> if(!Utils.didApiReturnedWithOutErrors(msg, arw)){ <END> return arw; } return arw; }</code><technical_language>return arw check returned in case</technical_language>

Target:
private ApiResultWrapper createACourseSISId(String courseId) { M_log.debug("createACourseSISId() call"); String courseSISId = Utils.generateSisCourseId(); String url = Utils.urlConstructor(Utils.URL_CHUNK_COURSES, courseId, Utils.URL_CHUNK_COURSE_SIS_COURSE_ID, courseSISId); ApiResultWrapper arw = Utils.makeApiCall(new HttpPut(url)); String msg = String.format("couldn't create course_sis_id for course %s, with status code %s, due to: %s", courseId, arw.getStatus(), (arw.getApiResp().isEmpty()) ? arw.getMessage() : arw.getApiResp()); if(!Utils.didApiReturnedWithOutErrors(msg, arw)){ return arw; } return arw; }
Source:
<code>public BackupPushStateStatusCommand() { <START> super(0); <END> }</code><technical_language>parameter needs 1 backup model node is level cache</technical_language>

Target:
public BackupPushStateStatusCommand() { super(1); }
Source:
<code>public void givenUsingJava8_whenGeneratingRandomAlphanumericString_thenCorrect() { final int leftLimit = 48; final int rightLimit = 122; final int targetStringLength = 10; final Random random = new Random(); final String generatedString = random.ints(targetStringLength, leftLimit, rightLimit + 1) <START> .filter(i -> (i < 57 || i > 65) && (i < 90 || i > 97)) <END> .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); LOG.debug(generatedString); }</code><technical_language>more filter excludes some wrong values, extract a separate method do some boundary tests it. values filtered out: 9:;<=>?@AZ[\]^_a Of 9, A, Z a values filter out</technical_language>

Target:
public void givenUsingJava8_whenGeneratingRandomAlphanumericString_thenCorrect() { int leftLimit = 48; int rightLimit = 122; int targetStringLength = 10; Random random = new Random(); String generatedString = random.ints(leftLimit, rightLimit + 1) .filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97)) .limit(targetStringLength) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); LOG.debug(generatedString); }
Source:
<code>public void prepare(Map stormConf, TopologyContext context, final OutputCollector collector) { <START> int processQSize = ((Number)stormConf.get(Config.TOPOLOGY_SHELLBOLT_MAX_PENDING)).intValue(); <END> _collector = collector; _context = context; _rand = new Random(); if (stormConf.containsKey(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)) { workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.TOPOLOGY_SUBPROCESS_TIMEOUT_SECS)); } else { workerTimeoutMills = 1000 * RT.intCast(stormConf.get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS)); } ShellContext shellContext = getShellContext(context); Map<String, Object> processConfigMap = new HashMap<>(); processConfigMap.put(MultiLangProcessorRuntime.PROCESS_CONFIG, stormConf); processConfigMap.put(MultiLangProcessorRuntime.SHELL_CONTEXT, shellContext); processConfigMap.put(MultiLangProcessorRuntime.INPUT_SCHEMA, inputSchema); processConfigMap.put(MultiLangProcessorRuntime.OUTPUT_SCHEMA, outputSchema); processConfigMap.put(MultiLangProcessorRuntime.PROCESSOR_Q_SIZE, processQSize); processConfigMap.put(MultiLangProcessorRuntime.WORKER_TIMEOUT_MILLS, workerTimeoutMills); processorRuntime = new MultiLangProcessorRuntime(); processorRuntime.setCallback(this.new ProcessorCallback()); processorRuntime.initialize(processConfigMap); }</code><technical_language>asking for this stream line UI user storm config? thought, do need a queue size here? synchronous? Meaning StreamLineEvent response received for in thread calling execute</technical_language>

Target:
public void prepare(Map stormConf, TopologyContext context, final OutputCollector collector) { this.collector = collector; this.context = context; rand = new Random(); ShellContext shellContext = getShellContext(context); Map<String, Object> processConfigMap = new HashMap<>(); processConfigMap.put(MultiLangProcessorRuntime.COMMAND, command.split(" ")); processConfigMap.put(MultiLangProcessorRuntime.PROCESS_CONFIG, stormConf); processConfigMap.put(MultiLangProcessorRuntime.SHELL_CONTEXT, shellContext); processConfigMap.put(MultiLangProcessorRuntime.OUTPUT_STREAMS, outputStreams); processConfigMap.put(MultiLangProcessorRuntime.PROCESS_TIMEOUT_MILLS, processTimeoutInMs); processConfigMap.put(MultiLangProcessorRuntime.SHELL_ENVIRONMENT, envMap); processorRuntime = new MultiLangProcessorRuntime(); processorRuntime.initialize(processConfigMap); }
Source:
<code><START> public IDiff getDeltaFor(SyncInfo info) { <END> if (info.getComparator().isThreeWay()) { ITwoWayDiff local = getLocalDelta(info); ITwoWayDiff remote = getRemoteDelta(info); return new ThreeWayDiff(local, remote); } else { if (info.getKind() != SyncInfo.IN_SYNC) { IResourceVariant remote = info.getRemote(); IResource local = info.getLocal(); int kind; if (remote == null) kind = IDiff.REMOVE; else if (!local.exists()) kind = IDiff.ADD; else kind = IDiff.CHANGE; if (local.getType() == IResource.FILE) { IFileRevision after = asFileState(remote); IFileRevision before = getLocalFileRevision((IFile) local); return new ResourceDiff(info.getLocal(), kind, 0, before, after); } return new ResourceDiff(info.getLocal(), kind); } return null; } }</code><technical_language>Nesting is deep IMHO</technical_language>

Target:
public IDiff getDeltaFor(SyncInfo info) { if (info.getComparator().isThreeWay()) { ITwoWayDiff local = getLocalDelta(info); ITwoWayDiff remote = getRemoteDelta(info); return new ThreeWayDiff(local, remote); } else { if (info.getKind() != SyncInfo.IN_SYNC) { IResourceVariant remote = info.getRemote(); IResource local = info.getLocal(); return computeResourceDiff(info, remote, local); } return null; } }
Source:
<code>public boolean equals(Object o) { if (o instanceof MeasurementKey) { MeasurementKey other = (MeasurementKey) o; <START> return d_som.equals(other.d_som) <END> && EqualsUtil.equal(d_arm, other.d_arm) && EqualsUtil.equal(d_wt, other.d_wt); } return false; }</code><technical_language>is .equals() defined for StudyOutcomeMeasure? Remember (reference the) included variable is mutable, if som.equals() compares variable, som.equals() here. is OK d_som == other.d_som in case interested in material identity</technical_language>

Target:
public boolean equals(Object o) { MeasurementKey other = matching(o); return other != null && d_som == other.d_som; }
Source:
<code>protected void updateOptionRanksMapping( Map<String, List<Integer>> optionRanks, String optionReceivingRanks, int rankReceived) { optionRanks.putIfAbsent(optionReceivingRanks, new ArrayList<Integer>()); <START> List<Integer> ranksReceived = optionRanks.get(optionReceivingRanks); <END> ranksReceived.add(rankReceived); }</code><technical_language>@wenmogu a I get time; meanwhile, if fix this test case (i.e. change expected match actual), else break</technical_language>

Target:
protected void updateOptionRanksMapping( Map<String, List<Integer>> optionRanks, String optionReceivingRanks, int rankReceived) { optionRanks.computeIfAbsent(optionReceivingRanks, key -> new ArrayList<>()) .add(rankReceived); }
Source:
<code>public static FS detect(Boolean cygwinUsed) { if (factory == null) { try { Class<?> activatorClass = Class .forName("org.eclipse.jgit.util.Java7FSFactory"); <START> System.out.println("Found Java7"); <END> factory = (FSFactory) activatorClass.newInstance(); } catch (ClassNotFoundException e) { System.out.println("Java7 module not found"); factory = new FS.FSFactory(); } catch (UnsupportedClassVersionError e) { System.out.println("Java7 module not accessible"); factory = new FS.FSFactory(); } catch (Exception e) { factory = new FS.FSFactory(); throw new Error(e); } } return factory.detect(cygwinUsed); }</code><technical_language>System.out exceptional path? log.info remove completely</technical_language>

Target:
public static FS detect(Boolean cygwinUsed) { if (factory == null) { try { Class<?> activatorClass = Class .forName("org.eclipse.jgit.util.Java7FSFactory"); factory = (FSFactory) activatorClass.newInstance(); } catch (ClassNotFoundException e) { factory = new FS.FSFactory(); } catch (UnsupportedClassVersionError e) { factory = new FS.FSFactory(); } catch (Exception e) { factory = new FS.FSFactory(); throw new Error(e); } } return factory.detect(cygwinUsed); }
Source:
<code>protected <T extends Base> boolean areEquals(List<T> list1, List<T> list2) { if (isOnlyOneNull(list1, list2)) { return false; } else if (areBothNull(list1, list2)) { return true; } else if (list1.size() != list2.size()) { return false; } else { <START> return arePropsEquals(list1.get(0), list2.get(0)); <END> } }</code><technical_language>compare element of list</technical_language>

Target:
protected <T extends Base> boolean areEquals(List<T> list1, List<T> list2) { if (isOnlyOneNull(list1, list2)) { return false; } else if (areBothNull(list1, list2)) { return true; } else if (list1.size() != list2.size()) { return false; } else { return areElementsPropsEquals(list1, list2); } }
Source:
<code>public static SchedulerType lookup(String schedulerType) { <START> return valueOfIgnoreCase(schedulerType); <END> }</code><technical_language>This throw a runtime exception if input is in of provided values. safer instead of throwing exceptions in main code path. Throwing exception work in current scenario for other future users of this enum. public static Blah fromString(String text) { for (Blah b : Blah.values()) { if (b.text.equalsIgnoreCase(text)) { return b; } } return null; }</technical_language>

Target:
public static SchedulerType lookup(String schedulerType) throws UnsupportedTypeException { return lookup(schedulerType, false, false); }
Source:
<code>public static CalcState fromJSON(final String json) throws JSONException { <START> <END> CalcState rv = null; if (json != null) { rv = new CalcState(new JSONObject(json)); } return rv; }</code><technical_language>Superfluous empty line</technical_language>

Target:
public static CalcState fromJSON(final String json) throws JSONException { if (json == null) { return null; } return new CalcState(new JSONObject(json)); }
Source:
<code><START> synchronized public void doDisconnect() { <END> if (getInputStream() != null) { try { getInputStream().close(); } catch (Exception exception) { Activator.log(exception); } } if (getTerminalToRemoteStream() != null) { try { getTerminalToRemoteStream().close(); } catch (Exception exception) { Activator.log(exception); } } }</code><technical_language>public synchronized</technical_language>

Target:
public synchronized void doDisconnect() { if (getInputStream() != null) { try { getInputStream().close(); } catch (Exception exception) { Activator.log(exception); } } if (getTerminalToRemoteStream() != null) { try { getTerminalToRemoteStream().close(); } catch (Exception exception) { Activator.log(exception); } } }
Source:
<code>private void addLinks(RunImageConfiguration runConfig, List<String> ret) { <START> if (!runConfig.getNetworkingConfig().isCustomNetwork()) { <END> for (String[] link : EnvUtil.splitOnLastColon(runConfig.getLinks())) { ret.add(link[0]); } } }</code><technical_language>leave this check in ? I needed EnvUtil.splitOnLastColon() return a list easier understand conditions for links add</technical_language>

Target:
private void addLinks(RunImageConfiguration runConfig, List<String> ret) { if (runConfig.getLinks() != null && !runConfig.getNetworkingConfig().isCustomNetwork()) { for (String[] link : EnvUtil.splitOnLastColon(runConfig.getLinks())) { ret.add(link[0]); } } }
Source:
<code>public static Dimension getImageBounds(final String path) { ImageDescriptor descriptor = imageDescriptor(path); if (descriptor != null) { ImageData imgData = <START> descriptor.getImageData(100); <END> if (imgData != null) { return new Dimension(imgData.width, imgData.height); } } return null; }</code><technical_language>Watch out, I tend recal ImageDescritpr.getImageData() costly re-creating memorry structure call, want test check dimension avoid re-creating image data n times</technical_language>

Target:
public static Dimension getImageBounds(final String path) { ImageDescriptor descriptor = imageDescriptor(path); if (descriptor != null) { ImageData imgData = DiagramUIPlugin.getPlugin().getImageDataFor(descriptor); if (imgData == null) { imgData = descriptor.getImageData(100); DiagramUIPlugin.getPlugin().cacheImageData(descriptor, imgData); } if (imgData != null) { return new Dimension(imgData.width, imgData.height); } } return null; }
Source:
<code>public static void writeOpenTag(final Response response, String id) { HeaderItemAttributeMap attributes = new HeaderItemAttributeMap(); attributes.add(HeaderItemAttribute.TYPE, "text/javascript"); <START> if (id != null) { <END> attributes.add(HeaderItemAttribute.ID, id); } writeOpenTag(response, attributes); }</code><technical_language>code style</technical_language>

Target:
public static void writeOpenTag(final Response response, String id) { AttributeMap attributes = new AttributeMap(); attributes.put(ATTR_TYPE, "text/javascript"); if (id != null) { attributes.put(ATTR_ID, id); } writeInlineScriptOpenTag(response, attributes); }
Source:
<code>public boolean matchesPathInfo(String pathInfo) { <START> LOGGER.entering(); <END> DefaultManagedArtifact request = new DefaultManagedArtifact(REPO_ABSOLUTE_PATH + pathInfo); boolean matches = this.equals(request); LOGGER.exiting(matches); return matches; }</code><technical_language>LOGGER.entering(pathInfo) useful</technical_language>

Target:
public boolean matchesPathInfo(String pathInfo) { LOGGER.entering(pathInfo); DefaultManagedArtifact request = new DefaultManagedArtifact(REPO_ABSOLUTE_PATH + pathInfo); boolean matches = this.equals(request); LOGGER.exiting(matches); return matches; }
Source:
<code>private void onDownloaderResponse(Object message, ActorRef self, ActorRef sender) { final DownloaderResponse response = (DownloaderResponse) message; if (logger.isInfoEnabled()) { logger.info("Call api response succeeded " + response.succeeded()); logger.info("Call api response: " + response); } <START> requestee.tell(message, self); <END> }</code><technical_language>@maria-farooq current implementation requestee null. protect code for this</technical_language>

Target:
private void onDownloaderResponse(Object message, ActorRef self, ActorRef sender) { final DownloaderResponse response = (DownloaderResponse) message; if (logger.isInfoEnabled()) { logger.info("Call api response succeeded " + response.succeeded()); logger.info("Call api response: " + response); } requestee = requestee == null ? sender : requestee; CallApiResponse apiResponse; if (response.succeeded()) { apiResponse = new CallApiResponse(response.get()); } else { apiResponse = new CallApiResponse(response.cause(), response.error()); } requestee.tell(apiResponse, self); }
Source:
<code>public List<Number> getData() { <START> return fData; <END> }</code><technical_language>expose internal list directly, callers free modify it. case for this method anyway, is needed? do ImmutableList.copyOf() Collections.unmodifiableList() if need (the is more lightweight, data change caller's feet, problems)</technical_language>

Target:
public List<Number> getData() { return ImmutableList.copyOf(fData); }
Source:
<code>private void loadInitialState(ITmfStateProvider provider) { final ITmfTrace trace = getTrace(); if (trace == null) { throw new IllegalStateException("Trace is null. It should be impossible to load states. "); } File path = new File(trace.getPath()); path = path.isDirectory() ? path : path.getParentFile(); if (path == null) { <START> throw new IllegalStateException("Trace does not seem to have a directory backing it : " + trace); END> } for (ITmfStateSystem ss : getStateSystems()) { if (ss instanceof ITmfStateSystemBuilder) { ITmfStateSystemBuilder ssb = (ITmfStateSystemBuilder) ss; StateSnapshot snapshot = StateSnapshot.read(path.toPath(), ss.getSSID()); if (snapshot == null || provider.getVersion() != snapshot.getVersion()) { continue; } for (Entry<List<String>, ITmfStateInterval> attributeSnapshot : snapshot.getStates().entrySet()) { List<String> attributePath = Objects.requireNonNull(attributeSnapshot.getKey()); int quark = ssb.getQuarkAbsoluteAndAdd(attributePath.toArray(new String[attributePath.size()])); ITmfStateInterval interval = Objects.requireNonNull(attributeSnapshot.getValue()); Object initialState = interval.getValue(); ssb.modifyAttribute(Math.max(interval.getStartTime(), ssb.getStartTime()), initialState, quark); } } } }</code><technical_language>Unit tests fail a trace a bogus path</technical_language>

Target:
private void loadInitialState(ITmfStateProvider provider) { final ITmfTrace trace = getTrace(); if (trace == null) { throw new IllegalStateException("Trace is null. It should be impossible to load states. "); } File path = new File(trace.getPath()); path = path.isDirectory() ? path : path.getParentFile(); if (path == null) { return; } for (ITmfStateSystem ss : getStateSystems()) { if (ss instanceof ITmfStateSystemBuilder) { ITmfStateSystemBuilder ssb = (ITmfStateSystemBuilder) ss; StateSnapshot snapshot = StateSnapshot.read(path.toPath(), ss.getSSID()); if (snapshot == null || provider.getVersion() != snapshot.getVersion()) { continue; } for (Entry<List<String>, ITmfStateInterval> attributeSnapshot : snapshot.getStates().entrySet()) { List<String> attributePath = Objects.requireNonNull(attributeSnapshot.getKey()); int quark = ssb.getQuarkAbsoluteAndAdd(attributePath.toArray(new String[attributePath.size()])); ITmfStateInterval interval = Objects.requireNonNull(attributeSnapshot.getValue()); Object initialState = interval.getValue(); ssb.modifyAttribute(Math.max(interval.getStartTime(), ssb.getStartTime()), initialState, quark); } } } }
Source:
<code>public void shouldSaveOrderSet() throws Exception { executeDataSet(ORDER_SET); OrderSet orderSet = orderSetBuilder(false, false); OrderSet orderSetObj = orderSetService.save(orderSet); <START> assertNotNull("OrderSet has a order_set_id", orderSetObj.getId().intValue()); <END> }</code><technical_language>Do need call intValue() returns a primitive checking for null</technical_language>

Target:
public void shouldSaveOrderSet() throws Exception { executeDataSet(ORDER_SET); Integer initialNumberOfOrderSets = orderSetService.getOrderSets(false).size(); OrderSet orderSet = orderSetBuilder(false, false); OrderSet orderSetObj = orderSetService.saveOrderSet(orderSet); Context.flushSession(); List<OrderSet> orderSets = orderSetService.getOrderSets(false); assertEquals("A new order set was saved to the exisiting list of order sets", initialNumberOfOrderSets + 1, orderSets.size()); assertNotNull("OrderSet has a order_set_id", orderSetObj.getId()); }
Source:
<code>public void addListener(EthereumListener listener) { logger.info("Ethereum listener added"); <START> ((BackwardCompatibilityEthereumListenerProxy) listener).getCompositeListener().addListener(listener); <END> }</code><technical_language>If user listener in common (ethereum.addListener(new EthereumListenerAdapter(){})) get strange exception here, I guess</technical_language>

Target:
public void addListener(EthereumListener listener) { logger.info("Ethereum listener added"); ((BackwardCompatibilityEthereumListenerProxy) this.listener).getCompositeListener().addListener(listener); }
Source:
<code>public static OkHttpClient defaultClient() { return new OkHttpClient.Builder() .connectionPool(connectionPool) <START> .dns(new SingleInetAddressDns()) END> .build(); }</code><technical_language>explain a bit more this</technical_language>

Target:
public static OkHttpClient defaultClient() { return new OkHttpClient.Builder() .connectionPool(connectionPool) .build(); }
Source:
<code>public void destroy() { LOGGER.debug("Cluster " + getClusterId() + " - destroy"); if (clusterId != null) { Marathon marathon = getMarathonContainer(); if (marathon != null) { marathon.killAllApps(); } List<Container> containers = dockerClient.listContainersCmd().exec(); for (Container container : containers) { if (ContainerName.belongsToCluster(container.getNames(), clusterId)) { dockerClient.removeContainerCmd(container.getId()).withForce().withRemoveVolumes(true).exec(); } } LOGGER.info("Destroyed minimesos cluster " + clusterId); <START> if (MAP_AGENT_SANDBOX == true) { <END> File sandboxLocation = new File(getHostDir(), ".minimesos/sandbox-" + clusterId); try { FileUtils.forceDelete(sandboxLocation); } catch (IOException e) { String msg = String.format("Failed to force delete the cluster sandbox at %s", sandboxLocation.getAbsolutePath()); LOGGER.error(msg, e); throw new MinimesosException(msg, e); } } } else { LOGGER.info("Minimesos cluster is not running"); } }</code><technical_language>if (MAP_AGENT_SANDBOX) enough ;)</technical_language>

Target:
public void destroy() { LOGGER.debug("Cluster " + getClusterId() + " - destroy"); if (clusterId != null) { Marathon marathon = getMarathonContainer(); if (marathon != null) { marathon.killAllApps(); } List<Container> containers = dockerClient.listContainersCmd().exec(); for (Container container : containers) { if (ContainerName.belongsToCluster(container.getNames(), clusterId)) { dockerClient.removeContainerCmd(container.getId()).withForce().withRemoveVolumes(true).exec(); } } File sandboxLocation = new File(getHostDir(), ".minimesos/sandbox-" + clusterId); if (sandboxLocation.exists()) { try { FileUtils.forceDelete(sandboxLocation); } catch (IOException e) { String msg = String.format("Failed to force delete the cluster sandbox at %s", sandboxLocation.getAbsolutePath()); LOGGER.error(msg, e); throw new MinimesosException(msg, e); } } } else { LOGGER.info("Minimesos cluster is not running"); } }
Source:
<code>public PartitionQueue(int partCount) { queue = new ArrayBlockingQueue<>(partCount * 100); moveEventMap = new ConcurrentHashMap<>(partCount); nextEventIndexMap = new HashMap<>(partCount); for (int i = 0; i < partCount; i++) { nextEventIndexMap.put(i, new AtomicLong(0)); <START> } <END> openPartCount = partCount; processedEventIndexMap = new HashMap<>(partCount); for (int i = 0; i < partCount; i++) { processedEventIndexMap.put(i, -1L); } }</code><technical_language>This is a suggestion, enforce immutability of nextEventIndexMap Collections.unmodifiableMap() if want rely ConcurrentHashMap</technical_language>

Target:
public PartitionQueue(int partCount) { queue = new ArrayBlockingQueue<>(partCount * 100); moveEventMap = new ConcurrentHashMap<>(partCount); Map<Integer, AtomicLong> nextEventIndexMap = new HashMap<>(partCount); for (int i = 0; i < partCount; i++) { nextEventIndexMap.put(i, new AtomicLong(0)); } this.nextEventIndexMap = Collections.unmodifiableMap(nextEventIndexMap); openPartCount = partCount; processedEventIndexMap = new HashMap<>(partCount); for (int i = 0; i < partCount; i++) { processedEventIndexMap.put(i, -1L); } }
Source:
<code>public PlanNode visitLateralJoin(LateralJoinNode node, RewriteContext<Set<Symbol>> context) { PlanNode subquery = context.rewrite(node.getSubquery(), context.get()); <START> if (intersection(ImmutableSet.copyOf(subquery.getOutputSymbols()), context.get()).isEmpty() && ScalarQueryUtil.isScalar(subquery)) { <END> return context.rewrite(node.getInput(), context.get()); } Set<Symbol> subquerySymbols = SymbolsExtractor.extractUnique(subquery); List<Symbol> newCorrelation = node.getCorrelation().stream() .filter(subquerySymbols::contains) .collect(toImmutableList()); Set<Symbol> inputContext = ImmutableSet.<Symbol>builder() .addAll(context.get()) .addAll(newCorrelation) .build(); PlanNode input = context.rewrite(node.getInput(), inputContext); return new LateralJoinNode(node.getId(), input, subquery, newCorrelation, node.getType()); }</code><technical_language>static import</technical_language>

Target:
public PlanNode visitLateralJoin(LateralJoinNode node, RewriteContext<Set<Symbol>> context) { PlanNode subquery = context.rewrite(node.getSubquery(), context.get()); if (intersection(ImmutableSet.copyOf(subquery.getOutputSymbols()), context.get()).isEmpty() && isScalar(subquery)) { return context.rewrite(node.getInput(), context.get()); } Set<Symbol> subquerySymbols = SymbolsExtractor.extractUnique(subquery); List<Symbol> newCorrelation = node.getCorrelation().stream() .filter(subquerySymbols::contains) .collect(toImmutableList()); Set<Symbol> inputContext = ImmutableSet.<Symbol>builder() .addAll(context.get()) .addAll(newCorrelation) .build(); PlanNode input = context.rewrite(node.getInput(), inputContext); return new LateralJoinNode(node.getId(), input, subquery, newCorrelation, node.getType()); }
Source:
<code>public void testPutNestedBinaryObject() throws Exception { IgniteBinary binary = grid(0).binary(); BinaryObjectBuilder nested = binary.builder("Nested"); nested.setField("str1", "stringValue"); nested.setField("sqlDate", java.sql.Date.valueOf("2019-01-01")); jcache().put(-1, nested.build()); BinaryObjectBuilder parent = binary.builder("Parent"); parent.setField("nested", nested.build()); parent.setField("id", Long.MAX_VALUE); parent.setField("byteVal", (byte)1); parent.setField("timestamp", new Timestamp(new java.util.Date().getTime())); BinaryObject obj = parent.build(); jcache().put(2, obj); JsonNode jsonNode = JSON_MAPPER.valueToTree(obj); <START> ((ObjectNode)jsonNode).put("id", Long.MIN_VALUE); <END> String jsonText = JSON_MAPPER.writeValueAsString(jsonNode); info("Put: " + jsonText); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT, "keyType", "int", "key", "3", "valueType", "Parent", "val", jsonText ); info("Put command result: " + ret); assertResponseSucceeded(ret, false); ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET, "keyType", "int", "key", "3"); info("Get command result: " + ret); JsonNode res = assertResponseSucceeded(ret, false); assertEquals(jsonNode, res); }</code><technical_language>Dangerous casting for external library, build a new BinaryObject instead. need change "id" field existing builder call build() method again</technical_language>

Target:
public void testPutNestedBinaryObject() throws Exception { IgniteBinary binary = grid(0).binary(); BinaryObjectBuilder nested = binary.builder("Nested"); nested.setField("str1", "stringValue"); nested.setField("sqlDate", java.sql.Date.valueOf("2019-01-01")); jcache().put(-1, nested.build()); BinaryObjectBuilder parent = binary.builder("Parent"); parent.setField("nested", nested.build()); parent.setField("id", Long.MAX_VALUE); parent.setField("byteVal", (byte)1); parent.setField("timestamp", new Timestamp(new java.util.Date().getTime())); jcache().put(2, parent.build()); parent.setField("id", Long.MIN_VALUE); String jsonText = JSON_MAPPER.writeValueAsString(parent.build()); info("Put: " + jsonText); String ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_PUT, "keyType", "int", "key", "3", "valueType", "Parent", "val", jsonText ); info("Put command result: " + ret); assertResponseSucceeded(ret, false); ret = content(DEFAULT_CACHE_NAME, GridRestCommand.CACHE_GET, "keyType", "int", "key", "3"); info("Get command result: " + ret); JsonNode res = assertResponseSucceeded(ret, false); assertEquals(jsonText, JSON_MAPPER.writeValueAsString(res)); }
Source:
<code>public void testReloadCache() throws Exception { connector = new BugzillaRestConnectorLocal(new Duration(5, TimeUnit.SECONDS)); assertNotNull(connector); configuration = connector.getRepositoryConfiguration(actualFixture.repository()); assertNotNull(configuration); Thread.sleep(6000L); BugzillaRestConfiguration configuration_new = connector.getRepositoryConfiguration(actualFixture.repository()); assertEquals(configuration, configuration_new); <START> mySync = this; <END> synchronized (mySync) { try { mySync.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } mySync = null; BugzillaRestConfiguration configuration_new1 = connector.getRepositoryConfiguration(actualFixture.repository()); assertThat(configuration, not(configuration_new1)); }</code><technical_language>This good. extract a waitForCacheRemoval method call instead of other sleeps</technical_language>

Target:
public void testReloadCache() throws Exception { connector = new BugzillaRestConnectorLocal(new Duration(5, TimeUnit.SECONDS)); assertNotNull(connector); configuration = connector.getRepositoryConfiguration(actualFixture.repository()); assertNotNull(configuration); Thread.sleep(6000L); BugzillaRestConfiguration configuration_new = connector.getRepositoryConfiguration(actualFixture.repository()); assertEquals(configuration, configuration_new); waitForCacheRemoval(); BugzillaRestConfiguration configuration_new1 = connector.getRepositoryConfiguration(actualFixture.repository()); assertThat(configuration, not(configuration_new1)); }
Source:
<code>public static void main(String[] args) { try { LoggingFactory.init(Level.INFO); Platform.setVirtual(false); boolean isDone = true; Runtime.start("gui", "SwingGui"); Arduino mega = (Arduino) Runtime.start("mega", "Arduino"); mega.setBoardMega(); mega.connect("COM7"); <START> HobbyServo servo = (HobbyServo) Runtime.start("servo", "HobbyServo"); <END> servo.attach(mega, 8); servo.moveTo(3); servo.moveTo(130); servo.moveTo(0); servo.invoke("moveTo", 3); if (isDone) { return; } } catch (Exception e) { log.error("main threw", e); } }</code><technical_language>MAJOR compatability issues if support a handy alias for "HobbyServo" "Servo" .</technical_language>

Target:
public static void main(String[] args) { try { LoggingFactory.init(Level.INFO); Platform.setVirtual(true); Runtime.start("gui", "SwingGui"); Arduino mega = (Arduino) Runtime.start("mega", "Arduino"); if (mega.isVirtual()) { VirtualArduino vmega = mega.getVirtual(); vmega.setBoardMega(); } mega.connect("COM7"); HobbyServo servo = (HobbyServo) Runtime.start("servo", "HobbyServo"); log.info("rest is {}", servo.getRest()); servo.save(); servo.attach(mega, 13); servo.moveTo(90.0); boolean isDone = true; if (isDone) { return; } } catch (Exception e) { log.error("main threw", e); } }
Source:
<code>public GithubSecurityRealm(String githubWebUri, String githubApiUri, String clientID, String clientSecret, String oauthScopes, String emailDomains, Boolean forceGithubEmail) { <START> super(); <END> this.githubWebUri = Util.fixEmptyAndTrim(githubWebUri); this.githubApiUri = Util.fixEmptyAndTrim(githubApiUri); this.clientID = Util.fixEmptyAndTrim(clientID); setClientSecret(Util.fixEmptyAndTrim(clientSecret)); this.oauthScopes = Util.fixEmptyAndTrim(oauthScopes); this.emailDomains = Util.fixEmptyAndTrim(emailDomains); this.forceGithubEmail = forceGithubEmail; }</code><technical_language>This cleanly migrate configuration. Please overload this method another deprecated method configurations cleanly migrate</technical_language>

Target:
public GithubSecurityRealm(String githubWebUri, String githubApiUri, String clientID, String clientSecret, String oauthScopes, String emailDomains, Boolean forceGithubEmail) { super(); this.githubWebUri = Util.fixEmptyAndTrim(githubWebUri); this.githubApiUri = Util.fixEmptyAndTrim(githubApiUri); this.clientID = Util.fixEmptyAndTrim(clientID); setClientSecret(Util.fixEmptyAndTrim(clientSecret)); this.oauthScopes = Util.fixEmptyAndTrim(oauthScopes); this.emailDomains = emailDomains.trim(); this.forceGithubEmail = forceGithubEmail; }
Source:
<code>public ToStringHelper string() { ToStringHelper toString = super.string(); if (groupNames.size() != 0) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && userData.size() > 0) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (mappings.size() != 0) toString.add("blockDeviceMappings", mappings); <START> if (maxCount != null) <END> toString.add("maxCount", maxCount); if (clientToken != null) toString.add("clientToken", clientToken); return toString; }</code><technical_language>Do need a > 0 check here..</technical_language>

Target:
public ToStringHelper string() { ToStringHelper toString = super.string(); if (groupNames.size() != 0) toString.add("groupNames", groupNames); if (noKeyPair) toString.add("noKeyPair", noKeyPair); toString.add("keyPair", keyPair); if (userData != null && userData.size() > 0) toString.add("userDataCksum", Hashing.crc32().hashBytes(Bytes.toArray(userData))); ImmutableSet<BlockDeviceMapping> mappings = blockDeviceMappings.build(); if (mappings.size() != 0) toString.add("blockDeviceMappings", mappings); if (maxCount != null && maxCount.intValue() > 0) toString.add("maxCount", maxCount); if (clientToken != null) toString.add("clientToken", clientToken); return toString; }
Source:
<code>public void setUp() { parser = new CargoResultParser(); StringBuilder builder = new StringBuilder(); builder.append(" Compiling example version (path)\n"); builder.append(" Running target\\debug\\mod-hash.exe\n"); builder.append("\n"); builder.append("running 1 test\n"); builder.append("test name ... FAILED\n"); builder.append("\n"); builder.append("failures:\n"); builder.append("\n"); builder.append("---- name stdout ----\n"); builder.append("\tthread 'name' panicked at 'description', tests\\mod.rs:line\n"); builder.append("\n"); builder.append("\n"); builder.append("failures:\n"); builder.append(" name\n"); builder.append("\n"); builder.append("test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured"); <START> fail = builder.toString(); <END> }</code><technical_language>This a constant? I build string w/o StringBuilder, is done (and jvm optimizes it)</technical_language>

Target:
public void setUp() { parser = new CargoResultParser(); failResult = new ProcessResult(0, fail, ""); }
Source:
<code>private void verifyCommonValues() { verify(propertyWriterFactory).of(activityCaptor.capture()); assertEquals(UUID, activityCaptor.getValue().getId()); verify(propertyWriter).setName(NAME); verify(propertyWriter).setDocumentation(DOCUMENTATION); verify(propertyWriter).setOnEntryAction(ON_ENTRY_ACTION); verify(propertyWriter).setOnExitAction(ON_EXIT_ACTION); verify(propertyWriter).setCalledElement(CALLED_ELEMENT); verify(propertyWriter).setAsync(IS_ASYNC); verify(propertyWriter).setIndependent(INDEPENDENT); verify(propertyWriter).setWaitForCompletion(WAIT_FOR_COMPLETION); verify(propertyWriter).setAssignmentsInfo(ASSIGNMENTS_INFO); verify(propertyWriter).setSimulationSet(SIMULATION_SET); <START> verify(propertyWriter).setBounds(BOUNDS); <END> }</code><technical_language>setBounds(Bounds rect) protected access in BasePropertyWriter jenkins fail (it is compile this PR). check code, I need Full downstream build test this PR properly</technical_language>

Target:
private void verifyCommonValues() { verify(propertyWriterFactory).of(activityCaptor.capture()); assertEquals(UUID, activityCaptor.getValue().getId()); verify(propertyWriter).setName(NAME); verify(propertyWriter).setDocumentation(DOCUMENTATION); verify(propertyWriter).setOnEntryAction(ON_ENTRY_ACTION); verify(propertyWriter).setOnExitAction(ON_EXIT_ACTION); verify(propertyWriter).setCalledElement(CALLED_ELEMENT); verify(propertyWriter).setAsync(IS_ASYNC); verify(propertyWriter).setIndependent(INDEPENDENT); verify(propertyWriter).setWaitForCompletion(WAIT_FOR_COMPLETION); verify(propertyWriter).setAssignmentsInfo(ASSIGNMENTS_INFO); verify(propertyWriter).setSimulationSet(SIMULATION_SET); verify(propertyWriter).setAbsoluteBounds(node); }
Source:
<code>public Collection<AlarmFeedback> getFeedback(String situationKey) throws FeedbackException { <START> Gson gson = new Gson(); <END> String query = "{\n" + " \"query\": { \"match\": { \"situation_key\": " + gson.toJson(situationKey) + " } }\n" + "}"; return search(query); }</code><technical_language>gson instance is thread-safe, declare a member variable instead of recreating everytime here</technical_language>

Target:
public Collection<AlarmFeedback> getFeedback(String situationKey) throws FeedbackException { String query = "{\n" + " \"query\": { \"match\": { \"situation_key\": " + gson.toJson(situationKey) + " } }\n" + "}"; return search(query); }
Source:
<code>public void addCustomHeader(String name, String value) { if (customHeaders == null) { customHeaders = new ArrayList<Param>(2); } <START> if (name.toLowerCase().equals(CONTENT_TYPE.toLowerCase())) { <END> setCustomContentType(value); } else if (name.toLowerCase().equals(CONTENT_TRANSFER_ENCODING.toLowerCase())) { transferEncoding = value; } else if (name.toLowerCase().equals(CONTENT_ID.toLowerCase())) { contentId = value; } else if (name.toLowerCase().equals(CONTENT_DISPOSITION.toLowerCase())) { setCustomContentDisposition(value); } else { customHeaders.add(new Param(name, value)); } }</code><technical_language>equalsIgnoreCase instead of allocating 2 additional Strings</technical_language>

Target:
public void addCustomHeader(String name, String value) { if (customHeaders == null) { customHeaders = new ArrayList<Param>(2); } for (String header : SPECIAL_HEADERS) { if (name.equalsIgnoreCase(header)) { throw new IllegalArgumentException("Trying to add special header " + header + " as custom (use constructor instead)"); } } customHeaders.add(new Param(name, value)); }