auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testBlobNotFoundCase() throws Exception { doPut(); operationsCount.incrementAndGet(); GetBlobOperation op = new GetBlobOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobIdStr, operationFuture, null, operationCompleteCallback, time); ArrayList<RequestInfo> requestListToFill = new ArrayList<>(); requestRegistrationCallback.requestListToFill = requestListToFill; for (MockServer server : mockServerLayout.getMockServers()) { server.setServerErrorForAllRequests(ServerErrorCode.Blob_Not_Found); } while (!op.isOperationComplete()) { op.poll(requestRegistrationCallback); List<ResponseInfo> responses = sendAndWaitForResponses(requestListToFill); for (ResponseInfo response : responses) { op.handleResponse(response); if (op.isOperationComplete()) { break; } } } Assert.assertEquals("Must have attempted sending requests to all replicas", replicasCount, correlationIdToGetOperation.size()); Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); RouterException routerException = (RouterException) op.getOperationException(); Assert.assertEquals(RouterErrorCode.BlobDoesNotExist, routerException.getErrorCode()); }

Target:
public void testBlobNotFoundCase() throws Exception { doPut(); operationsCount.incrementAndGet(); GetBlobOperation op = new GetBlobOperation(routerConfig, routerMetrics, mockClusterMap, responseHandler, blobIdStr, operationFuture, null, operationCompleteCallback, blobIdFactory, time); ArrayList<RequestInfo> requestListToFill = new ArrayList<>(); requestRegistrationCallback.requestListToFill = requestListToFill; for (MockServer server : mockServerLayout.getMockServers()) { server.setServerErrorForAllRequests(ServerErrorCode.Blob_Not_Found); } while (!op.isOperationComplete()) { op.poll(requestRegistrationCallback); List<ResponseInfo> responses = sendAndWaitForResponses(requestListToFill); for (ResponseInfo response : responses) { op.handleResponse(response); if (op.isOperationComplete()) { break; } } } Assert.assertEquals("Must have attempted sending requests to all replicas", replicasCount, correlationIdToGetOperation.size()); Assert.assertTrue("Operation should be complete at this time", op.isOperationComplete()); RouterException routerException = (RouterException) op.getOperationException(); Assert.assertEquals(RouterErrorCode.BlobDoesNotExist, routerException.getErrorCode()); }
Source:
public void testCreateRelationshipFieldWithDash_Return400() throws Exception { final FieldResource resource = new FieldResource(); final ContentType contentType = getContentType(); final String jsonField = "{"+ " \"clazz\" : \"com.dotcms.contenttype.model.field.ImmutableRelationshipField\","+ " \"contentTypeId\" : \"CONTENT_TYPE_ID\","+ " \"name\" : \"YouTube Videos\","+ " \"values\" : 1," + " \"variable\": \"youtube-videos\","+ " \"relationType\": \"Youtube\""+ " }"; final Response response = resource.createContentTypeField( contentType.id(), jsonField.replace("CONTENT_TYPE_ID", contentType.id()), getHttpRequest()); assertNotNull(response); assertEquals(400, response.getStatus()); assertTrue("Error: " + response.getEntity().toString(), response.getEntity().toString().contains("contains characters not allowed")); }

Target:
public void testCreateRelationshipFieldWithDash_Return400() throws Exception { final FieldResource resource = new FieldResource(); final ContentType contentType = getContentType(); final String jsonField = "{"+ " \"clazz\" : \"" + ImmutableRelationshipField.class.getCanonicalName() +"\","+ " \"contentTypeId\" : \"CONTENT_TYPE_ID\","+ " \"name\" : \"YouTube Videos\","+ " \"values\" : 1," + " \"variable\": \"youtube-videos\","+ " \"relationType\": \"Youtube\""+ " }"; final Response response = resource.createContentTypeField( contentType.id(), jsonField.replace("CONTENT_TYPE_ID", contentType.id()), getHttpRequest()); assertNotNull(response); assertEquals(400, response.getStatus()); assertTrue("Error: " + response.getEntity().toString(), response.getEntity().toString().contains("contains characters not allowed")); }
Source:
private void registerPanda() { register(new PandaEntityEatingTimeProvider()); register(PandaEntity.class, Keys.HIDDEN_GENE, p -> ((PandaGene) (Object) p.getHiddenGene()), (p, g) -> p.setHiddenGene((PandaEntity.Type) (Object) g)); register(PandaEntity.class, Keys.KNOWN_GENE, p -> ((PandaGene) (Object) p.getMainGene()), (p, g) -> p.setMainGene((PandaEntity.Type) (Object) g)); register(PandaEntity.class, Keys.IS_EATING, PandaEntity::func_213578_dZ, PandaEntity::func_213534_t); register(PandaEntity.class, Keys.IS_LYING_ON_BACK, PandaEntity::func_213567_dY, PandaEntity::func_213542_s); register(PandaEntity.class, Keys.IS_ROLLING_AROUND, PandaEntity::func_213564_eh, PandaEntity::func_213576_v); register(PandaEntity.class, Keys.SNEEZING_TIME, PandaEntity::func_213585_ee, PandaEntity::func_213562_s); register(PandaEntity.class, Keys.UNHAPPY_TIME, PandaEntity::func_213544_dV, PandaEntity::func_213588_r); }

Target:
private void registerPanda() { register(PandaEntityAccessor.class, Keys.EATING_TIME, PandaEntityAccessor::accessor$func_213559_es, PandaEntityAccessor::accessor$func_213571_t); register(PandaEntity.class, Keys.HIDDEN_GENE, p -> ((PandaGene) (Object) p.getHiddenGene()), (p, g) -> p.setHiddenGene((PandaEntity.Type) (Object) g)); register(PandaEntity.class, Keys.KNOWN_GENE, p -> ((PandaGene) (Object) p.getMainGene()), (p, g) -> p.setMainGene((PandaEntity.Type) (Object) g)); register(PandaEntity.class, Keys.IS_EATING, PandaEntity::func_213578_dZ, PandaEntity::func_213534_t); register(PandaEntity.class, Keys.IS_FRIGHTENED, PandaEntity::func_213566_eo); register(PandaEntity.class, Keys.IS_LYING_ON_BACK, PandaEntity::func_213567_dY, PandaEntity::func_213542_s); register(PandaEntity.class, Keys.IS_ROLLING_AROUND, PandaEntity::func_213564_eh, PandaEntity::func_213576_v); register(PandaEntity.class, Keys.IS_SNEEZING, PandaEntity::func_213539_dW, PandaEntity::func_213581_u); register(PandaEntity.class, Keys.IS_UNHAPPY, panda -> panda.func_213544_dV() > 0); register(PandaEntity.class, Keys.SNEEZING_TIME, PandaEntity::func_213585_ee, PandaEntity::func_213562_s); register(PandaEntity.class, Keys.UNHAPPY_TIME, PandaEntity::func_213544_dV, PandaEntity::func_213588_r); }
Source:
private void send(String message, String vmID, boolean removeClient){ ReactorClient client; client = JsonRpcServer.getReacorsMap().get(vmID); if (client == null){ log.error("failed to sync reactors"); client = JsonRpcServer.getReactorClient(); if (client == null) { log.error("cannot initialize client, null pointer"); return; } } try { client.sendMessage(message.getBytes()); log.debug("sending events message {}", message); }catch (ClientConnectionException e) { log.error("Failure in sending response", e); } if (removeClient){ JsonRpcServer.removeReactors(vmID); } }

Target:
private void send(String message, String vmID, boolean removeClient) throws ClientConnectionException{ try { ReactorClient client = JsonRpcServer.getReactorsMap().get(vmID); client.sendMessage(message.getBytes()); log.debug("sending events message {}", message); }catch (ClientConnectionException e) { log.error("Failure in sending response", e); } if (removeClient){ JsonRpcServer.removeReactorsMap(vmID); } }
Source:
public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { if (newFile == null) { return false; } if (fileTypes == null || fileTypes.isEmpty()) { return true; } final List<String> fileMimes = fileTypes.stream() .filter(fileType -> fileType.matches("[^/\\n]+\\/[^/\\n]+")) .collect(Collectors.toList()); final List<String> fileExts = fileTypes.stream() .filter(fileType -> !fileMimes.contains(fileType)) .collect(Collectors.toList()); boolean extMatch = false; if (fileExts.size() > 0 && newFile.getName() != null) { String[] split = newFile.getName().split(("\\.(?=[^\\.]+$)")); if (split.length == 2) { extMatch = fileExts.stream().anyMatch(fileExt -> fileExt.equals("." + split[1])); } } boolean mimeMatch = false; if (!extMatch && fileMimes.size() > 0) { try { final String mimeType = getFileMimeType(newFile); LOG.debug("File mime-type is: " + mimeType); for (String fileMime : fileMimes) { if (StringUtils.equals(mimeType, fileMime)) { mimeMatch = true; } else if (fileMime.indexOf("*") == fileMime.length() - 1) { fileMime = fileMime.substring(0, fileMime.length() - 1); if (mimeType.indexOf(fileMime) == 0) { mimeMatch = true; } } } } catch (IOException e) { LOG.error("Invalid file type"); } } return extMatch || mimeMatch; }

Target:
public static boolean validateFileType(final FileItemWrap newFile, final List<String> fileTypes) { if (newFile == null) { return false; } if (fileTypes == null || fileTypes.isEmpty()) { return true; } ; final List<String> fileExts = fileTypes.stream() .filter(fileType -> fileType.startsWith(".")) .collect(Collectors.toList()); final List<String> fileMimes = fileTypes.stream() .filter(fileType -> !fileExts.contains(fileType)) .collect(Collectors.toList()); if (fileExts.size() > 0 && newFile.getName() != null) { String[] split = newFile.getName().split(("\\.(?=[^\\.]+$)")); if (split.length == 2 && fileExts.stream().anyMatch(fileExt -> fileExt.equals("." + split[1]))) { return true; } } if (fileMimes.size() > 0) { final String mimeType = getFileMimeType(newFile); LOG.debug("File mime-type is: " + mimeType); for (String fileMime : fileMimes) { if (StringUtils.equals(mimeType, fileMime)) { return true; } if (fileMime.indexOf("*") == fileMime.length() - 1) { fileMime = fileMime.substring(0, fileMime.length() - 1); if (mimeType.indexOf(fileMime) == 0) { return true; } } } } return false; }
Source:
public Response workflowsGet(Integer limit, Integer offset, String accept, String ifNoneMatch, String workflowType) { limit = limit != null ? limit : RestApiConstants.PAGINATION_LIMIT_DEFAULT; offset = offset != null ? offset : RestApiConstants.PAGINATION_OFFSET_DEFAULT; String tenantDomain = RestApiUtil.getLoggedInUserTenantDomain(); WorkflowListDTO workflowListDTO; try { Workflow[] workflows; String status="CREATED"; APIAdmin apiAdmin = new APIAdminImpl(); workflows=apiAdmin.getworkflows(workflowType, status ,tenantDomain); try { workflowListDTO = WorkflowMappingUtil.fromWorkflowsToDTO(workflows, limit, offset); WorkflowMappingUtil.setPaginationParams(workflowListDTO, limit, offset, workflows.length); return Response.ok().entity(workflowListDTO).build(); } catch( NullPointerException e){ RestApiUtil.handleInternalServerError("Error while retrieving workflow requests" , e, log); } } catch(APIManagementException e){ RestApiUtil.handleInternalServerError("Error while retrieving workflow requests" , e, log); } return null; }

Target:
public Response workflowsGet(Integer limit, Integer offset, String accept, String ifNoneMatch, String workflowType) { limit = limit != null ? limit : RestApiConstants.PAGINATION_LIMIT_DEFAULT; offset = offset != null ? offset : RestApiConstants.PAGINATION_OFFSET_DEFAULT; String tenantDomain = RestApiUtil.getLoggedInUserTenantDomain(); WorkflowListDTO workflowListDTO; try { Workflow[] workflows; String status = "CREATED"; APIAdmin apiAdmin = new APIAdminImpl(); workflows = apiAdmin.getworkflows(workflowType, status, tenantDomain); workflowListDTO = WorkflowMappingUtil.fromWorkflowsToDTO(workflows, limit, offset); WorkflowMappingUtil.setPaginationParams(workflowListDTO, limit, offset, workflows.length); return Response.ok().entity(workflowListDTO).build(); } catch (APIManagementException e) { RestApiUtil.handleInternalServerError("Error while retrieving workflow requests. ", e, log); } return null; }
Source:
public List<SimpleEntity> createSimpleEntities() { SimpleEntity entityOne = new SimpleEntity(); SimpleEntity divisionTwo = new SimpleEntity(); entityOne.setId(1); entityOne.setName("Wydzial 1"); divisionTwo.setId(23); divisionTwo.setName("Wydział 23 Karny"); return Lists.newArrayList(entityOne, divisionTwo); }

Target:
public List<SimpleEntity> createSimpleEntities() { SimpleEntity entityOne = new SimpleEntity(); SimpleEntity entityTwo = new SimpleEntity(); entityOne.setId(1); entityOne.setName("Wydzial 1"); entityTwo.setId(23); entityTwo.setName("Wydział 23 Karny"); return Lists.newArrayList(entityOne, entityTwo); }
Source:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { getSupportActionBar().setElevation(0); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } SettingsFragment settingsFragment = (SettingsFragment) getSupportFragmentManager().findFragmentById(R.id.settingsContentFrame); if (settingsFragment == null) { settingsFragment = SettingsFragment.newInstance(); } if (!settingsFragment.isActive()) { addFragmentToActivity(getSupportFragmentManager(), settingsFragment, R.id.settingsContentFrame); } new SettingsPresenter(settingsFragment, mOpenMRSLogger); }

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setElevation(0); actionBar.setDisplayHomeAsUpEnabled(true); } SettingsFragment settingsFragment = (SettingsFragment) getSupportFragmentManager().findFragmentById(R.id.settingsContentFrame); if (settingsFragment == null) { settingsFragment = SettingsFragment.newInstance(); } if (!settingsFragment.isActive()) { addFragmentToActivity(getSupportFragmentManager(), settingsFragment, R.id.settingsContentFrame); } new SettingsPresenter(settingsFragment, mOpenMRSLogger); }
Source:
protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern currentNode = node.clone(); final Var subVar = node.getSubjectVar(); final Var predVar = node.getPredicateVar(); final Var objVar = node.getObjectVar(); final Var conVar = node.getContextVar(); if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) { final List<Set<Resource>> intersections = inferenceEngine.getIntersectionsImplying((URI) objVar.getValue()); if (intersections != null && !intersections.isEmpty()) { final Set<Resource> combinedIntersections = new TreeSet<>(new ResourceComparator()); for (final Set<Resource> intersection : intersections) { combinedIntersections.addAll(intersection); } final TupleExpr joinTree = createJoinTree(new ArrayList<>(combinedIntersections), subVar, conVar); if (joinTree != null) { final Union union = new InferUnion(joinTree, currentNode); node.replaceWith(union); log.trace("Replacing node with inferred intersection union: " + union); } } } }

Target:
protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern currentNode = node.clone(); final Var subVar = node.getSubjectVar(); final Var predVar = node.getPredicateVar(); final Var objVar = node.getObjectVar(); final Var conVar = node.getContextVar(); if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) { final List<Set<Resource>> intersections = inferenceEngine.getIntersectionsImplying((URI) objVar.getValue()); if (intersections != null && !intersections.isEmpty()) { final List<TupleExpr> joins = new ArrayList<>(); for (final Set<Resource> intersection : intersections) { final Set<Resource> sortedIntersection = new TreeSet<>(new ResourceComparator()); sortedIntersection.addAll(intersection); final TupleExpr joinTree = createJoinTree(new ArrayList<>(sortedIntersection), subVar, conVar); if (joinTree != null) { joins.add(joinTree); } } if (!joins.isEmpty()) { final TupleExpr unionTree = createUnionTree(joins); final Union union = new InferUnion(unionTree, currentNode); node.replaceWith(union); log.trace("Replacing node with inferred intersection union: " + union); } } } }
Source:
public Builder setDataForm(DataForm dataForm) { if (dataForm.getTitle() != null || dataForm.getItems().size() != 0 || dataForm.getReportedData() != null || dataForm.getInstructions().size() != 0) { throw new IllegalArgumentException("Illegal Arguements for SoftwareInformation"); } FormField field = dataForm.getHiddenFormTypeField(); if (field != null) { String value = field.getFirstValue(); if (value.equals(SoftwareInfoForm.FORM_TYPE)) { this.dataFormBuilder = dataForm.asBuilder(); return this; } else { throw new IllegalArgumentException("Malformed FORM_TYPE Formfield encountered"); } } else { throw new IllegalArgumentException("FORM_TYPE Formfield missing"); } }

Target:
public Builder setDataForm(DataForm dataForm) { if (dataForm.getTitle() != null || !dataForm.getItems().isEmpty() || dataForm.getReportedData() != null || !dataForm.getInstructions().isEmpty()) { throw new IllegalArgumentException("Illegal Arguements for SoftwareInformation"); } String formTypeValue = dataForm.getFormType(); if (formTypeValue == null) { throw new IllegalArgumentException("FORM_TYPE Formfield missing"); } if (!formTypeValue.equals(SoftwareInfoForm.FORM_TYPE)) { throw new IllegalArgumentException("Malformed FORM_TYPE Formfield encountered"); } this.dataFormBuilder = dataForm.asBuilder(); return this; }
Source:
private Image getEditorImage(StagingEntry diff) { if (diff.isSubmodule()) return SUBMODULE; Image image = DEFAULT; String name = new Path(diff.getPath()).lastSegment(); if (name != null) { ImageDescriptor descriptor = PlatformUI.getWorkbench() .getEditorRegistry().getImageDescriptor(name); image = (Image) this.resourceManager.get(descriptor); } if (diff.isSymlink()) { image = addSymlinkDecorationToImage(image); } return image; }

Target:
private Image getEditorImage(StagingEntry diff) { if (diff.isSubmodule()) return SUBMODULE; Image image = DEFAULT; String name = new Path(diff.getPath()).lastSegment(); if (name != null) { ImageDescriptor descriptor = PlatformUI.getWorkbench() .getEditorRegistry().getImageDescriptor(name); image = (Image) this.resourceManager.get(descriptor); } if (diff.isSymlink()) { try { IPath diffLocation = diff.getLocation(); if (diffLocation != null) { File diffFile = diffLocation.toFile(); if (diffFile.exists()) { String targetPath = FS.DETECTED.readSymLink(diffFile); if (targetPath != null && new File(diffFile, targetPath).isDirectory()) image = FOLDER; } } } catch (IOException e) { Activator .error(UIText.StagingViewLabelProvider_SymlinkError, e); } image = addSymlinkDecorationToImage(image); } return image; }
Source:
public void toggleCheckMode() throws Exception { if (this.isCommOpen()) { String gcode = GrblUtils.getToggleCheckModeCommand(this.grblVersion, this.grblVersionLetter); if (!"".equals(gcode)) { GcodeCommand command = createCommand(gcode); this.sendCommandImmediately(command); if (getControlState() == COMM_CHECK) { setSingleStepMode(temporaryCheckSingleStepMode); } else if (getControlState() == COMM_IDLE) { temporaryCheckSingleStepMode = getSingleStepMode(); setSingleStepMode(true); } return; } } super.toggleCheckMode(); }

Target:
public void toggleCheckMode() throws Exception { if (this.isCommOpen()) { String gcode = GrblUtils.getToggleCheckModeCommand(this.grblVersion, this.grblVersionLetter); if (!"".equals(gcode)) { GcodeCommand command = createCommand(gcode); this.sendCommandImmediately(command); return; } } super.toggleCheckMode(); }
Source:
private void updateActionAvailability() { boolean allowStart = true; boolean allowStop = true; boolean allowRemove = true; boolean allowStartRebalance = true; boolean allowOptimize = true; if (getSelectedItems() == null || getSelectedItems().size() == 0) { allowStart = false; allowStop = false; allowRemove = false; allowStartRebalance = false; allowOptimize = false; } else { allowStart = true; allowStop = true; allowRemove = true; allowStartRebalance = true; allowOptimize = true; for (GlusterVolumeEntity volume : Linq.<GlusterVolumeEntity> cast(getSelectedItems())) { if (volume.getStatus() == GlusterStatus.UP) { allowStart = false; allowRemove = false; } else if (volume.getStatus() == GlusterStatus.DOWN) { allowStop = false; allowStartRebalance = false; } } } getStartCommand().setIsExecutionAllowed(allowStart); getStopCommand().setIsExecutionAllowed(allowStop); getRemoveVolumeCommand().setIsExecutionAllowed(allowRemove); getRebalanceCommand().setIsExecutionAllowed(allowStartRebalance); getOptimizeForVirtStoreCommand().setIsExecutionAllowed(allowOptimize); boolean isAvailable = !(getSystemTreeSelectedItem() != null && getSystemTreeSelectedItem().getType() == SystemTreeItemType.Volume); getNewVolumeCommand().setIsAvailable(isAvailable); getRemoveVolumeCommand().setIsAvailable(isAvailable); }

Target:
private void updateActionAvailability() { boolean allowStart = true; boolean allowStop = true; boolean allowRemove = true; boolean allowStartRebalance = true; boolean allowOptimize = true; if (getSelectedItems() == null || getSelectedItems().size() == 0) { allowStart = false; allowStop = false; allowRemove = false; allowStartRebalance = false; allowOptimize = false; } else { for (GlusterVolumeEntity volume : Linq.<GlusterVolumeEntity> cast(getSelectedItems())) { if (volume.getStatus() == GlusterStatus.UP) { allowStart = false; allowRemove = false; } else if (volume.getStatus() == GlusterStatus.DOWN) { allowStop = false; allowStartRebalance = false; } } } getStartCommand().setIsExecutionAllowed(allowStart); getStopCommand().setIsExecutionAllowed(allowStop); getRemoveVolumeCommand().setIsExecutionAllowed(allowRemove); getRebalanceCommand().setIsExecutionAllowed(allowStartRebalance); getOptimizeForVirtStoreCommand().setIsExecutionAllowed(allowOptimize); boolean isAvailable = !(getSystemTreeSelectedItem() != null && getSystemTreeSelectedItem().getType() == SystemTreeItemType.Volume); getNewVolumeCommand().setIsAvailable(isAvailable); getRemoveVolumeCommand().setIsAvailable(isAvailable); }
Source:
private Set<ObjectId> listNonHEADIndexObjects() throws CorruptObjectException, IOException { RevWalk revWalk = null; DirCache dc = null; try { if (repo.getIndexFile() == null) return Collections.emptySet(); } catch (NoWorkTreeException e) { return Collections.emptySet(); } TreeWalk treeWalk = new TreeWalk(repo); try { dc = repo.readDirCache(); treeWalk.addTree(new DirCacheIterator(dc)); ObjectId headID = repo.resolve(Constants.HEAD); if (headID != null) { revWalk = new RevWalk(repo); treeWalk.addTree(revWalk.parseTree(headID)); revWalk.dispose(); } treeWalk.setFilter(TreeFilter.ANY_DIFF); treeWalk.setRecursive(true); Set<ObjectId> ret = new HashSet<ObjectId>(); while (treeWalk.next()) { ObjectId objectId = treeWalk.getObjectId(0); if (!ObjectId.zeroId().equals(objectId)) ret.add(objectId); } return ret; } finally { if (revWalk != null) revWalk.dispose(); treeWalk.release(); } }

Target:
private Set<ObjectId> listNonHEADIndexObjects() throws CorruptObjectException, IOException { RevWalk revWalk = null; try { if (repo.getIndexFile() == null) return Collections.emptySet(); } catch (NoWorkTreeException e) { return Collections.emptySet(); } TreeWalk treeWalk = new TreeWalk(repo); try { treeWalk.addTree(new DirCacheIterator(repo.readDirCache())); ObjectId headID = repo.resolve(Constants.HEAD); if (headID != null) { revWalk = new RevWalk(repo); treeWalk.addTree(revWalk.parseTree(headID)); revWalk.dispose(); } treeWalk.setFilter(TreeFilter.ANY_DIFF); treeWalk.setRecursive(true); Set<ObjectId> ret = new HashSet<ObjectId>(); while (treeWalk.next()) { ObjectId objectId = treeWalk.getObjectId(0); if (!ObjectId.zeroId().equals(objectId)) ret.add(objectId); } return ret; } finally { if (revWalk != null) revWalk.dispose(); treeWalk.release(); } }
Source:
public void showPictureEditor() throws Exception { uploadPopupButton.click(); waitForElementVisible(browser.driver.findElement(By.id("studentPhotoUploader"))); }

Target:
public void showPictureEditor() throws Exception { uploadPopupButton.click(); waitForElementVisibility(browser.driver.findElement(By.id("studentPhotoUploader"))); }
Source:
private SiriusDiagramEditor switchToTargetEditor(final SiriusDiagramEditor defaultEditor, final URI sessionResourceUri, URI markedDiagramDescriptorURI) { SiriusDiagramEditor targetEditor = null; DRepresentationDescriptor markedDiagramDescriptor = (DRepresentationDescriptor) defaultEditor.getDiagram().eResource().getEObject(markedDiagramDescriptorURI.fragment()); if (markedDiagramDescriptor == null) { markedDiagramDescriptor = (DRepresentationDescriptor) defaultEditor.getEditingDomain().getResourceSet().getEObject(markedDiagramDescriptorURI, true); } Option<Diagram> option = getGMFDiagramFromDRepresentationDescriptor(markedDiagramDescriptor); if (option.some()) { Diagram markerDiagram = option.get(); URI markerDiagramURI = EcoreUtil.getURI(markerDiagram); if (defaultEditor.getDiagram().equals(markerDiagram)) { targetEditor = defaultEditor; } else { URIEditorInput editorInput = null; String editorName = markedDiagramDescriptor.getName(); Session session = new EObjectQuery(markedDiagramDescriptor).getSession(); if (session != null) { editorInput = new SessionEditorInput(markerDiagramURI, editorName, session); } else { editorInput = new URIEditorInput(markerDiagramURI, editorName); } final SiriusDiagramEditor searchEditor = searchEditor(editorInput); if (searchEditor != null) { targetEditor = searchEditor; } else { targetEditor = handleClosedEditorCase(defaultEditor, sessionResourceUri, markedDiagramDescriptorURI, markerDiagram, editorInput); } } } return targetEditor; }

Target:
private SiriusDiagramEditor switchToTargetEditor(final SiriusDiagramEditor defaultEditor, final URI sessionResourceUri, URI markedDiagramDescriptorURI) { SiriusDiagramEditor targetEditor = null; DRepresentationDescriptor markedDiagramDescriptor = (DRepresentationDescriptor) defaultEditor.getDiagram().eResource().getEObject(markedDiagramDescriptorURI.fragment()); if (markedDiagramDescriptor == null) { markedDiagramDescriptor = (DRepresentationDescriptor) defaultEditor.getEditingDomain().getResourceSet().getEObject(markedDiagramDescriptorURI, true); } Optional<Diagram> optionalDiagram = getGMFDiagramFromDRepresentationDescriptor(markedDiagramDescriptor); if (optionalDiagram.isPresent()) { Diagram markerDiagram = optionalDiagram.get(); URI markerDiagramURI = EcoreUtil.getURI(markerDiagram); if (defaultEditor.getDiagram().equals(markerDiagram)) { targetEditor = defaultEditor; } else { URIEditorInput editorInput = null; String editorName = markedDiagramDescriptor.getName(); Session session = new EObjectQuery(markedDiagramDescriptor).getSession(); if (session != null) { editorInput = new SessionEditorInput(markerDiagramURI, editorName, session); } else { editorInput = new URIEditorInput(markerDiagramURI, editorName); } final SiriusDiagramEditor searchEditor = searchEditor(editorInput); if (searchEditor != null) { targetEditor = searchEditor; } else { targetEditor = handleClosedEditorCase(defaultEditor, sessionResourceUri, markedDiagramDescriptorURI, markerDiagram, editorInput); } } } return targetEditor; }
Source:
public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (!(o instanceof ICVSRemoteFolder)) return new Object[0]; ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) o; monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { getLabel(remoteFolder) }), 200); try { if (remoteFolder.getTag() != null && remoteFolder.getTag().getType() == CVSTag.BRANCH) { ICVSRemoteResource[] cachedFolders = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(remoteFolder.getRepository(), remoteFolder.getTag(), Policy.subMonitorFor(monitor, 100)); if (!hasParentInCachedFolders(cachedFolders, remoteFolder)) { return getChildrenFromCachedFolders(cachedFolders, remoteFolder, Policy.subMonitorFor(monitor, 100)); } } return ((ICVSRemoteFolder) o).members(Policy.subMonitorFor(monitor, 100)); } finally { monitor.done(); } }

Target:
public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (!(o instanceof ICVSRemoteFolder)) return new Object[0]; ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) o; if (remoteFolder.getTag() != null && remoteFolder.getTag().getType() == CVSTag.BRANCH) { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { getLabel(remoteFolder) }), 100); try { ICVSRemoteResource[] cachedFolders = CVSUIPlugin .getPlugin() .getRepositoryManager() .getFoldersForTag(remoteFolder.getRepository(), remoteFolder.getTag(), Policy.subMonitorFor(monitor, 50)); if (!hasCachedParent(cachedFolders, remoteFolder)) { return getCachedChildren(cachedFolders, remoteFolder, Policy.subMonitorFor(monitor, 50)); } return remoteFolder.members(Policy.subMonitorFor(monitor, 50)); } finally { monitor.done(); } } return remoteFolder.members(monitor); }
Source:
public void testKafkaTemplateCanBeReferencedFromSubclass() { KafkaItemWriter<String, String> kafkaItemWriter = new KafkaItemWriter<String, String>() { @Override protected void writeKeyValue(String key, String value) { this.kafkaTemplate.flush(); } }; kafkaItemWriter.setKafkaTemplate(kafkaTemplate); kafkaItemWriter.writeKeyValue("k", "v"); verify(kafkaTemplate).flush(); }

Target:
public void testKafkaTemplateCanBeReferencedFromSubclass() { KafkaItemWriter<String, String> kafkaItemWriter = new KafkaItemWriter<String, String>() { @Override protected void writeKeyValue(String key, String value) { this.kafkaTemplate.sendDefault(key, value); } }; kafkaItemWriter.setKafkaTemplate(kafkaTemplate); kafkaItemWriter.writeKeyValue("k", "v"); verify(kafkaTemplate).sendDefault("k", "v"); }
Source:
public static synchronized void startInstance(String portsConfig) { if (jmxServer == null) { if (portsConfig != null) { Iterator<Integer> ports = NetUtils.getPortRangeFromString(portsConfig); if (ports.hasNext()) { jmxServer = startJMXServerWithPortRanges(ports); } if (jmxServer == null) { LOG.error("Could not start JMx server on any configured port(s) in: " + portsConfig); } } } else { LOG.warn("JVM-wide JMXServer already started at port: " + jmxServer.getPort()); } }

Target:
public static synchronized void startInstance(String portsConfig) { if (jmxServer == null) { if (portsConfig != null) { Iterator<Integer> ports = NetUtils.getPortRangeFromString(portsConfig); if (ports.hasNext()) { jmxServer = startJMXServerWithPortRanges(ports); } if (jmxServer == null) { LOG.error("Could not start JMX server on any configured port(s) in: " + portsConfig); } } } else { LOG.warn("JVM-wide JMXServer already started at port: " + jmxServer.getPort()); } }
Source:
private void drawPreview() { JPanel pdfImagePanel = pdfDisplay.drawPreviewOnJPanel(); if(PDFDisplay.isDisableNextFlag()){ nextPageButton.setEnabled(false); } else{ nextPageButton.setEnabled(true); } if(PDFDisplay.isDisablePrevFlag()){ previousPageButton.setEnabled(false); } else{ previousPageButton.setEnabled(true); } if (pdfImagePanel != null) { JViewport vp = jScrollPane.getViewport(); Point p = vp.getViewPosition(); vp.setView(pdfImagePanel); vp.setViewPosition(p); } jLabel.setText("of " + pdfDisplay.getTotalPages()); }

Target:
private void drawPreview() { JPanel pdfImagePanel = pdfDisplay.drawPreviewOnJPanel(); if (pdfImagePanel != null) { JViewport vp = jScrollPane.getViewport(); Point p = vp.getViewPosition(); vp.setView(pdfImagePanel); vp.setViewPosition(p); } jLabel.setText("of " + pdfDisplay.getTotalPages()); }
Source:
public void consume(Context context, Event event) throws Exception { int subjectType = event.getSubjectType(); int eventType = event.getEventType(); switch (subjectType) { case Constants.ITEM: if (eventType == Event.INSTALL) { items.add((Item) event.getSubject(context)); } break; default: log.warn("consume() got unrecognized event: " + event.toString()); } }

Target:
public void consume(Context context, Event event) throws Exception { int subjectType = event.getSubjectType(); int eventType = event.getEventType(); switch (subjectType) { case Constants.ITEM: if (eventType == Event.INSTALL) { items.add((Item) event.getSubject(context)); } break; default: log.debug("consume() got unrecognized event: " + event.toString()); } }
Source:
public void run() { vertx = Vertx.vertx(); eb = vertx.eventBus(); AccountManager.create(eb, tracer); OrderLog.create(eb, tracer); InventoryManager.create(eb, tracer); Router router = Router.router(vertx); router.route(HttpMethod.POST, "/orders").handler(this::handlePlaceOrder); router.route(HttpMethod.GET, "/orders").handler(this::handleListOrders); vertx.createHttpServer().requestHandler(router::accept).listen(8080); }

Target:
public void run() { vertx = Vertx.vertx(); eb = vertx.eventBus(); AccountManager.create(eb, tracer); OrderLog.create(eb, tracer); InventoryManager.create(eb, tracer); Router router = Router.router(vertx); router.route(HttpMethod.POST, "/orders").handler(this::handlePlaceOrder); router.route(HttpMethod.GET, "/orders").handler(this::handleListOrders); vertx.createHttpServer().requestHandler(router::accept).listen(8180); }
Source:
public static <T extends TypedSPI> Optional<T> newTypedServiceInstance(final Class<T> typedServiceInterface, final String type) { Class<?> instanceClass = TYPED_SERVICE_CLASSES.containsKey(typedServiceInterface) ? TYPED_SERVICE_CLASSES.get(typedServiceInterface).get(type) : null; if (null == instanceClass) { return Optional.empty(); } return Optional.of((T) newServiceInstance(instanceClass)); }

Target:
public static <T extends TypedSPI> Optional<T> newTypedServiceInstance(final Class<T> typedServiceInterface, final String type) { return Optional.ofNullable(TYPED_SERVICE_CLASSES.get(typedServiceInterface)) .map(serviceClasses -> serviceClasses.get(type)) .map(clazz -> (T) newServiceInstance(clazz)); }
Source:
public List<String> getParameterNames(HtmlParameter.Type type) { List<String> list = new ArrayList<String>(); Model.getSingleton() .getSession() .getParameters(this, type) .forEach((nvp) -> list.add(nvp.getName())); ; return list; }

Target:
public List<String> getParameterNames(HtmlParameter.Type type) { List<String> list = new ArrayList<String>(); Model.getSingleton() .getSession() .getParameters(this, type) .forEach((nvp) -> list.add(nvp.getName())); return list; }
Source:
public void doApprovePendingScripts(@JsonBody AllSelectedHashesModel content) { Jenkins.getInstance().checkPermission(Jenkins.RUN_SCRIPTS); LOG.log(Level.FINE, "Approval granted for selected {0}", content.hashes); synchronized (this) { String userLogin = this.getCurrentUserLogin(); for (String hash : content.hashes) { approvedScriptHashes.add(hash); PendingScript pendingScript = removePendingScript(hash); if (METADATA_GATHERING) { String script = pendingScript == null ? null : pendingScript.script; this.metadataStorage.withMetadata(hash, script, metadata -> metadata.notifyApproval(pendingScript, userLogin) ); } } save(); } SecurityContext orig = ACL.impersonate(ACL.SYSTEM); try { for (ApprovalListener listener : ExtensionList.lookup(ApprovalListener.class)) { for (String hash : content.hashes) { listener.onApproved(hash); } } } finally { SecurityContextHolder.setContext(orig); } }

Target:
public void doApprovePendingScripts(@JsonBody AllSelectedHashesModel content) { Jenkins.getInstance().checkPermission(Jenkins.RUN_SCRIPTS); LOG.log(Level.FINE, "Approval granted for selected {0}", content.hashes); synchronized (this) { String userLogin = this.getCurrentUserLogin(); for (String hash : content.hashes) { approvedScriptHashes.add(hash); PendingScript pendingScript = removePendingScript(hash); if (METADATA_GATHERING) { String script = pendingScript == null ? null : pendingScript.script; this.metadataStorage.withMetadata(hash, script, metadata -> metadata.notifyApproval(pendingScript, userLogin) ); } } save(); } try (ACLContext unused = ACL.as(ACL.SYSTEM)) { for (ApprovalListener listener : ExtensionList.lookup(ApprovalListener.class)) { for (String hash : content.hashes) { listener.onApproved(hash); } } } }
Source:
public void setException(@Nullable Repository repo, Throwable err) { if (KetchReplica.log.isErrorEnabled()) { StringBuilder m = new StringBuilder(); m.append("pushAsync to "); m.append(replica.describeForLog()); m.append(" failed for:\n"); for (ReceiveCommand cmd : commands) { m.append(" "); m.append(cmd.getOldId().abbreviate(8).name()); m.append(' '); m.append(cmd.getNewId().abbreviate(8).name()); m.append(' '); m.append(cmd.getRefName()); m.append('\n'); } KetchReplica.log.error(m.toString(), err); } boolean invoke; synchronized (lock) { invoke = !done; this.exception = err; this.done = true; } if (invoke) { replica.afterPush(repo, this); } }

Target:
public void setException(@Nullable Repository repo, Throwable err) { if (KetchReplica.log.isErrorEnabled()) { StringBuilder m = new StringBuilder(); m.append("pushAsync to "); m.append(replica.describeForLog()); m.append(" failed for:\n"); for (ReceiveCommand cmd : commands) { m.append(" "); m.append(cmd.getOldId().abbreviate(8).name()); m.append(' '); m.append(cmd.getNewId().abbreviate(8).name()); m.append(' '); m.append(cmd.getRefName()); m.append('\n'); } KetchReplica.log.error(m.toString(), err); } exception = err; replica.afterPush(repo, this); }
Source:
public void testSwitchTargetVersion() throws Exception { CDOSession session = openSession(); CDOTransaction mainTx = session.openTransaction(); CDOResource resource = mainTx.createResource("test"); resource.getContents().add(createCategory("cat1")); mainTx.commit(); mainTx.close(); CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("branch"); CDOTransaction branchTx = session.openTransaction(branch); resource = branchTx.getResource("test"); resource.getContents().add(createCategory("cat2")); branchTx.commit(); resource.getContents().add(createCategory("cat3")); branchTx.commit(); branchTx.close(); session.close(); CDOSession cleanSession = openSession(); CDOView view = cleanSession.openView(); resource = view.getResource("test"); resource.getContents().size(); assertEquals(1, resource.cdoRevision().getVersion()); view.setBranch(branch); assertEquals(2, resource.cdoRevision().getVersion()); }

Target:
public void testSwitchTargetVersion() throws Exception { CDOSession session = openSession(); CDOTransaction mainTx = session.openTransaction(); String path = getResourcePath("test"); CDOResource resource = mainTx.createResource(path); resource.getContents().add(createCategory("cat1")); mainTx.commit(); mainTx.close(); CDOBranch branch = session.getBranchManager().getMainBranch().createBranch("branch"); CDOTransaction branchTx = session.openTransaction(branch); resource = branchTx.getResource(path); resource.getContents().add(createCategory("cat2")); branchTx.commit(); resource.getContents().add(createCategory("cat3")); branchTx.commit(); branchTx.close(); session.close(); CDOSession cleanSession = openSession(); CDOView view = cleanSession.openView(); resource = view.getResource(path); resource.getContents().size(); assertEquals(1, resource.cdoRevision().getVersion()); view.setBranch(branch); assertEquals(2, resource.cdoRevision().getVersion()); }
Source:
public static void createInstance() throws ServerConfigurationException, NoSuchFieldException, IllegalAccessException { carbonServerConfiguration = ServerConfiguration.getInstance(); resourceURL = CarbonBaseUtilsTest.class.getClassLoader().getResource("carbon.xml"); assertFalse(getIsInitialized(carbonServerConfiguration, "isInitialized")); InputStream inputStream = readFile("carbon.xml"); carbonServerConfiguration.forceInit(inputStream); assertTrue(getIsInitialized(carbonServerConfiguration, "isInitialized")); }

Target:
public void createInstance() throws ServerConfigurationException, NoSuchFieldException, IllegalAccessException { assertFalse(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized")); InputStream inputStream = readFile("carbon.xml"); ServerConfiguration.getInstance().forceInit(inputStream); assertTrue(getIsInitialized(ServerConfiguration.getInstance(), "isInitialized")); }
Source:
private List<File> getAllPossibleExternalConfigDirFilenames(final File configdir, final List<String> profiles) { val fileNames = new ArrayList<File>(); for (val appName: getApplicationNames()) { for (val ext: EXTENSIONS) { fileNames.add(new File(configdir, String.format("%s.%s", appName, ext))); } } for (val profile: profiles) { for (val ext: EXTENSIONS) { fileNames.add(new File(configdir, String.format("application-%s.%s", profile, ext))); fileNames.add(new File(configdir, String.format("%s.%s", profile, ext))); } } return fileNames; }

Target:
private List<File> getAllPossibleExternalConfigDirFilenames(final File configdir, final List<String> profiles) { val fileNames = getApplicationNames() .stream() .flatMap(appName -> EXTENSIONS .stream() .map(ext -> new File(configdir, String.format("%s.%s", appName, ext)))) .collect(Collectors.toList()); fileNames.addAll(profiles .stream() .flatMap(profile -> EXTENSIONS .stream() .flatMap(ext -> PROFILE_PATTERNS .stream().map(pattern -> new File(configdir, String.format(pattern, profile, ext))))).collect(Collectors.toList())); return fileNames; }
Source:
public static ActionInvocation loadInvocation(String key, String token) { InvocationContext invocationContext = (InvocationContext) getInvocationMap().get(key); if ((invocationContext == null) || !invocationContext.token.equals(token)) { return null; } final ActionInvocation savedInvocation = invocationContext.invocation; if (savedInvocation != null) { final ActionContext savedActionContext = savedInvocation.getInvocationContext(); final ActionContext previousActionContext = ActionContext.getContext(); ActionContext.bound(savedActionContext); savedActionContext.setValueStack(savedInvocation.getStack()); if (previousActionContext != null) { savedActionContext.setPageContext(previousActionContext.getPageContext()); } else { savedActionContext.setPageContext(null); } } return savedInvocation; }

Target:
public static ActionInvocation loadInvocation(String key, String token) { InvocationContext invocationContext = (InvocationContext) getInvocationMap().get(key); if ((invocationContext == null) || !invocationContext.token.equals(token)) { return null; } final ActionInvocation savedInvocation = invocationContext.invocation; if (savedInvocation != null) { final ActionContext previousActionContext = ActionContext.getContext(); savedInvocation .getInvocationContext() .withPageContext(previousActionContext.getPageContext()) .withValueStack(savedInvocation.getStack()) .bind(); } return savedInvocation; }
Source:
public void createTimeZoneList() { String[] ids = SimpleTimeZone.getAvailableIDs(); for (String id : ids) { TimeZone zone = TimeZone.getTimeZone(id); int offset = zone.getRawOffset() / 1000; int hour = offset / 3600; int minutes = (offset % 3600) / 60; String item = String.format("(GMT%+d:%02d) %s", hour, minutes, id); timeZoneComboBox.addItem(item); } TimeZone thisTimeZone = Calendar.getInstance().getTimeZone(); int thisOffset = thisTimeZone.getRawOffset() / 1000; int thisHour = thisOffset / 3600; int thisMinutes = (thisOffset % 3600) / 60; String formatted = String.format("(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID()); timeZoneComboBox.setSelectedItem(formatted); }

Target:
private void createTimeZoneList() { String[] ids = SimpleTimeZone.getAvailableIDs(); for (String id : ids) { TimeZone zone = TimeZone.getTimeZone(id); int offset = zone.getRawOffset() / 1000; int hour = offset / 3600; int minutes = (offset % 3600) / 60; String item = String.format("(GMT%+d:%02d) %s", hour, minutes, id); timeZoneComboBox.addItem(item); } TimeZone thisTimeZone = Calendar.getInstance().getTimeZone(); int thisOffset = thisTimeZone.getRawOffset() / 1000; int thisHour = thisOffset / 3600; int thisMinutes = (thisOffset % 3600) / 60; String formatted = String.format("(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID()); timeZoneComboBox.setSelectedItem(formatted); }
Source:
public void testExecute_getProfileOfUnregisteredStudent_shouldReturnNotFoundMessage() { StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1"); StudentAttributes unregisteredStudentInCourse1 = StudentAttributes.builder(student1InCourse1.getCourse(), "student1InUnregisteredCourse@gmail.tmt") .withGoogleId("") .withName("unregistered student in course 1") .withComment("") .withSectionName(student1InCourse1.getSection()) .withTeamName(student1InCourse1.getTeam()) .build(); typicalBundle.students.put("unregisteredStudentInCourse1", unregisteredStudentInCourse1); removeAndRestoreTypicalDataBundle(); removeAndRestoreDataBundle(typicalBundle); String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, unregisteredStudentInCourse1.getEmail(), Const.ParamsNames.COURSE_ID, unregisteredStudentInCourse1.getCourse(), }; loginAsStudent(student1InCourse1.getGoogleId()); GetStudentProfileAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); assertEquals(HttpStatus.SC_NOT_FOUND, result.getStatusCode()); }

Target:
public void testExecute_getProfileOfUnregisteredStudent_shouldReturnNotFoundMessage() throws Exception { StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1"); StudentAttributes unregisteredStudentInCourse1 = StudentAttributes.builder(student1InCourse1.getCourse(), "student1InUnregisteredCourse@gmail.tmt") .withGoogleId("") .withName("unregistered student in course 1") .withComment("") .withSectionName(student1InCourse1.getSection()) .withTeamName(student1InCourse1.getTeam()) .build(); StudentsLogic.inst().createStudent(unregisteredStudentInCourse1); String[] submissionParams = new String[] { Const.ParamsNames.STUDENT_EMAIL, unregisteredStudentInCourse1.getEmail(), Const.ParamsNames.COURSE_ID, unregisteredStudentInCourse1.getCourse(), }; loginAsStudent(student1InCourse1.getGoogleId()); GetStudentProfileAction action = getAction(submissionParams); JsonResult result = getJsonResult(action); assertEquals(HttpStatus.SC_NOT_FOUND, result.getStatusCode()); }
Source:
public boolean verified(Payload payload, SessionWrapper session) { try { return permissionAPI.doesUserHavePermission((Permissionable) payload.getData(), Integer.parseInt(payload.getVisibilityId()), session.getUser(), false); } catch (DotDataException e) { throw new BaseRuntimeInternationalizationException(e); } }

Target:
public boolean verified(Payload payload, SessionWrapper session) { try { return permissionAPI.doesUserHavePermission((Permissionable) payload.getData(), Integer.parseInt(payload.getVisibilityId()), session.getUser(), false); } catch (DotDataException e) { throw new VerifierException(e); } }
Source:
public byte[] receiveDatagram() throws OpenEnergyMonitorException { if (in == null) { connect(); } byte[] buffer = new byte[100]; StringBuilder sb = new StringBuilder(); int len = -1; try { while ((len = this.in.read(buffer)) > 0) { for (int i = 0; i < len; i++) { logger.trace("Received char: {}", buffer[i]); if (buffer[i] != 0x0A) { if (buffer[i] != 0x0D) { sb.append((char) buffer[i]); } } else { return parseLine(sb.toString()); } } } } catch (IOException e) { throw new OpenEnergyMonitorException("Error occured while receiving data", e); } return null; }

Target:
public byte[] receiveDatagram() throws OpenEnergyMonitorException { if (in == null) { connect(); } byte[] buffer = new byte[100]; StringBuilder sb = new StringBuilder(); int len = -1; try { while ((len = this.in.read(buffer)) > 0) { for (int i = 0; i < len; i++) { logger.trace("Received char: {}", buffer[i]); if (buffer[i] != 0x0A) { if (buffer[i] != 0x0D) { sb.append((char) buffer[i]); } } else { return parseLine(sb.toString()); } } } } catch (IOException e) { throw new OpenEnergyMonitorException("Error occurred while receiving data. ", e); } return null; }