auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void nonBinaryWithSourceImages() throws Exception { FolderObject folderObject = repoObjectFactory.createFolderObject(null); final Map<String, Object> headers = createEvent(true, folderObject.getPid(), Cdr.Collection.getURI(), Container.getURI()); template.sendBodyAndHeaders("", headers); NotifyBuilder notify1 = new NotifyBuilder(cdrEnhancements) .whenCompleted(1) .create(); NotifyBuilder notify2 = new NotifyBuilder(cdrServiceSolr) .whenCompleted(1) .create(); boolean result1 = notify1.matches(5l, TimeUnit.SECONDS); assertTrue("Enhancement route not satisfied", result1); boolean result2 = notify2.matches(5l, TimeUnit.SECONDS); assertTrue("Indexing route not satisfied", result2); verify(solrIngestProcessor).process(any(Exchange.class)); }

Target:
public void nonBinaryWithSourceImages() throws Exception { CollectionObject collObject = repoObjectFactory.createCollectionObject(null); String uuid = collObject.getPid().getUUID(); String basePath = idToPath(uuid, HASHED_PATH_DEPTH, HASHED_PATH_SIZE); File uploadedFile = new File(String.valueOf(Paths.get(tempDir.getAbsolutePath(), basePath, uuid))); FileInputStream input = new FileInputStream("src/test/resources/uploaded-files/burndown.png"); FileUtils.copyInputStreamToFile(input, uploadedFile); final Map<String, Object> headers = createEvent(collObject.getPid(), Cdr.Collection.getURI(), Container.getURI()); template.sendBodyAndHeaders("", headers); NotifyBuilder notify1 = new NotifyBuilder(cdrEnhancements) .whenCompleted(1) .create(); NotifyBuilder notify2 = new NotifyBuilder(cdrServiceSolr) .whenCompleted(1) .create(); boolean result1 = notify1.matches(5l, TimeUnit.SECONDS); assertTrue("Enhancement route not satisfied", result1); boolean result2 = notify2.matches(5l, TimeUnit.SECONDS); assertTrue("Indexing route not satisfied", result2); verify(addSmallThumbnailProcessor).process(any(Exchange.class)); verify(addLargeThumbnailProcessor).process(any(Exchange.class)); verify(addAccessCopyProcessor, never()).process(any(Exchange.class)); verify(solrIngestProcessor).process(any(Exchange.class)); }
Source:
protected static String getAgentString(String agentName, String agentVersion, String agentDesc, String agentURL, String agentEmail) { StringBuffer buf = new StringBuffer(); buf.append(agentName); if (agentVersion != null) { buf.append("/"); buf.append(agentVersion); } if (((agentDesc != null) && (agentDesc.length() != 0)) || ((agentEmail != null) && (agentEmail.length() != 0)) || ((agentURL != null) && (agentURL.length() != 0))) { buf.append(" ("); if ((agentDesc != null) && (agentDesc.length() != 0)) { buf.append(agentDesc); if ((agentURL != null) || (agentEmail != null)) buf.append("; "); } if ((agentURL != null) && (agentURL.length() != 0)) { buf.append(agentURL); if (agentEmail != null) buf.append("; "); } if ((agentEmail != null) && (agentEmail.length() != 0)) buf.append(agentEmail); buf.append(")"); } return buf.toString(); }

Target:
protected static String getAgentString(String agentName, String agentVersion, String agentDesc, String agentURL, String agentEmail) { StringBuffer buf = new StringBuffer(); buf.append(agentName); if (StringUtils.isNotBlank(agentVersion)) { buf.append("/"); buf.append(agentVersion); } boolean hasAgentDesc = StringUtils.isNotBlank(agentDesc); boolean hasAgentURL = StringUtils.isNotBlank(agentURL); boolean hasAgentEmail = StringUtils.isNotBlank(agentEmail); if (hasAgentDesc || hasAgentEmail || hasAgentURL) { buf.append(" ("); if (hasAgentDesc) { buf.append(agentDesc); if (hasAgentURL || hasAgentEmail) buf.append("; "); } if (hasAgentURL) { buf.append(agentURL); if (hasAgentEmail) buf.append("; "); } if (hasAgentEmail) { buf.append(agentEmail); } buf.append(")"); } return buf.toString(); }
Source:
public AccountAttributes getCopy() { AccountAttributes copy = AccountAttributes.builder() .withGoogleId(googleId) .withName(name) .withEmail(email) .withInstitute(institute) .withIsInstructor(isInstructor) .withDefaultStudentProfileAttributes(googleId) .build(); copy.studentProfile = this.studentProfile == null ? null : this.studentProfile.getCopy(); return copy; }

Target:
public AccountAttributes getCopy() { return AccountAttributes.builder() .withGoogleId(googleId) .withName(name) .withEmail(email) .withInstitute(institute) .withIsInstructor(isInstructor) .withStudentProfileAttributes(this.studentProfile == null ? null : this.studentProfile.getCopy()) .build(); }
Source:
public Hypervisor build() { properties(properties() != null ? ImmutableList.copyOf(properties()) : null); diskSpeeds(diskSpeeds() != null ? ImmutableList.copyOf(diskSpeeds()) : null); cpuSpeeds(cpuSpeeds() != null ? ImmutableList.copyOf(cpuSpeeds()) : null); return autoBuild(); }

Target:
public Hypervisor build() { properties(properties() != null ? ImmutableList.copyOf(properties()) : ImmutableList.<Property>of()); diskSpeeds(diskSpeeds() != null ? ImmutableList.copyOf(diskSpeeds()) : ImmutableList.<DiskSpeed>of()); cpuSpeeds(cpuSpeeds() != null ? ImmutableList.copyOf(cpuSpeeds()) : ImmutableList.<CpuSpeed>of()); return autoBuild(); }
Source:
private void bindGeocachingUserToGCVoteuser() { final Preference pref = getPreference(R.string.pref_username); if (pref == null) { return; } final String value = PreferenceManager .getDefaultSharedPreferences(pref.getContext()) .getString(pref.getKey(), ""); getPreference(R.string.pref_user_vote).setSummary(value); final Preference prefvote = getPreference(R.string.pref_user_vote); bindSummaryToValue(prefvote, value); }

Target:
private void bindGeocachingUserToGCVoteuser() { if (!Settings.hasGCCredentials()) { return; } final String value = Settings.getGcCredentials().getLeft(); getPreference(R.string.pref_user_vote).setSummary(value); final Preference prefvote = getPreference(R.string.pref_user_vote); bindSummaryToValue(prefvote, value); }
Source:
private boolean allowEnrollInPublication(Node node, String nodeType) throws Exception { String path = node.getPath(); Node parentNode = node.getParent(); while(!path.equals("/") && path.length() > 0) { parentNode = (Node)node.getSession().getItem(path); if(parentNode.isNodeType(nodeType)) return false; path = StringUtils.substringBeforeLast(path, path.substring(path.lastIndexOf("/"), path.length())); } return true; }

Target:
private boolean allowEnrollInPublication(Node node, String nodeType) throws Exception { String path = node.getPath(); Node parentNode = node.getParent(); while(!path.equals("/") && path.length() > 0) { parentNode = (Node)node.getSession().getItem(path); if(parentNode.isNodeType(nodeType)) return false; path = path.substring(0, path.lastIndexOf("/")); } return true; }
Source:
protected final boolean checkAssignmentBound(TType rhs) { if (fBounds.length == 0) return true; for (TType fBound : fBounds) { if (rhs.canAssignTo(fBound)) { return true; } } return false; }

Target:
protected final boolean checkAssignmentBound(TType rhs) { if (fBounds.length == 0) return true; for (TType bound : fBounds) { if (rhs.canAssignTo(bound)) { return true; } } return false; }
Source:
protected static List<URL> getClasspath(final Configuration configuration, final PackagedProgram program) { final List<URL> classpath = new ArrayList<>(); classpath.addAll( ConfigUtils.decodeListFromConfig( configuration, PipelineOptions.CLASSPATHS, url -> { try { return new URL(url); } catch (MalformedURLException e) { throw new IllegalArgumentException("Bad syntax for classpath: " + url, e); } })); classpath.addAll(program.getClasspaths()); return Collections.unmodifiableList(classpath.stream().distinct().collect(Collectors.toList())); }

Target:
private static List<URL> getClasspath(final Configuration configuration, final PackagedProgram program) throws MalformedURLException { final List<URL> classpath = ConfigUtils.decodeListFromConfig( configuration, PipelineOptions.CLASSPATHS, URL::new); classpath.addAll(program.getClasspaths()); return Collections.unmodifiableList(classpath.stream().distinct().collect(Collectors.toList())); }
Source:
public void addMessage(@Valid final Message message) { env.addMessage(message); }

Target:
public Response addMessage(@Valid final Message message) { env.addMessage(message); return Response.status(Response.Status.CREATED).build(); }
Source:
public void multiRequest() throws IOException { init(); ViewMultipleRequest<String, Object> multi = db.getViewRequestBuilder("example", "foo") .newMultipleRequest(Key.Type.STRING, Object.class) .keys("key-1").add() .keys("key-2").add() .keys("key-3").add() .build(); int i = 1; List<ViewResponse<String, Object>> responses = multi.getViewResponses(); assertEquals(3, responses.size(), "There should be 3 respones for 3 requests"); for (ViewResponse<String, Object> response : responses) { assertEquals(1, response.getRows().size(), "There should be 1 row in each response"); assertEquals("key-" + i, response.getKeys().get(0), "The returned key should be key-" + i); i++; } }

Target:
public void multiRequest() throws IOException { init(); ViewMultipleRequest<String, Object> multi = db.getViewRequestBuilder("example", "foo") .newMultipleRequest(Key.Type.STRING, Object.class) .keys("key-1").add() .keys("key-2").add() .keys("key-3").add() .build(); int i = 1; List<ViewResponse<String, Object>> responses = multi.getViewResponses(); assertEquals(3, responses.size(), "There should be 3 responses for 3 requests"); for (ViewResponse<String, Object> response : responses) { assertEquals(1, response.getRows().size(), "There should be 1 row in each response"); assertEquals("key-" + i, response.getKeys().get(0), "The returned key should be key-" + i); i++; } }
Source:
private void parseContestZipArchive(FileInformationDTO fileInformationDTO) throws AppException { ZipFile zipFile; try { zipFile = new ZipFile(fileInformationDTO.getFileName()); } catch (IOException e) { throw new AppException("Create zipFile object failed."); } String tempDirectory = settings.SETTING_UPLOAD_FOLDER + "/" + fileInformationDTO.getFileName(); ZipUtil.unzipFile(zipFile, tempDirectory, new ContestZipChecker()); Contest contest = parseContestInfo(tempDirectory); }

Target:
public ContestDTO parseContestZipArchive(FileInformationDTO fileInformationDTO) throws AppException { ZipFile zipFile; try { zipFile = new ZipFile(fileInformationDTO.getFileName()); } catch (IOException e) { throw new AppException("Create zipFile object failed."); } String tempDirectory = settings.SETTING_UPLOAD_FOLDER + "/" + fileInformationDTO.getFileName(); ZipUtil.unzipFile(zipFile, tempDirectory, new ContestZipChecker()); return parseContestInfo(tempDirectory); }
Source:
private String createAndRegisterUniqueAlias(String originalAlias) { String uniqueAlias = originalAlias; if (!aliasMap.containsKey(originalAlias)) { aliasMap.put(originalAlias, 0); uniqueAlias = 0 + uniqueAlias; } else { aliasMap.put(originalAlias, aliasMap.get(originalAlias) + 1); uniqueAlias = aliasMap.get(originalAlias).toString() + originalAlias; } if (aliasList.contains(nameCutter.trimByCamelCase(uniqueAlias, 19))) { logger.warn("ALIAS CRASH AT :" + uniqueAlias + "\t as: " + nameCutter.trimByCamelCase(uniqueAlias, 19)); uniqueAlias = uniqueAlias + "_NAME_CRASH_AS_19_CHAR_VALUE"; } else { uniqueAlias = nameCutter.trimByCamelCase(uniqueAlias, 19); aliasList.add(uniqueAlias); } return uniqueAlias; }

Target:
private String createAndRegisterUniqueAlias(String originalAlias) { String uniqueAlias = originalAlias; if (!aliasMap.containsKey(originalAlias)) { aliasMap.put(originalAlias, 0); uniqueAlias = 0 + uniqueAlias; } else { aliasMap.put(originalAlias, aliasMap.get(originalAlias) + 1); uniqueAlias = aliasMap.get(originalAlias).toString() + originalAlias; } final String uniqueAliasShort = nameCutter.trimByCamelCase(uniqueAlias, 19); if (aliasList.contains(uniqueAliasShort)) { logger.warn("Ambiguous alias name '{}'\t as '{}", uniqueAlias, uniqueAliasShort); uniqueAlias = uniqueAlias + "_NAME_CRASH_AS_19_CHAR_VALUE"; } else { uniqueAlias = uniqueAliasShort; aliasList.add(uniqueAlias); } return uniqueAlias; }
Source:
public String getUserMessage() { StringBuffer sb = new StringBuffer(); String desc = exception.getDescription(); switch(desc) { case "Unclosed character class": sb.append("The regular expression is missing a closing ']' character, or has an empty pair of square brackets '[]'."); break; case "Unmatched closing ')'": sb.append("The regular expression is missing a opening '(' character."); break; case "Unclosed group": sb.append("The regular expression is missing a closing ')' character."); break; case "Dangling meta character '*'": case "Dangling meta character '+'": case "Dangling meta character '?'": sb.append("The regular expression has a '*','+' or '?' in the wrong place."); break; case "Unexpected internal error": sb.append("The regular expression has a backslash '\\' at the end."); break; case "Unclosed counted closure": sb.append("The regular expression is missing a closing '}' character, or has an incorrect quantifier statement in curly brackets '{}'."); break; case "Illegal repetition": sb.append("The regular expression has an incomplete or incorrect quantifier statement in curly brackets '{}'."); break; case "Illegal repetition range": sb.append("The regular expression has a quantifier statement where the minimum is larger than the maximum (e.g. {4,3})."); break; case "Illegal character range": sb.append("The regular expression has a range statement which is incomplete or has the characters in the incorrect order (e.g. [9-0])"); break; default: sb.append(exception.getMessage()); break; } return sb.toString(); }

Target:
public String getUserMessage() { String msg = ""; String desc = exception.getDescription(); switch(desc) { case "Unclosed character class": msg = "The regular expression is missing a closing ']' character, or has an empty pair of square brackets '[]'."; break; case "Unmatched closing ')'": msg = "The regular expression is missing a opening '(' character."; break; case "Unclosed group": msg = "The regular expression is missing a closing ')' character."; break; case "Dangling meta character '*'": case "Dangling meta character '+'": case "Dangling meta character '?'": msg = "The regular expression has a '*','+' or '?' in the wrong place."; break; case "Unexpected internal error": msg = "The regular expression has a backslash '\\' at the end."; break; case "Unclosed counted closure": msg = "The regular expression is missing a closing '}' character, or has an incorrect quantifier statement in curly brackets '{}'."; break; case "Illegal repetition": msg = "The regular expression has an incomplete or incorrect quantifier statement in curly brackets '{}'."; break; case "Illegal repetition range": msg = "The regular expression has a quantifier statement where the minimum is larger than the maximum (e.g. {4,3})."; break; case "Illegal character range": msg = "The regular expression has a range statement which is incomplete or has the characters in the incorrect order (e.g. [9-0])"; break; default: msg = exception.getMessage(); break; } return msg; }
Source:
private double decomposedValueOnDefault(CDSAnalytic indexCDS, double indexCoupon, ISDACompliantYieldCurve yieldCurve, IntrinsicIndexDataBundle intrinsicData, int singleName) { double protection = intrinsicData.getLGD(singleName) * intrinsicData.getWeight(singleName); double singleNamePV = _pricer.pv(indexCDS, yieldCurve, intrinsicData.getCreditCurves()[singleName], indexCoupon) * intrinsicData.getWeight(singleName); return protection - singleNamePV; }

Target:
private double decomposedValueOnDefault(CDSAnalytic indexCDS, double indexCoupon, ISDACompliantYieldCurve yieldCurve, IntrinsicIndexDataBundle intrinsicData, int singleName) { double weight = intrinsicData.getWeight(singleName); double protection = intrinsicData.getLGD(singleName); double singleNamePV = _pricer.pv(indexCDS, yieldCurve, intrinsicData.getCreditCurves()[singleName], indexCoupon); return weight * (protection - singleNamePV); }
Source:
protected void getInformationsFromContextManager(IContextManager contextManager) { List<IContext> internalContextList = new ArrayList<IContext>(); IContext newSelectedCopiedContext = null; if (process != null && process.getUpdateManager() != null) { process.getUpdateManager().updateAll(); } if (process != null && process.getLastRunContext() != null) { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (process.getLastRunContext().getName().equals(context.getName())) { newSelectedCopiedContext = copiedContext; } } } else { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (contextManager.getDefaultContext().equals(context)) { newSelectedCopiedContext = copiedContext; } } } Collections.sort(internalContextList, new ContextCompare()); contextComboViewer.setInput(internalContextList); ProcessManager processManager = ProcessManager.getInstance(); if (newSelectedCopiedContext != null) { setContextComboSelection(new StructuredSelection(newSelectedCopiedContext)); processManager.setSelectContext(newSelectedCopiedContext); contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList()); } else { IContext element = internalContextList.get(0); processManager.setSelectContext(element); setContextComboSelection(new StructuredSelection(element)); contextTableViewer.setInput(element.getContextParameterList()); } }

Target:
protected void getInformationsFromContextManager(IContextManager contextManager) { List<IContext> internalContextList = new ArrayList<IContext>(); IContext newSelectedCopiedContext = null; if (process != null && process.getLastRunContext() != null) { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (process.getLastRunContext().getName().equals(context.getName())) { newSelectedCopiedContext = copiedContext; } } } else { for (IContext context : contextManager.getListContext()) { IContext copiedContext = context.clone(); internalContextList.add(copiedContext); if (contextManager.getDefaultContext().equals(context)) { newSelectedCopiedContext = copiedContext; } } } Collections.sort(internalContextList, new ContextCompare()); contextComboViewer.setInput(internalContextList); ProcessManager processManager = ProcessManager.getInstance(); if (newSelectedCopiedContext != null) { setContextComboSelection(new StructuredSelection(newSelectedCopiedContext)); processManager.setSelectContext(newSelectedCopiedContext); contextTableViewer.setInput(newSelectedCopiedContext.getContextParameterList()); } else { IContext element = internalContextList.get(0); processManager.setSelectContext(element); setContextComboSelection(new StructuredSelection(element)); contextTableViewer.setInput(element.getContextParameterList()); } }
Source:
public void contributeToCoolBar(ICoolBarManager coolBarManager) { if (coolBarManager instanceof SubCoolBarManager) { subManager = (SubCoolBarManager) coolBarManager; } else { subManager = new SubCoolBarManager(coolBarManager); } subManager.setVisible(true); ToolBarManager actionToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeActionTools(actionToolBarManager, getActionBars()); if ( actionToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.ACTION_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.ACTION_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(actionToolBarManager, ToolConstants.ACTION_TOOLBAR_ID); subManager.add(toolBarContributionItem); } if( isModalIncluded ){ ToolBarManager modalToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeModalTools(modalToolBarManager, getActionBars()); if ( modalToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.MODAL_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.MODAL_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(modalToolBarManager, ToolConstants.MODAL_TOOLBAR_ID); subManager.add(toolBarContributionItem); } } super.contributeToCoolBar(coolBarManager); }

Target:
public void contributeToCoolBar(ICoolBarManager coolBarManager) { if (coolBarManager instanceof SubCoolBarManager) { subManager = (SubCoolBarManager) coolBarManager; } else { subManager = new SubCoolBarManager(coolBarManager); } subManager.setVisible(true); ToolBarManager actionToolBarManager = new ToolBarManager(SWT.FLAT); ApplicationGIS.getToolManager().contributeActionTools(actionToolBarManager, getActionBars()); if ( actionToolBarManager.getItems().length > 0){ IContributionItem item = subManager.find(ToolConstants.ACTION_TOOLBAR_ID); if(item != null){ subManager.remove(ToolConstants.ACTION_TOOLBAR_ID); } ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem(actionToolBarManager, ToolConstants.ACTION_TOOLBAR_ID); subManager.add(toolBarContributionItem); } super.contributeToCoolBar(coolBarManager); }
Source:
private void deleteCredentialAndRedirect() { if (mCredential == null) { Log.w(TAG, "deleteCredentialAndRedirect: null credential"); startAuthMethodChoice(); return; } AuthUI.getInstance() .delete(getActivity()) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (!task.isSuccessful()) { Log.w(TAG, "deleteCredential:failure", task.getException()); } startAuthMethodChoice(); } }); }

Target:
private void deleteCredentialAndRedirect() { if (mCredential == null) { Log.w(TAG, "deleteCredentialAndRedirect: null credential"); startAuthMethodChoice(); return; } GoogleSignInHelper.getInstance(getActivity()) .delete(mCredential) .addOnCompleteListener(new OnCompleteListener<Status>() { @Override public void onComplete(@NonNull Task<Status> task) { if (!task.isSuccessful()) { Log.w(TAG, "deleteCredential:failure", task.getException()); } startAuthMethodChoice(); } }); }
Source:
public void finishedLoadingLogs() { FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_geotag_layout); if (fragment == null || !(fragment instanceof GeoTagImagesFragment)) { fragment = new GeoTagImagesFragment(); fm.beginTransaction().replace(R.id.fragment_geotag_layout, fragment).commit(); } }

Target:
public void finishedLoadingLogs() { FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(R.id.fragment_geotag_layout); if (!(fragment instanceof GeoTagImagesFragment)) { fragment = new GeoTagImagesFragment(); fm.beginTransaction().replace(R.id.fragment_geotag_layout, fragment).commit(); } }
Source:
private ICompletionProposal[] getProbeVariableCompletions(IDocument document, int offset, String prefix){ String probe = getProbe(document, offset); String[] completionData = stpMetadataSingleton.getProbeVariableCompletions(probe, prefix); ICompletionProposal[] result = new ICompletionProposal[completionData.length]; int prefixLength = prefix.length(); for (int i = 0; i < completionData.length; i++){ int endIndex = completionData[i].indexOf(':'); String variableName = completionData[i].substring(prefixLength, endIndex); result[i] = new CompletionProposal( variableName, offset, 0, endIndex - prefixLength, null, completionData[i] + " - variable", null, TapsetLibrary.getAndCacheDocumentation("probe::" + probe + "::" + variableName)); } return result; }

Target:
private ICompletionProposal[] getProbeVariableCompletions(IDocument document, int offset, String prefix){ String probe = getProbe(document, offset); String[] completionData = stpMetadataSingleton.getProbeVariableCompletions(probe, prefix); ICompletionProposal[] result = new ICompletionProposal[completionData.length]; int prefixLength = prefix.length(); for (int i = 0; i < completionData.length; i++){ int endIndex = completionData[i].indexOf(':'); String variableName = completionData[i].substring(0, endIndex); result[i] = new CompletionProposal( completionData[i].substring(prefixLength, endIndex), offset, 0, endIndex - prefixLength, null, completionData[i] + " - variable", null, TapsetLibrary.getAndCacheDocumentation("probe::" + probe + "::" + variableName)); } return result; }
Source:
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { return null; } Convention toConvention = rel.getConvention(); RelBuilder builder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); RelNode sort = builder.push(rel) .adoptConvention(toConvention) .sort(toCollation) .build(); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }

Target:
public RelNode convert( RelOptPlanner planner, RelNode rel, RelCollation toCollation, boolean allowInfiniteCostConverters) { if (toCollation.getFieldCollations().isEmpty()) { return null; } RelBuilder builder = RelFactories.LOGICAL_BUILDER.create(rel.getCluster(), null); RelNode sort = builder.push(rel) .sort(toCollation) .build(); RelNode newRel = planner.register(sort, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toCollation); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
Source:
public void connectionListenerDestroyed(ConnectionListener cl) { if (cl.getState() == ConnectionState.DESTROYED) { log.tracef("ManagedConnection is already destroyed %s", cl); return; } if (statistics.isEnabled()) statistics.deltaDestroyedCount(); cl.setState(ConnectionState.DESTROYED); ManagedConnection mc = cl.getManagedConnection(); try { mc.destroy(); } catch (Throwable t) { log.debug("Exception destroying ManagedConnection " + cl, t); } mc.removeConnectionEventListener(cl); }

Target:
public void connectionListenerDestroyed(ConnectionListener cl) { if (statistics.isEnabled()) statistics.deltaDestroyedCount(); }
Source:
public static ResourceType addResourceTypeToRegistry(final String resourceType, boolean isNative, final String description, final String defaultPath, final String defaultExtension, final String... otherExtensions) { ResourceType resource = new ResourceType( resourceType, isNative, description, defaultPath, defaultExtension, otherExtensions ); CACHE.put( resourceType, resource ); resource.getAllExtensions().forEach( ext -> CACHE.put( "." + ext, resource ) ); return resource; }

Target:
public static ResourceType addResourceTypeToRegistry(final String resourceType, boolean isNative, final String description, final String defaultPath, final String defaultExtension, final String... otherExtensions) { ResourceType resource = new ResourceType( resourceType, isNative, description, defaultPath, defaultExtension, otherExtensions ); CACHE.put( resourceType, resource ); resource.getAllExtensions().forEach( ext -> { if (ext.contains( "." )) { throw new IllegalArgumentException( "A resource extension cannot contain a dot. Found: " + ext ); } CACHE.put( "." + ext, resource ); } ); return resource; }
Source:
public BackgroundTask<?> getDataLoadingTask() { if (dataLoadingTask == null) { return null; } return dataLoadingTask; }

Target:
public BackgroundTask<?> getDataLoadingTask() { return dataLoadingTask; }
Source:
public static Collection testParameters() { return Arrays.asList( new Object[][]{ { new Long( "1" ), new BigDecimal( "1" ) }, { new Long( "2" ), new BigInteger( "2" ) }, { new Long( "3" ), new Byte( "3" ) }, { null, new Double( "4.0" ) }, { null, new Float( "5.0" ) }, { new Long( "6" ), new Integer( "6" ) }, { new Long( "7" ), new Long( "7" ) }, { new Long( "8" ), new Short( "8" ) }, { new Long( "9" ), "9" }, { null, true }, { null, new Date() }, { null, "bananna" } } ); }

Target:
public static Collection testParameters() { return Arrays.asList( new Object[][]{ { new Long( "1" ), new BigDecimal( "1" ) }, { new Long( "2" ), new BigInteger( "2" ) }, { new Long( "3" ), new Byte( "3" ) }, { null, new Double( "4.0" ) }, { null, new Float( "5.0" ) }, { new Long( "6" ), new Integer( "6" ) }, { new Long( "7" ), new Long( "7" ) }, { new Long( "8" ), new Short( "8" ) }, { new Long( "9" ), "9" }, { null, true }, { null, new Date() }, { null, "banana" } } ); }
Source:
synchronized void endTransaction(Transaction t, boolean hasChanges) { int txId = t.transactionId; t.setStatus(Transaction.STATUS_CLOSED); boolean success = transactions.compareAndSet(txId, t, null); assert success; do { VersionedBitSet original = openTransactions.get(); assert original.get(txId); VersionedBitSet clone = original.cloneIt(); clone.clear(txId); success = openTransactions.compareAndSet(original, clone); } while(!success); if (hasChanges) { boolean wasStored = t.wasStored; if (wasStored && !preparedTransactions.isClosed()) { preparedTransactions.remove(txId); } if (wasStored || store.getAutoCommitDelay() == 0) { store.tryCommit(); } else { if (undoLog.isEmpty()) { int unsaved = store.getUnsavedMemory(); int max = store.getAutoCommitMemory(); if (unsaved * 4 > max * 3) { store.tryCommit(); } } } } }

Target:
synchronized void endTransaction(Transaction t, boolean hasChanges) { int txId = t.transactionId; t.setStatus(Transaction.STATUS_CLOSED); assert transactions.get(txId) == t : transactions.get(txId) + " != " + t; transactions.set(txId, null); boolean success; do { VersionedBitSet original = openTransactions.get(); assert original.get(txId); VersionedBitSet clone = original.clone(); clone.clear(txId); success = openTransactions.compareAndSet(original, clone); } while(!success); if (hasChanges) { boolean wasStored = t.wasStored; if (wasStored && !preparedTransactions.isClosed()) { preparedTransactions.remove(txId); } if (wasStored || store.getAutoCommitDelay() == 0) { store.tryCommit(); } else { if (undoLog.isEmpty()) { int unsaved = store.getUnsavedMemory(); int max = store.getAutoCommitMemory(); if (unsaved * 4 > max * 3) { store.tryCommit(); } } } } }
Source:
public Int2DArrayAssert isDeepEqualTo(int[][] expected) { if (actual == expected) { return myself; } isNotNull(); if (expected.length != actual.length) { throw failures.failure(info, shouldHaveSameSizeAs(actual, expected, actual.length, expected.length)); } for (int i = 0; i < actual.length; i++) { int[] actualSubArray = actual[i]; int[] expectedSubArray = expected[i]; if (actualSubArray == expectedSubArray) { continue; } if (actualSubArray == null) { throw failures.failure(info, shouldNotBeNull("actual[" + i + "]")); } if (expectedSubArray.length != actualSubArray.length) { throw failures.failure(info, shouldHaveSameSizeOfSubarrayAs(actual, expected, actualSubArray, expectedSubArray, actualSubArray.length, expectedSubArray.length, i)); } for (int j = 0; j < actualSubArray.length; j++) { if (actualSubArray[j] != expectedSubArray[j]) { throw failures.failure(info, shouldBeEqual(actualSubArray[j], expectedSubArray[j], info.representation(), "[" + i + "][" + j + "]")); } } } return myself; }

Target:
public Int2DArrayAssert isDeepEqualTo(int[][] expected) { if (actual == expected) return myself; isNotNull(); if (expected.length != actual.length) { throw failures.failure(info, shouldHaveSameSizeAs(actual, expected, actual.length, expected.length)); } for (int i = 0; i < actual.length; i++) { int[] actualSubArray = actual[i]; int[] expectedSubArray = expected[i]; if (actualSubArray == expectedSubArray) continue; if (actualSubArray == null) { throw failures.failure(info, shouldNotBeNull("actual[" + i + "]")); } if (expectedSubArray.length != actualSubArray.length) { throw failures.failure(info, subarraysShouldHaveSameSize(actual, expected, actualSubArray, expectedSubArray, i)); } for (int j = 0; j < actualSubArray.length; j++) { if (actualSubArray[j] != expectedSubArray[j]) { throw failures.failure(info, shouldBeEqual(actualSubArray[j], expectedSubArray[j], info.representation(), "[" + i + "][" + j + "]")); } } } return myself; }
Source:
public void updatePidFromNitro(HttpServletResponse response, @PathVariable("pid") String pid) throws IOException { Iterable<List<Item>> items; try { items = contentAdapter .fetchEpisodes(ProgrammesQuery.builder() .withPid(pid) .withMixins(ANCESTOR_TITLES, CONTRIBUTIONS, IMAGES, GENRE_GROUPINGS) .withPageSize(1) .build()); } catch (NitroException e) { log.error("Failed to get Nitro item {}", pid, e); writeServerErrorWithStack(response, e); return; } if (Iterables.getOnlyElement(items) == null) { log.error("No items found in Nitro for pid {}", pid); response.setStatus(HttpStatusCode.NOT_FOUND.code()); response.setContentLength(0); return; } List<Item> itemsList = Iterables.getOnlyElement(items); Iterator<Item> itemIterator = itemsList.iterator(); createOrUpdateItems(response, pid, itemIterator); }

Target:
public void updatePidFromNitro( HttpServletResponse response, @PathVariable("pid") String pid ) throws IOException { Item item; try { Iterable<List<Item>> items = contentAdapter .fetchEpisodes(ProgrammesQuery.builder() .withPid(pid) .withMixins(ANCESTOR_TITLES, CONTRIBUTIONS, IMAGES, GENRE_GROUPINGS) .withPageSize(1) .build()); item = Iterables.getOnlyElement(items).get(0); } catch (NoSuchElementException e) { log.error("No items found in Nitro for pid {}", pid); response.setStatus(HttpStatusCode.NOT_FOUND.code()); response.setContentLength(0); return; } catch (NitroException e) { log.error("Failed to get Nitro item {}", pid, e); writeServerErrorWithStack(response, e); return; } createOrUpdateItem(response, pid, item); }
Source:
public final void runAction() throws IOException { Project project = windowObjects.getProject(); final Editor projectEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (projectEditor != null) { windowObjects.getFileNameContentsMap().clear(); windowObjects.getFileNameNumbersMap().clear(); final JTree jTree = windowObjects.getjTree(); final DefaultTreeModel model = (DefaultTreeModel) jTree.getModel(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); root.removeAllChildren(); jTree.setVisible(true); windowObjects.getSpotlightPaneTinyEditorsJPanel().removeAll(); if (editorDocOps.isJavaFile(projectEditor.getDocument())) { Pair<Integer, Integer> pair = editorDocOps.getLineOffSets(projectEditor, windowObjects.getDistance()); Set<String> allImports = getAllImportsAfterExcludes(projectEditor, pair); if (!allImports.isEmpty()) { ProgressManager.getInstance().run(new QueryKBServerTask( windowObjects.getProject(), allImports, jTree, model, root)); } else { if (projectEditor.getSelectionModel().hasSelection()) { utilsInstance.showHelpInfo(HELP_MESSAGE_IF_CODE_SELECTED); } else { utilsInstance.showHelpInfo(HELP_MESSAGE_NO_SELECTED_CODE); } } } else { utilsInstance.showHelpInfo(FILETYPE_HELP); } } else { utilsInstance.showHelpInfo(EDITOR_ERROR); } }

Target:
public final void runAction() throws IOException { Project project = windowObjects.getProject(); final Editor projectEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (projectEditor != null) { windowObjects.getFileNameContentsMap().clear(); windowObjects.getFileNameNumbersMap().clear(); final JTree jTree = windowObjects.getjTree(); final DefaultTreeModel model = (DefaultTreeModel) jTree.getModel(); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); root.removeAllChildren(); jTree.setVisible(true); windowObjects.getSpotlightPaneTinyEditorsJPanel().removeAll(); if (editorDocOps.isJavaFile(projectEditor.getDocument())) { Pair<Integer, Integer> pair = editorDocOps.getLineOffSets(projectEditor, windowObjects.getDistance()); Set<String> allImports = getAllImportsAfterExcludes(projectEditor, pair); if (!allImports.isEmpty()) { ProgressManager.getInstance().run(new QueryKBServerTask( windowObjects.getProject(), allImports, jTree, model, root)); } else { if (projectEditor.getSelectionModel().hasSelection()) { uiUtils.showHelpInfo(HELP_MESSAGE_IF_CODE_SELECTED); } else { uiUtils.showHelpInfo(HELP_MESSAGE_NO_SELECTED_CODE); } } } else { uiUtils.showHelpInfo(FILETYPE_HELP); } } else { uiUtils.showHelpInfo(EDITOR_ERROR); } }
Source:
public void writeToTopology(final InternalTopologyBuilder topologyBuilder) { final String processorName = processorParameters.processorName(); topologyBuilder.addProcessor(processorName, processorParameters.processorSupplier(), parentNodeNames()); if (storeNames.length > 0) { topologyBuilder.connectProcessorAndStateStores(processorName, storeNames); } if (storeNeeded) { topologyBuilder.addStateStore(Objects.requireNonNull(storeBuilder, "storeBuilder was null"), processorName); } }

Target:
public void writeToTopology(final InternalTopologyBuilder topologyBuilder) { final String processorName = processorParameters.processorName(); topologyBuilder.addProcessor(processorName, processorParameters.processorSupplier(), parentNodeNames()); if (storeNames.length > 0) { topologyBuilder.connectProcessorAndStateStores(processorName, storeNames); } if (processorParameters.processorSupplier() instanceof KTableSource) { if (((KTableSource<?, ?>) processorParameters.processorSupplier()).materialized()) { topologyBuilder.addStateStore(Objects.requireNonNull(storeBuilder, "storeBuilder was null"), processorName); } } else if (storeBuilder != null) { topologyBuilder.addStateStore(storeBuilder, processorName); } }
Source:
public boolean isDeactivationSafe() { return ctx.cache().inMemoryCaches().isEmpty(); }

Target:
public boolean isDeactivationSafe() { return !ctx.cache().cacheDescriptors().values().stream() .anyMatch(desc -> !isPersistentCache(desc.cacheConfiguration(), ctx.config().getDataStorageConfiguration())); }
Source:
public String getLink() { return this.link; }

Target:
public String getLink() { return BASE_STYLE_GUIDE_LINK + this.getName(); }
Source:
public synchronized void setCatalogInitialization(CatalogInitialization catalogInitialization) { if (catalogInitialization!=null) catalogInitialization.injectManagementContext(this); this.catalogInitialization = catalogInitialization; }

Target:
public void setCatalogInitialization(CatalogInitialization catalogInitialization) { synchronized (catalogInitMutex) { Preconditions.checkNotNull(catalogInitialization, "initialization must not be null"); if (this.catalogInitialization!=null && this.catalogInitialization != catalogInitialization) throw new IllegalStateException("Changing catalog init from "+this.catalogInitialization+" to "+catalogInitialization+"; changes not permitted"); catalogInitialization.injectManagementContext(this); this.catalogInitialization = catalogInitialization; } }
Source:
public String getSVG(String svgWidth, String svgHeight) { try { DOMSource domSource = new DOMSource(svgDocument.getFirstChild()); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); if(!svgWidth.isEmpty()){ svgDocument.getFirstChild().getAttributes().getNamedItem("width").setTextContent(svgWidth); } if(!svgHeight.isEmpty()){ svgDocument.getFirstChild().getAttributes().getNamedItem("height").setTextContent(svgHeight); } transformer.transform(domSource, result); return writer.toString(); } catch (TransformerException e) { throw new RuntimeException("Could not transform svg", e); } }

Target:
public String getSVG(String svgWidth, String svgHeight) { try { DOMSource domSource = new DOMSource(svgDocument.getFirstChild()); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); if (svgWidth != null && !svgWidth.isEmpty()) { svgDocument.getFirstChild().getAttributes().getNamedItem("width").setTextContent(svgWidth); } if (svgHeight != null && !svgHeight.isEmpty()) { svgDocument.getFirstChild().getAttributes().getNamedItem("height").setTextContent(svgHeight); } transformer.transform(domSource, result); return writer.toString(); } catch (TransformerException e) { throw new RuntimeException("Could not transform svg", e); } }
Source:
public void setExcludedPatterns(Set<String> patterns) { if (excludedPatterns != null && excludedPatterns.size() > 0) { LOG.warn("Replacing excluded patterns with [{}], be aware that this affects all instances and safety of your application!", excludedPatterns, patterns); } else { LOG.debug("Replacing excluded patterns with [{}], be aware that this affects all instances and safety of your application!", excludedPatterns, patterns); } excludedPatterns = new HashSet<>(patterns.size()); for (String pattern : patterns) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } }

Target:
public void setExcludedPatterns(Set<String> patterns) { if (excludedPatterns != null && excludedPatterns.size() > 0) { LOG.warn("Replacing excluded patterns with [{}], be aware that this affects all instances and safety of your application!", excludedPatterns, patterns); } else { LOG.debug("Sets excluded patterns to [{}]", patterns); } excludedPatterns = new HashSet<>(patterns.size()); for (String pattern : patterns) { excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE)); } }
Source:
public String getDisplayString(RadiologyReport radiologyReport) { return radiologyReport.getReportStatus() .toString(); }

Target:
public String getDisplayString(RadiologyReport radiologyReport) { return radiologyReport.getRadiologyOrder() .getOrderNumber() + ", " + radiologyReport.getReportStatus() .toString(); }
Source:
public boolean commit(Transaction tx) throws TException { try { return client.commitTx(TransactionConverterUtils.wrap(tx)).isValue(); } catch (Exception e) { isValid = false; throw e; } }

Target:
public boolean commit(Transaction tx) throws TException, TransactionNotInProgressException { try { return client.commitTx(TransactionConverterUtils.wrap(tx)).isValue(); } catch (TTransactionNotInProgressException e) { throw new TransactionNotInProgressException(e.getMessage()); } catch (TException e) { isValid.set(false); throw e; } }
Source:
private boolean addToFeatureMap(final Object featureKey, boolean unique, final Object value, final EObject holder) { Collection<EObject> setVal = valueToFeatureToHolderMap.get(value, featureKey); if (setVal == null) { setVal = unique ? new HashSet<EObject>() : HashMultiset.<EObject> create(); valueToFeatureToHolderMap.put(value, featureKey, setVal); } boolean changed = unique || !setVal.contains(holder); setVal.add(holder); return changed; }

Target:
private boolean addToFeatureMap(final Object featureKey, boolean unique, final Object value, final EObject holder) { Collection<EObject> setVal = valueToFeatureToHolderMap.get(value, featureKey); if (setVal == null) { setVal = unique ? new HashSet<EObject>() : HashMultiset.<EObject> create(); valueToFeatureToHolderMap.put(value, featureKey, setVal); } boolean changed = unique || !setVal.contains(holder); boolean success = setVal.add(holder); if (unique && !success) { String msg = String.format("Error adding feature %s to the index with type %s. This indicates some errors in underlying model representation.", value, featureKey); logNotificationHandlingError(msg); } return changed; }
Source:
public void testApplicationFileExist() throws Exception { File f = new File("target/liberty/usr/servers/test/dropins/appsdirectory-set-appz-configured-it.war"); Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists()); }

Target:
public void testApplicationFileExist() throws Exception { File f = new File("liberty/usr/servers/test/dropins/appsdirectory-set-appz-notconfigured-it.war"); Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists()); }
Source:
public void start(CoprocessorEnvironment env) throws IOException { Configuration config = env.getConfiguration(); timeInterval = config.getLong( QueryServices.TASK_HANDLING_INTERVAL_ATTRIB, QueryServicesOptions.DEFAULT_TASK_HANDLING_INTERVAL); timeMaxInterval = config.getLong( QueryServices.TASK_HANDLING_MAX_INTERVAL_ATTRIB, QueryServicesOptions.DEFAULT_TASK_HANDLING_MAX_INTERVAL); initialDelay = config.getLong( QueryServices.TASK_HANDLING_INITIAL_DELAY_ATTRIB, QueryServicesOptions.DEFAULT_TASK_HANDLING_INITIAL_DELAY); }

Target:
public void start(CoprocessorEnvironment env) throws IOException { Configuration config = env.getConfiguration(); timeInterval = config.getLong( QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, QueryServicesOptions.DEFAULT_TASK_HANDLING_INTERVAL_MS); timeMaxInterval = config.getLong( QueryServices.TASK_HANDLING_MAX_INTERVAL_MS_ATTRIB, QueryServicesOptions.DEFAULT_TASK_HANDLING_MAX_INTERVAL_MS); }
Source:
public void sendResourcePack(String url, String hash) throws IllegalArgumentException { Preconditions.checkArgument( hash.length() <= 40 ); if ( !hash.equals( resourcePackHash ) ) { unsafe().sendPacket( new ResourcePackRequest( url, hash ) ); } }

Target:
public void sendResourcePack(String url, String hash) throws IllegalArgumentException { if ( hash != null ) { Preconditions.checkArgument( hash.length() <= 40, "Hash must be at least 40 characters" ); if ( hash.equals( resourcePackHash ) ) { return; } } unsafe().sendPacket( new ResourcePackRequest( url, hash ) ); }
Source:
public String placeMarketOrder(MarketOrder marketOrder) throws IOException { return placeBithumbMarketOrder(marketOrder).getOrderId(); }

Target:
public String placeMarketOrder(MarketOrder marketOrder) throws IOException { try { return placeBithumbMarketOrder(marketOrder).getOrderId(); } catch (BithumbException e) { throw BithumbErrorAdapter.adapt(e); } }
Source:
public Mono<Map<Symbol, Object>> getRemoteProperties() { if (this.remoteProperties != null) { return Mono.just(this.remoteProperties); } synchronized (this) { if (this.remoteProperties != null) { return Mono.just(this.remoteProperties); } return RetryUtil.withRetry( getEndpointStates() .takeUntil(state -> state == AmqpEndpointState.ACTIVE) .then(Mono.fromCallable(() -> { this.remoteProperties = sender.getRemoteProperties(); return this.remoteProperties; })), timeout, retry); } }

Target:
public Mono<Map<Symbol, Object>> getRemoteProperties() { return RetryUtil.withRetry( getEndpointStates() .takeUntil(state -> state == AmqpEndpointState.ACTIVE) .then(Mono.fromCallable(sender::getRemoteProperties)), timeout, retry); }
Source:
private void defineJavaRepository(Context context) { NewRepository repo = context .createRepository(CheckListRegistrar.REPOSITORY_KEY, "java") .setName(CheckListRegistrar.REPOSITORY_NAME); rulesLoader.load(repo, CheckListRegistrar.CHECK_CLASSES); repo.done(); }

Target:
private void defineJavaRepository(Context context) { NewRepository repo = context .createRepository(JavaCheckClasses.REPOSITORY_KEY, "java") .setName(JavaCheckClasses.REPOSITORY_NAME); rulesLoader.load(repo, JavaCheckClasses.CHECK_CLASSES); repo.done(); }
Source:
public long getBytesReceived() { return callbackWrapper != null ? callbackWrapper.totalBytesRead.get() : 0; }

Target:
public long getBytesReceived() { return bytesReceived.get(); }