auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public Organisation rejectOrganisation(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "Organisation ID.", required = true) @PathParam("organisationId") Long id) { Organisation organisation = organisationDAO.findById(id); if (organisation == null) { String msg = "Organisation not found"; LOG.info(msg); throw new CustomWebApplicationException(msg, HttpStatus.SC_NOT_FOUND); } if (!Objects.equals(organisation.getStatus(), Organisation.ApplicationState.APPROVED)) { organisation.setStatus(Organisation.ApplicationState.REJECTED); Event rejectOrgEvent = new Event.Builder() .withOrganisation(organisation) .withInitiatorUser(user) .withType(Event.EventType.REJECT_ORG) .build(); eventDAO.create(rejectOrgEvent); } return organisationDAO.findById(id); }

Target:
public Organisation rejectOrganisation(@ApiParam(hidden = true) @Auth User user, @ApiParam(value = "Organisation ID.", required = true) @PathParam("organisationId") Long id) { Organisation organisation = organisationDAO.findById(id); if (organisation == null) { String msg = "Organisation not found"; LOG.info(msg); throw new CustomWebApplicationException(msg, HttpStatus.SC_NOT_FOUND); } if (Objects.equals(organisation.getStatus(), Organisation.ApplicationState.PENDING)) { organisation.setStatus(Organisation.ApplicationState.REJECTED); Event rejectOrgEvent = new Event.Builder() .withOrganisation(organisation) .withInitiatorUser(user) .withType(Event.EventType.REJECT_ORG) .build(); eventDAO.create(rejectOrgEvent); } else if (Objects.equals(organisation.getStatus(), Organisation.ApplicationState.APPROVED)) { String msg = "The organization is already approved"; LOG.info(msg); throw new CustomWebApplicationException(msg, HttpStatus.SC_BAD_REQUEST); } return organisationDAO.findById(id); }
Source:
protected GuiScrollbar getScrollBar() { return this.myScrollBar; }

Target:
protected GuiScrollbar getScrollBar() { return this.scrollBar; }
Source:
private static Expression updateComparisonPredicate(Expression expression) { Function functionCall = expression.getFunctionCall(); if (functionCall != null) { SqlKind sqlKind = SqlKind.OTHER_FUNCTION; try { sqlKind = SqlKind.valueOf(functionCall.getOperator().toUpperCase()); } catch (Exception e) { } switch (sqlKind) { case EQUALS: case NOT_EQUALS: case GREATER_THAN: case GREATER_THAN_OR_EQUAL: case LESS_THAN: case LESS_THAN_OR_EQUAL: if (functionCall.getOperands().get(0).getLiteral() != null) { functionCall.setOperator(getOppositeOperator(functionCall.getOperator())); List<Expression> oldOperands = functionCall.getOperands(); Expression tempExpr = oldOperands.get(0); oldOperands.set(0, oldOperands.get(1)); oldOperands.set(1, tempExpr); } if (functionCall.getOperands().get(1).getLiteral() != null) { return expression; } Expression comparisonFunction = RequestUtils.getFunctionExpression(functionCall.getOperator()); List<Expression> exprList = new ArrayList<>(); exprList.add(getLeftOperand(functionCall)); exprList.add(RequestUtils.getLiteralExpression(0)); comparisonFunction.getFunctionCall().setOperands(exprList); return comparisonFunction; default: List<Expression> operands = functionCall.getOperands(); List<Expression> newOperands = new ArrayList<>(); if (operands != null) { for (int i = 0; i < operands.size(); i++) { newOperands.add(updateComparisonPredicate(operands.get(i))); } } functionCall.setOperands(newOperands); } } return expression; }

Target:
private static Expression updateComparisonPredicate(Expression expression) { Function functionCall = expression.getFunctionCall(); if (functionCall != null) { SqlKind sqlKind = SqlKind.OTHER_FUNCTION; try { sqlKind = SqlKind.valueOf(functionCall.getOperator().toUpperCase()); } catch (Exception e) { } switch (sqlKind) { case EQUALS: case NOT_EQUALS: case GREATER_THAN: case GREATER_THAN_OR_EQUAL: case LESS_THAN: case LESS_THAN_OR_EQUAL: if (functionCall.getOperands().get(0).getLiteral() != null) { functionCall.setOperator(getOppositeOperator(functionCall.getOperator())); List<Expression> oldOperands = functionCall.getOperands(); Expression tempExpr = oldOperands.get(0); oldOperands.set(0, oldOperands.get(1)); oldOperands.set(1, tempExpr); } if (functionCall.getOperands().get(1).getLiteral() != null) { return expression; } Expression comparisonFunction = RequestUtils.getFunctionExpression(functionCall.getOperator()); List<Expression> exprList = new ArrayList<>(); exprList.add(getLeftOperand(functionCall)); exprList.add(RequestUtils.getLiteralExpression(0)); comparisonFunction.getFunctionCall().setOperands(exprList); return comparisonFunction; default: List<Expression> newOperands = new ArrayList<>(); int operandsSize = functionCall.getOperandsSize(); for (int i = 0; i < operandsSize; i++) { Expression operand = functionCall.getOperands().get(i); newOperands.add(updateComparisonPredicate(operand)); } functionCall.setOperands(newOperands); } } return expression; }
Source:
public Roles list() { MultilevelAdministrationByAdElementIdParameters params = new MultilevelAdministrationByAdElementIdParameters(principalId); params.setFiltered(SessionUtils.isFiltered()); return mapCollection(getBackendCollection(VdcQueryType.GetPermissionsByAdElementId, params)); }

Target:
public Roles list() { return mapCollection(getBackendCollection(VdcQueryType.GetPermissionsByAdElementId, new MultilevelAdministrationByAdElementIdParameters(principalId))); }
Source:
public void validate(OrcDataSource input) throws OrcCorruptionException { checkState(validationBuilder != null, "validation is not enabled"); validateFile( validationBuilder.build(), input, types, hiveStorageTimeZone, orcEncoding, new OrcReaderConfig(false)); }

Target:
public void validate(OrcDataSource input) throws OrcCorruptionException { checkState(validationBuilder != null, "validation is not enabled"); validateFile( validationBuilder.build(), input, types, hiveStorageTimeZone, orcEncoding, new OrcReaderOptions(new DataSize(1, MEGABYTE), new DataSize(8, MEGABYTE), new DataSize(16, MEGABYTE), false)); }
Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.friends_fragment, container, false); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setHasFixedSize(true); recyclerView.addItemDecoration(new FeedAdapter.FeedOffsetDecorator( getResources().getDimensionPixelSize(R.dimen.default_padding))); recyclerView.addItemDecoration(new FeedAdapter.FeedShadowDecorator( getActivity().getResources().getDrawable(R.drawable.show_screen_shadow))); if (typeface == null) { typeface = Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Medium.ttf"); } loadData(); return view; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.friends_fragment, container, false); recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setHasFixedSize(true); recyclerView.addItemDecoration(new FeedAdapter.FeedOffsetDecorator( getResources().getDimensionPixelSize(R.dimen.default_padding))); recyclerView.addItemDecoration(new FeedAdapter.FeedShadowDecorator( getResources().getDrawable(R.drawable.show_screen_shadow))); loadData(); return view; }
Source:
private void setGlobalHaMaintenance(boolean enabled) { VM vm = (VM) getSelectedItem(); if (vm == null) { return; } if (!vm.isHostedEngine()) { return; } SetHaMaintenanceParameters params = new SetHaMaintenanceParameters(vm.getRunOnVds(), HaMaintenanceMode.GLOBAL, enabled); Frontend.getInstance().runAction(VdcActionType.SetHaMaintenance, params, null, this); }

Target:
private void setGlobalHaMaintenance(boolean enabled) { VM vm = (VM) getSelectedItem(); if (vm == null) { return; } if (!vm.isHostedEngine()) { return; } SetHaMaintenanceParameters params = new SetHaMaintenanceParameters(vm.getRunOnVds(), HaMaintenanceMode.GLOBAL, enabled); Frontend.getInstance().runAction(VdcActionType.SetHaMaintenance, params); }
Source:
public static ByteSource serializeImage( final BufferedImage bufferedImage, final String mimeType, final int quality ) throws IOException { final byte[] serializedImage; final String format = getFormatByMimeType( mimeType ); if ( quality != 0 ) { serializedImage = writeImage( bufferedImage, format, quality ); } else { serializedImage = writeImage( bufferedImage, format ); } return ByteSource.wrap( serializedImage ); }

Target:
public static byte[] serializeImage( final BufferedImage bufferedImage, final String mimeType, final int quality ) throws IOException { final byte[] serializedImage; final String format = getFormatByMimeType( mimeType ); if ( quality != 0 ) { serializedImage = writeImage( bufferedImage, format, quality ); } else { serializedImage = writeImage( bufferedImage, format ); } return serializedImage; }
Source:
public IntegrationFlow build() { Assert.notNull(itemWriter, "An ItemWriter must be provided"); if(this.itemProcessor == null) { this.itemProcessor = new PassThroughItemProcessor(); } SimpleChunkProcessor<I, O> chunkProcessor = new SimpleChunkProcessor<>(itemProcessor, itemWriter); ChunkProcessorChunkHandler<I> chunkProcessorChunkHandler = new ChunkProcessorChunkHandler<>(); chunkProcessorChunkHandler.setChunkProcessor(chunkProcessor); return IntegrationFlows .from(inputChannel) .handle(chunkProcessorChunkHandler, SERVICE_ACTIVATOR_METHOD_NAME) .channel(outputChannel) .get(); }

Target:
public IntegrationFlow build() { Assert.notNull(this.itemWriter, "An ItemWriter must be provided"); Assert.notNull(this.inputChannel, "An InputChannel must be provided"); Assert.notNull(this.outputChannel, "An OutputChannel must be provided"); if(this.itemProcessor == null) { this.itemProcessor = new PassThroughItemProcessor(); } SimpleChunkProcessor<I, O> chunkProcessor = new SimpleChunkProcessor<>(this.itemProcessor, this.itemWriter); ChunkProcessorChunkHandler<I> chunkProcessorChunkHandler = new ChunkProcessorChunkHandler<>(); chunkProcessorChunkHandler.setChunkProcessor(chunkProcessor); return IntegrationFlows .from(this.inputChannel) .handle(chunkProcessorChunkHandler, SERVICE_ACTIVATOR_METHOD_NAME) .channel(this.outputChannel) .get(); }
Source:
public List<PsiElement> getGroovyElements(@NotNull GroovyPsiElementFactory factory) { String extraGroovyCode; switch (type) { case EXTERNAL: extraGroovyCode = " '" + data + "'"; break; case MODULE: extraGroovyCode = " project('" + data + "')"; break; case FILES: extraGroovyCode = " files('" + data + "')"; break; case FILETREE: extraGroovyCode = " fileTree(" + GradleGroovyFile.convertMapToGroovySource((Map<String, Object>)data) + ")"; break; default: extraGroovyCode = ""; break; } return ImmutableList.of( (PsiElement)factory.createStatementFromText(scope.getGroovyMethodCall() + extraGroovyCode) ); }

Target:
public List<PsiElement> getGroovyElements(@NotNull GroovyPsiElementFactory factory) { String extraGroovyCode; switch (type) { case EXTERNAL: extraGroovyCode = " '" + escapeLiteralString(data) + "'"; break; case MODULE: extraGroovyCode = " project('" + escapeLiteralString(data) + "')"; break; case FILES: extraGroovyCode = " files('" + escapeLiteralString(data) + "')"; break; case FILETREE: extraGroovyCode = " fileTree(" + GradleGroovyFile.convertMapToGroovySource((Map<String, Object>)data) + ")"; break; default: extraGroovyCode = ""; break; } return ImmutableList.of( (PsiElement)factory.createStatementFromText(scope.getGroovyMethodCall() + extraGroovyCode) ); }
Source:
public void updateStatus(String url, PluginSettings pluginSettings, String prIdStr, String revision, String pipelineStage, String result, String trackbackURL) throws Exception { LOGGER.info(String.format("GitHubProvider.updateStatus(): '%s' -> %s", result, url)); String repository = getRepository(url); GHCommitState state = getState(result); String endPointToUse = pluginSettings.getEndPoint(); String usernameToUse = pluginSettings.getUsername(); String passwordToUse = pluginSettings.getPassword(); String oauthAccessTokenToUse = pluginSettings.getOauthToken(); if (StringUtils.isEmpty(endPointToUse)) { endPointToUse = System.getProperty("go.plugin.build.status.github.endpoint"); } if (StringUtils.isEmpty(usernameToUse)) { usernameToUse = System.getProperty("go.plugin.build.status.github.username"); } if (StringUtils.isEmpty(passwordToUse)) { passwordToUse = System.getProperty("go.plugin.build.status.github.password"); } if (StringUtils.isEmpty(oauthAccessTokenToUse)) { oauthAccessTokenToUse = System.getProperty("go.plugin.build.status.github.oauth"); } updateCommitStatus(revision, pipelineStage, trackbackURL, repository, state, usernameToUse, passwordToUse, oauthAccessTokenToUse, endPointToUse); }

Target:
public void updateStatus(String url, PluginSettings pluginSettings, String prIdStr, String revision, String pipelineStage, String result, String trackbackURL) throws Exception { LOGGER.info("Updating status for '%s' to %s", url, result); String repository = getRepository(url); GHCommitState state = getState(result); String endPointToUse = pluginSettings.getEndPoint(); String usernameToUse = pluginSettings.getUsername(); String passwordToUse = pluginSettings.getPassword(); String oauthAccessTokenToUse = pluginSettings.getOauthToken(); if (StringUtils.isEmpty(endPointToUse)) { endPointToUse = System.getProperty("go.plugin.build.status.github.endpoint"); } if (StringUtils.isEmpty(usernameToUse)) { usernameToUse = System.getProperty("go.plugin.build.status.github.username"); } if (StringUtils.isEmpty(passwordToUse)) { passwordToUse = System.getProperty("go.plugin.build.status.github.password"); } if (StringUtils.isEmpty(oauthAccessTokenToUse)) { oauthAccessTokenToUse = System.getProperty("go.plugin.build.status.github.oauth"); } updateCommitStatus(revision, pipelineStage, trackbackURL, repository, state, usernameToUse, passwordToUse, oauthAccessTokenToUse, endPointToUse); }
Source:
private String toVarcharValue(Object value) { if (value instanceof Collection<?>) { return "[" + String.join(", ", ((Collection<?>) value).stream().map(this::toVarcharValue).collect(toList())) + "]"; } if (value instanceof Document) { return ((Document) value).toJson(); } return value.toString(); }

Target:
private String toVarcharValue(Object value) { if (value instanceof Collection<?>) { return "[" + String.join(", ", ((Collection<?>) value).stream().map(this::toVarcharValue).collect(toList())) + "]"; } if (value instanceof Document) { return ((Document) value).toJson(); } return String.valueOf(value); }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); checkFirstRun(); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(true); Tab tab = actionBar.newTab() .setText("Claims") .setTabListener(new ClaimTabListener<ClaimTabFragment>(this, "Claims", ClaimTabFragment.class)); actionBar.addTab(tab); tab = actionBar.newTab() .setText("Approval") .setTabListener(new ClaimTabListener<ApprovalTabFragment>(this, "Approval", ApprovalTabFragment.class)); actionBar.addTab(tab);; }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); userManager = new UserManager(this); if (userManager.getActiveUser() == null) { promptForUserInformation(); } else { loadSession(); } ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(true); Tab tab = actionBar.newTab() .setText(R.string.title_tab_claims) .setTabListener(new ClaimTabListener<ClaimTabFragment>(this, "Claims", ClaimTabFragment.class)); actionBar.addTab(tab); tab = actionBar.newTab() .setText(R.string.title_tab_approval) .setTabListener(new ClaimTabListener<ApprovalTabFragment>(this, "Approval", ApprovalTabFragment.class)); actionBar.addTab(tab); }
Source:
private static String getStringFromInputStream(InputStream is) { BufferedReader br = null; StringBuilder sb = new StringBuilder(); String line; try { br = new BufferedReader(new InputStreamReader(is)); while ((line = br.readLine()) != null) { sb.append(line); } } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return sb.toString(); }

Target:
private static String getStringFromInputStream(InputStream is) throws IOException { BufferedReader br = null; StringBuilder sb = new StringBuilder(); String line; try { br = new BufferedReader(new InputStreamReader(is)); while ((line = br.readLine()) != null) { sb.append(line); sb.append("\n"); } } finally { if (br != null) { br.close(); } } return sb.toString(); }
Source:
public static LatokenOrderSide parse(String s) { try { return LatokenOrderSide.valueOf(s); } catch (Exception e) { throw new RuntimeException("Unknown LatokenOrderSide " + s + "."); } }

Target:
public static LatokenOrderSide parse(String s) { try { return LatokenOrderSide.valueOf(s); } catch (Exception e) { throw new ExchangeException("Unknown LatokenOrderSide " + s + "."); } }
Source:
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; }

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:
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()) { this.viewer.getTree().getDisplay().asyncExec(new Runnable() { @Override public void run() { for (IContainer parent : parentsToRefresh) { NestedProjectsContentProvider.this.viewer.refresh(parent); } parentsToRefresh.clear(); } }); } } }

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:
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()); } return multiInstantiator.instantiate(target, parameters); } catch (ConversionException ex) { errors.add(ex.getValidationMessage().withCategory(target.getName())); } catch (IllegalStateException e) { return setPropertiesAfterConversions(target, parameters); } return null; }

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:
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 -> { try { 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); } }

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:
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()) { Object s = tmp_it.next(); record.addField(ValueUtil.toStratosphere(s)); } } else { record.setField(0, ValueUtil.toStratosphere(b)); } return true; } else { return false; } }

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:
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()); if(!Utils.didApiReturnedWithOutErrors(msg, arw)){ return arw; } return arw; }

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:
public BackupPushStateStatusCommand() { super(0); }

Target:
public BackupPushStateStatusCommand() { super(1); }
Source:
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) .filter(i -> (i < 57 || i > 65) && (i < 90 || i > 97)) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); LOG.debug(generatedString); }

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:
public void prepare(Map stormConf, TopologyContext context, final OutputCollector collector) { int processQSize = ((Number)stormConf.get(Config.TOPOLOGY_SHELLBOLT_MAX_PENDING)).intValue(); _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); }

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:
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(); 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; } }

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:
public boolean equals(Object o) { if (o instanceof MeasurementKey) { MeasurementKey other = (MeasurementKey) o; return d_som.equals(other.d_som) && EqualsUtil.equal(d_arm, other.d_arm) && EqualsUtil.equal(d_wt, other.d_wt); } return false; }

Target:
public boolean equals(Object o) { MeasurementKey other = matching(o); return other != null && d_som == other.d_som; }
Source:
protected void updateOptionRanksMapping( Map<String, List<Integer>> optionRanks, String optionReceivingRanks, int rankReceived) { optionRanks.putIfAbsent(optionReceivingRanks, new ArrayList<Integer>()); List<Integer> ranksReceived = optionRanks.get(optionReceivingRanks); ranksReceived.add(rankReceived); }

Target:
protected void updateOptionRanksMapping( Map<String, List<Integer>> optionRanks, String optionReceivingRanks, int rankReceived) { optionRanks.computeIfAbsent(optionReceivingRanks, key -> new ArrayList<>()) .add(rankReceived); }
Source:
public static FS detect(Boolean cygwinUsed) { if (factory == null) { try { Class<?> activatorClass = Class .forName("org.eclipse.jgit.util.Java7FSFactory"); System.out.println("Found Java7"); 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); }

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:
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 arePropsEquals(list1.get(0), list2.get(0)); } }

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:
public static SchedulerType lookup(String schedulerType) { return valueOfIgnoreCase(schedulerType); }

Target:
public static SchedulerType lookup(String schedulerType) throws UnsupportedTypeException { return lookup(schedulerType, false, false); }
Source:
public static CalcState fromJSON(final String json) throws JSONException { CalcState rv = null; if (json != null) { rv = new CalcState(new JSONObject(json)); } return rv; }

Target:
public static CalcState fromJSON(final String json) throws JSONException { if (json == null) { return null; } return new CalcState(new JSONObject(json)); }
Source:
synchronized public 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); } } }

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:
private void addLinks(RunImageConfiguration runConfig, List<String> ret) { if (!runConfig.getNetworkingConfig().isCustomNetwork()) { for (String[] link : EnvUtil.splitOnLastColon(runConfig.getLinks())) { ret.add(link[0]); } } }

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:
public static Dimension getImageBounds(final String path) { ImageDescriptor descriptor = imageDescriptor(path); if (descriptor != null) { ImageData imgData = descriptor.getImageData(100); if (imgData != null) { return new Dimension(imgData.width, imgData.height); } } return null; }

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:
public static void writeOpenTag(final Response response, String id) { HeaderItemAttributeMap attributes = new HeaderItemAttributeMap(); attributes.add(HeaderItemAttribute.TYPE, "text/javascript"); if (id != null) { attributes.add(HeaderItemAttribute.ID, id); } writeOpenTag(response, attributes); }

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:
public boolean matchesPathInfo(String pathInfo) { LOGGER.entering(); DefaultManagedArtifact request = new DefaultManagedArtifact(REPO_ABSOLUTE_PATH + pathInfo); boolean matches = this.equals(request); LOGGER.exiting(matches); return matches; }

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:
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.tell(message, self); }

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:
public List<Number> getData() { return fData; }

Target:
public List<Number> getData() { return ImmutableList.copyOf(fData); }
Source:
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) { throw new IllegalStateException("Trace does not seem to have a directory backing it : " + trace); } 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); } } } }

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:
public void shouldSaveOrderSet() throws Exception { executeDataSet(ORDER_SET); OrderSet orderSet = orderSetBuilder(false, false); OrderSet orderSetObj = orderSetService.save(orderSet); assertNotNull("OrderSet has a order_set_id", orderSetObj.getId().intValue()); }

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:
public void addListener(EthereumListener listener) { logger.info("Ethereum listener added"); ((BackwardCompatibilityEthereumListenerProxy) listener).getCompositeListener().addListener(listener); }

Target:
public void addListener(EthereumListener listener) { logger.info("Ethereum listener added"); ((BackwardCompatibilityEthereumListenerProxy) this.listener).getCompositeListener().addListener(listener); }
Source:
public static OkHttpClient defaultClient() { return new OkHttpClient.Builder() .connectionPool(connectionPool) .dns(new SingleInetAddressDns()) .build(); }

Target:
public static OkHttpClient defaultClient() { return new OkHttpClient.Builder() .connectionPool(connectionPool) .build(); }
Source:
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); if (MAP_AGENT_SANDBOX == true) { 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"); } }

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:
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)); } openPartCount = partCount; processedEventIndexMap = new HashMap<>(partCount); for (int i = 0; i < partCount; i++) { processedEventIndexMap.put(i, -1L); } }

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:
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() && ScalarQueryUtil.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()); }

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()); }