auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testBinaryWithNotGenericInterceptor() throws Exception { IgniteConfiguration ccfg = Config.getServerConfiguration() .setCacheConfiguration(new CacheConfiguration("test").setInterceptor(new ThinBinaryValueInterceptor())); String castErr = "cannot be cast to"; String treeErr = "Tree is corrupted"; ListeningTestLogger srvLog = new ListeningTestLogger(log); LogListener lsnrCast = LogListener.matches(castErr). andMatches(str -> !str.contains(treeErr)).build(); srvLog.registerListener(lsnrCast); ccfg.setGridLogger(srvLog); try (Ignite ignored = Ignition.start(ccfg)) { try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)) ) { ClientCache<Integer, ThinBinaryValue> cache = client.cache("test"); try { <START> cache.put(1, new ThinBinaryValue()); <END> } catch (Exception e) { assertTrue(X.getFullStackTrace(e).contains(castErr)); } } } }</code><technical_language>is exception, this test fail check anything. Please insert assert false, of GridTestUtils.assertThrows helpers</technical_language>

Target:
public void testBinaryWithNotGenericInterceptor() throws Exception { IgniteConfiguration ccfg = Config.getServerConfiguration() .setCacheConfiguration(new CacheConfiguration("test").setInterceptor(new ThinBinaryValueInterceptor())); String castErr = "cannot be cast to"; String treeErr = "Tree is corrupted"; ListeningTestLogger srvLog = new ListeningTestLogger(log); LogListener lsnrCast = LogListener.matches(castErr). andMatches(str -> !str.contains(treeErr)).build(); srvLog.registerListener(lsnrCast); ccfg.setGridLogger(srvLog); try (Ignite ignored = Ignition.start(ccfg)) { try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER)) ) { ClientCache<Integer, ThinBinaryValue> cache = client.cache("test"); try { cache.put(1, new ThinBinaryValue()); assert false; } catch (Exception e) { assertTrue(X.getFullStackTrace(e).contains(castErr)); } } } }
Source:
<code>public void sendHitResult( int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd ) { int hitResult = handleHitResult(time, result, x, y, color, end, hitObject, hitResultType, repeat, (curve != null && !sliderHeldToEnd)); if (hitResult == HIT_MISS && (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) return; boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled(); <START> if (GameMod.PERFECT.isActive() && (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K)) { <END> hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else { health.setHealth(0f); } }</code><technical_language>Oops! I a derp here, fix in a short while</technical_language>

Target:
public void sendHitResult( int time, int result, float x, float y, Color color, boolean end, HitObject hitObject, HitObjectType hitResultType, boolean expand, int repeat, Curve curve, boolean sliderHeldToEnd ) { int hitResult = handleHitResult(time, result, x, y, color, end, hitObject, hitResultType, repeat, (curve != null && !sliderHeldToEnd)); if (hitResult == HIT_MISS && (GameMod.RELAX.isActive() || GameMod.AUTOPILOT.isActive())) return; boolean hideResult = (hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) && !Options.isPerfectHitBurstEnabled(); if (GameMod.PERFECT.isActive() && hitResult == HIT_300 || hitResult == HIT_300G || hitResult == HIT_300K) { hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else if (!GameMod.PERFECT.isActive()) { hitResultList.add(new HitObjectResult(time, hitResult, x, y, color, hitResultType, curve, expand, hideResult)); } else { health.setHealth(0f); } }
Source:
<code>private Answer executeRequest(TrashNetworkVspCommand cmd) { try { isNuageVspGuruLoaded(); _nuageVspGuruClient.trash(cmd.getDomainUuid(), cmd.getNetworkUuid(), cmd.isL3Network(), cmd.isSharedNetwork(), cmd.getVpcUuid(), cmd.getDomainTemplateName()); return new TrashNetworkVspAnswer(cmd, true, "Deleted Nuage VSP network mapping to " + cmd.getNetworkUuid()); <START> } catch (Exception e) { <END> s_logger.error("Failure during " + cmd, e); return new TrashNetworkVspAnswer(cmd, e); } }</code><technical_language>unchecked checked exceptions caught? catching expected checked exceptions, allow unchecked exceptions simply bubble out</technical_language>

Target:
private Answer executeRequest(TrashNetworkVspCommand cmd) { try { isNuageVspGuruLoaded(); _nuageVspGuruClient.trash(cmd.getDomainUuid(), cmd.getNetworkUuid(), cmd.isL3Network(), cmd.isSharedNetwork(), cmd.getVpcUuid(), cmd.getDomainTemplateName()); return new Answer(cmd, true, "Deleted network mapping to " + cmd.getNetworkUuid() + " on Nuage VSD " + _hostName); } catch (ExecutionException | ConfigurationException e) { s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e); return new Answer(cmd, e); } }
Source:
<code>protected IStatus run(IProgressMonitor monitor) { try { SessionNegotiation.Status status = negotiation.start(monitor); switch (status) { case CANCEL: return Status.CANCEL_STATUS; case ERROR: NotificationPanel.showError( MessageFormat.format( Messages.NegotiationHandler_session_local_error_message, negotiation.getErrorMessage()), Messages.NegotiationHandler_session_local_error_title); return new Status( IStatus.ERROR, SarosComponent.PLUGIN_ID, negotiation.getErrorMessage()); case OK: break; case REMOTE_CANCEL: NotificationPanel.showInformation( MessageFormat.format( Messages.NegotiationHandler_remote_canceled_invitation_text, peer), Messages.NegotiationHandler_remote_canceled_invitation); <START> <END> return new Status( IStatus.CANCEL, SarosComponent.PLUGIN_ID, MessageFormat.format( Messages.NegotiationHandler_remote_canceled_invitation_text, peer)); case REMOTE_ERROR: NotificationPanel.showError( MessageFormat.format( Messages.NegotiationHandler_remote_error_during_invitation_text, peer, negotiation.getErrorMessage()), Messages.NegotiationHandler_remote_error_during_invitation); return new Status( IStatus.ERROR, SarosComponent.PLUGIN_ID, MessageFormat.format( Messages.NegotiationHandler_remote_error_during_invitation_text, peer, negotiation.getErrorMessage())); } } catch (Exception e) { LOG.error("This exception is not expected here: ", e); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, e.getMessage(), e); } sessionManager.startSharingProjects(negotiation.getPeer()); return Status.OK_STATUS; }</code><technical_language>Duplicated code. declare: String title, message top of method assign values. This is easier read generate message e.g 2 times in this section</technical_language>

Target:
protected IStatus run(IProgressMonitor monitor) { try { SessionNegotiation.Status status = negotiation.start(monitor); String message; switch (status) { case CANCEL: return Status.CANCEL_STATUS; case ERROR: message = MessageFormat.format( Messages.NegotiationHandler_session_local_error_message, negotiation.getErrorMessage()); NotificationPanel.showError( message, Messages.NegotiationHandler_session_local_error_title); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, message); case OK: break; case REMOTE_CANCEL: message = MessageFormat.format( Messages.NegotiationHandler_session_remote_cancel_message, peer); NotificationPanel.showInformation( message, Messages.NegotiationHandler_session_remote_cancel_title); return new Status(IStatus.CANCEL, SarosComponent.PLUGIN_ID, message); case REMOTE_ERROR: message = MessageFormat.format( Messages.NegotiationHandler_session_remote_error_message, peer, negotiation.getErrorMessage()); NotificationPanel.showError( message, Messages.NegotiationHandler_session_remote_error_title); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, message); } } catch (Exception e) { LOG.error("This exception is not expected here: ", e); return new Status(IStatus.ERROR, SarosComponent.PLUGIN_ID, e.getMessage(), e); } sessionManager.startSharingProjects(negotiation.getPeer()); return Status.OK_STATUS; }
Source:
<code>public void multifilePartial() throws Exception { <START> String expected = DeclarationGeneratorTests.getTestFileText(input("singleton.d.ts")); <END> assertThatProgram( ImmutableList.of(input("missing_imported_base.js")), ImmutableList.of(input("named_base_exporter.js"), input("default_base_exporter.js"))) .generatesDeclarations(expected); }</code><technical_language>nitpicing name: 'singleton' in a java code base bring unwanted associations. 'total', new word for clutz mode</technical_language>

Target:
public void multifilePartial() throws Exception { String expected = DeclarationGeneratorTests.getTestFileText(input("total.d.ts")); assertThatProgram( ImmutableList.of(input("missing_imported_base.js")), ImmutableList.of(input("named_base_exporter.js"), input("default_base_exporter.js"))) .generatesDeclarations(expected); }
Source:
<code>public void listsDocs() throws IOException { final Bucket bucket = this.mockBucket("lists", "lists-exists"); <START> final List<String> expected = Lists.newArrayList(bucket.list("")); <END> final List<String> names = new AwsDocs(bucket).names(); MatcherAssert.assertThat(names, Matchers.equalTo(expected)); MatcherAssert.assertThat(names, Matchers.hasItem("sub/test")); }</code><technical_language>this inlined for step-by-step :(</technical_language>

Target:
public void listsDocs() throws IOException { final String label = "lists"; final String name = "lists-exists"; final Bucket bucket = this.mockBucket(label, name); final List<String> expected = Arrays.asList(name, "sub/file"); final List<String> names = new AwsDocs(bucket, label).names(); MatcherAssert.assertThat(names, Matchers.equalTo(expected)); }
Source:
<code>private void flatDelete(PDOMLinkage linkage) throws CoreException { <START> linkage.storeValue(record + DEFAULTVAL, null); <END> super.delete(linkage); }</code><technical_language>Yes</technical_language>

Target:
private void flatDelete(PDOMLinkage linkage) throws CoreException { super.delete(linkage); }
Source:
<code>public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung) throws IOException { Project project = process.getProject(); URI tifOrdner = getImagesTifDirectory(true, process); if (fileService.fileExist(tifOrdner) && fileService.getSubUris(tifOrdner).size() > 0) { URI zielTif = userHome.resolve(File.separator + atsPpnBand + ordnerEndung); if (project.isUseDmsImport()) { if (!fileService.fileExist(zielTif)) { fileService.createDirectory(userHome, atsPpnBand + ordnerEndung); } } else { User user = Helper.getCurrentUser(); try { if (user != null) { fileService.createDirectoryForUser(zielTif, user.getLogin()); } else { <START> throw new IOException("noLoggedUser"); <END> } } catch (Exception e) { Helper.setFehlerMeldung("Export canceled, error", "could not create destination directory"); logger.error("could not create destination directory", e); } } ArrayList<URI> dateien = fileService.getSubUris(Helper.dataFilter, tifOrdner); for (URI file : dateien) { if (fileService.isFile(file)) { URI target = zielTif.resolve(File.separator + fileService.getFileNameWithExtension(file)); fileService.copyFile(file, target); } } } }</code><technical_language>exception messages translatable translated now</technical_language>

Target:
public void imageDownload(Process process, URI userHome, String atsPpnBand, final String ordnerEndung) throws IOException { Project project = process.getProject(); URI tifOrdner = getImagesTifDirectory(true, process); if (fileService.fileExist(tifOrdner) && fileService.getSubUris(tifOrdner).size() > 0) { URI zielTif = userHome.resolve(File.separator + atsPpnBand + ordnerEndung); if (project.isUseDmsImport()) { if (!fileService.fileExist(zielTif)) { fileService.createDirectory(userHome, atsPpnBand + ordnerEndung); } } else { User user = Helper.getCurrentUser(); try { if (user != null) { fileService.createDirectoryForUser(zielTif, user.getLogin()); } else { throw new IOException("No logged user!"); } } catch (Exception e) { Helper.setFehlerMeldung("Export canceled, error", "could not create destination directory"); logger.error("could not create destination directory", e); } } ArrayList<URI> dateien = fileService.getSubUris(Helper.dataFilter, tifOrdner); for (URI file : dateien) { if (fileService.isFile(file)) { URI target = zielTif.resolve(File.separator + fileService.getFileNameWithExtension(file)); fileService.copyFile(file, target); } } } }
Source:
<code>public boolean validate(Object value, Object context) { if (validation) { <START> MutableBoolean validated = new MutableBoolean(); <END> resolve(value, context, (session, docRef) -> { if (session.exists(docRef)) { validated.setTrue(); } }); return validated.isTrue(); } return true; }</code><technical_language>Please introduce extra indentation do early exit: if (!validation) { return true; } // original code This diff easier read</technical_language>

Target:
public boolean validate(Object value, Object context) { if (!validation) { return true; } MutableBoolean validated = new MutableBoolean(); resolve(value, context, (session, docRef) -> { if (session.exists(docRef)) { validated.setTrue(); } }); return validated.isTrue(); }
Source:
<code>public void testCreateMultipleElementsAndCloseWithoutSaving() { <START> <END> assertTrue(diagram.getOwnedDiagramElements().isEmpty()); for (int i = 0; i < 35; i++) { editor.activateTool("Package"); editor.click(new Point(2, 2)); SWTBotUtils.waitAllUiEvents(); } SWTBotSiriusHelper.close(editor, true); bot.waitUntilWidgetAppears(Conditions.shellIsActive("Save")); final SWTBotShell uncontrolShell = bot.shell("Save"); uncontrolShell.activate(); SWTBotButton no = bot.button("No"); bot.waitUntilWidgetAppears(new ItemEnabledCondition(no)); no.click(); SWTBotUtils.waitAllUiEvents(); diagram = (DDiagram) getRepresentationWithName(localSession.getOpenedSession(), ENTITIES_DESC_NAME, "root" + " package entities"); assertEquals("The diagram should be empty", 0, diagram.getDiagramElements().size()); }</code><technical_language>Useless line</technical_language>

Target:
public void testCreateMultipleElementsAndCloseWithoutSaving() { assertEquals("The diagram should be empty", 0, diagram.getOwnedDiagramElements().size()); for (int i = 0; i < 35; i++) { editor.activateTool("Package"); editor.click(new Point(2, 2)); SWTBotUtils.waitAllUiEvents(); } SWTBotSiriusHelper.close(editor, true); bot.waitUntilWidgetAppears(Conditions.shellIsActive("Save")); final SWTBotShell uncontrolShell = bot.shell("Save"); uncontrolShell.activate(); SWTBotButton no = bot.button("No"); bot.waitUntilWidgetAppears(new ItemEnabledCondition(no)); no.click(); SWTBotUtils.waitAllUiEvents(); diagram = (DDiagram) getRepresentationWithName(localSession.getOpenedSession(), ENTITIES_DESC_NAME, "root" + " package entities"); assertEquals("The diagram should be empty after having closed without saving.", 0, diagram.getDiagramElements().size()); }
Source:
<code>public void close() { try { closer.close(); } catch (IOException e) { <START> throw Throwables.propagate(e); <END> } }</code><technical_language>simply new RuntimeException(e)</technical_language>

Target:
public void close() { try { closer.close(); } catch (IOException e) { throw new RuntimeException(e); } }
Source:
<code>void visitLeafNode(final ObjectNode parent, final Path.Element element) throws ScimException { JsonNode node = parent.path(element.getAttribute()); if(! node.isMissingNode()) { <START> setPathPresent(true); <END> } }</code><technical_language>if path contains a filter? this check element matches filter is present? (If need functionality for Spring release, I guess leave out for now.)</technical_language>

Target:
void visitLeafNode(final ObjectNode parent, final Path.Element element) throws ScimException { JsonNode node = parent.path(element.getAttribute()); if(node.isArray() && element.getValueFilter() != null) { node = filterArray((ArrayNode) node, element.getValueFilter(), false); } if(node.isArray()) { if(((ArrayNode)node).size() > 0) { setPathPresent(true); } } else if(! node.isMissingNode()) { setPathPresent(true); } }
Source:
<code>protected void sendEvent(CoreSession session, DocumentRef ref, Calendar retainUntil) { DocumentModel doc = session.getDocument(ref); DocumentEventContext ctx = new DocumentEventContext(session, null, doc); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); ctx.setProperty("category", DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.RETAIN_UNTIL, retainUntil); ctx.setProperty("comment", retainUntil.toInstant().toString()); <START> Event event = ctx.newEvent(DocumentEventTypes.RETENTION_EXPIRED); <END> Framework.getService(EventService.class).fireEvent(event); }</code><technical_language>this trigger elastic reindex</technical_language>

Target:
protected void sendEvent(CoreSession session, DocumentRef ref, Calendar retainUntil) { DocumentModel doc = session.getDocument(ref); DocumentEventContext ctx = new DocumentEventContext(session, null, doc); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); ctx.setProperty(DocumentEventContext.CATEGORY_PROPERTY_KEY, DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.RETAIN_UNTIL, retainUntil); ctx.setProperty(DocumentEventContext.COMMENT_PROPERTY_KEY, retainUntil.toInstant().toString()); Event event = ctx.newEvent(DocumentEventTypes.RETENTION_EXPIRED); Framework.getService(EventService.class).fireEvent(event); }
Source:
<code>public void process(IQ reqIQ) throws Exception { try { String node = federatedQueueManager.getRelatedNodeForRemotePacket(reqIQ); federatedQueueManager.passResponseToRequester(reqIQ.createCopy()); Element pubsub = reqIQ.getChildElement(); List<Element> elements = pubsub.elements(); boolean handled = false; for (Element x : elements) { for (PubSubElementProcessorAbstract elementProcessor : elementProcessors) { if (elementProcessor.accept(x)) { if (null != node) { elementProcessor.setNode(node); } elementProcessor.process(x, null, reqIQ, x); handled = true; } } } if (handled) { return; } } catch (UnknownFederatedPacketException e) { LOGGER.error(e); } if (!"result".equals(reqIQ.getType().toString())) { sendUnexpectedRequestResponse(reqIQ); <START> } <END> }</code><technical_language>change this to: java if (!reqIQ.getType().equals(IQ.Type.Result)) {</technical_language>

Target:
public void process(IQ reqIQ) throws Exception { try { String node = federatedQueueManager.getRelatedNodeForRemotePacket(reqIQ); federatedQueueManager.passResponseToRequester(reqIQ.createCopy()); Element pubsub = reqIQ.getChildElement(); List<Element> elements = pubsub.elements(); boolean handled = false; for (Element x : elements) { for (PubSubElementProcessorAbstract elementProcessor : elementProcessors) { if (elementProcessor.accept(x)) { if (null != node) { elementProcessor.setNode(node); } elementProcessor.process(x, null, reqIQ, x); handled = true; } } } if (handled) { return; } } catch (UnknownFederatedPacketException e) { LOGGER.error(e); } if (IQ.Type.result != reqIQ.getType()) { sendUnexpectedRequestResponse(reqIQ); } }
Source:
<code>public Object getSinglePropertyValue() { assert propertyValues.values().length == 1; <START> return propertyValues.values()[0]; <END> }</code><technical_language>provide method get single method in helper class</technical_language>

Target:
public Object getSinglePropertyValue() { return propertyValues.getSinglePropertyValue(); }
Source:
<code>public void testServerDisconnect() throws Exception { String connectionId = "testServerDisconnect_Hello"; blockingConnect(connectionId); assertEquals("hello", blockingRequest(connectionId, "hello")); this.server.closeConnections(); while (!selector.disconnected().contains(connectionId)) { <START> selector.poll(1000L); <END> } connectionId = "testServerDisconnect_Hello2"; blockingConnect(connectionId); assertEquals("hello", blockingRequest(connectionId, "hello")); }</code><technical_language>again</technical_language>

Target:
public void testServerDisconnect() throws Exception { String connectionId = blockingConnect(); assertEquals("hello", blockingRequest(connectionId, "hello")); this.server.closeConnections(); while (!selector.disconnected().contains(connectionId)) { selector.poll(1000L); } connectionId = blockingConnect(); assertEquals("hello", blockingRequest(connectionId, "hello")); }
Source:
<code>public void testImagesDoesNotExist() { <START> DiskImage diskImage1 = getNewDiskImage(); DiskImage diskImage2 = getNewDiskImage(); List<DiskImage> diskImagesFromParams = new ArrayList<>(); diskImagesFromParams.addAll(Arrays.asList(diskImage1, diskImage2)); Set<Guid> guidsForDiskImages = diskImagesFromParams.stream() .map(DiskImage::getId) .collect(Collectors.toSet()); <END> cmd.getParameters().setDisks(guidsForDiskImages); doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISKS_NOT_EXIST)).when(diskImagesValidator) .diskImagesNotExist(guidsForDiskImages); ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.ACTION_TYPE_FAILED_DISKS_NOT_EXIST); }</code><technical_language>do need of this? Set<Guid> guidsForDiskImages = new HashSet<>(Arrays.asList(Guid.newGuid(), Guid.newGuid()));</technical_language>

Target:
public void testImagesDoesNotExist() { DiskImage diskImage1 = getNewDiskImage(); DiskImage diskImage2 = getNewDiskImage(); List<DiskImage> diskImagesFromParams = new ArrayList<>(); diskImagesFromParams.addAll(Arrays.asList(diskImage1, diskImage2)); Set<Guid> guidsForDiskImages = new HashSet<>(Arrays.asList(Guid.newGuid(), Guid.newGuid())); cmd.getParameters().setDisks(guidsForDiskImages); doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISKS_NOT_EXIST)).when(diskExistenceValidator).diskImagesNotExist(); ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.ACTION_TYPE_FAILED_DISKS_NOT_EXIST); }
Source:
<code>protected abstract boolean exists() throws IOException; protected abstract ByteBuffer fileBytes() throws IOException; protected abstract ByteBuffer welcomeBytes() throws IOException; protected abstract ByteBuffer directoryListingBytes() throws IOException; protected ByteBuffer formatFileListAsHtml(File[] files) throws IOException { StringBuilder builder = new StringBuilder(); for (File file : files) { builder .append("<li><a href=\"") .append(file.getName()) .append("\">") .append(file.getName()) <START> .append("</a></li>"); <END> } String formattedString = String.format(DIRECTORY_LISTING_FORMAT_STRING, builder.toString()); byte[] formattedBytes = formattedString.getBytes(); ByteArrayInputStream inputStream = new ByteArrayInputStream(formattedBytes); return read(formattedBytes.length, inputStream); }</code><technical_language>DANGER: Possibility of Cross Site Scripting attack. For example, able upload a file called malicious JavaScript in filename. file name escaped inserted HTML</technical_language>

Target:
protected abstract boolean exists() throws IOException; protected abstract boolean isDirectory() throws IOException; protected abstract ByteBuffer fileBytes() throws IOException; protected abstract ByteBuffer welcomeBytes() throws IOException; protected abstract ByteBuffer directoryListingBytes() throws IOException; protected ByteBuffer read(int length, InputStream in) throws IOException { return AbstractResourceHandler.consumeInputStreamToByteBuffer(length, in); }
Source:
<code>public ListFragment(String id, List<ISfMenuItem> items) { super(id, "list-fragment", SfMenu.this); this.add(new ListView<ISfMenuItem>("items", items) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ISfMenuItem> item) { ISfMenuItem menuItem = item.getModelObject(); SfMenu.this.map.put(menuItem.getId(), menuItem); item.add(new ItemFragment("item", menuItem)); item.add(new MenuFragment("menu", menuItem.getItems())); <START> item.add(AttributeModifier.replace("id", menuItem.getId())); <END> if (!menuItem.isEnabled()) { item.add(AttributeModifier.append("class", Model.of("ui-state-disabled"))); } } }); }</code><technical_language>Is a need set id manually ? chance for duplicate id is higher this way</technical_language>

Target:
public ListFragment(String id, List<ISfMenuItem> items) { super(id, "list-fragment", SfMenu.this); this.add(new ListView<ISfMenuItem>("items", items) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<ISfMenuItem> item) { ISfMenuItem menuItem = item.getModelObject(); if(menuItem.isEnabled()) { item.add(new ItemLinkFragment("item", menuItem)); item.add(new MenuFragment("menu", menuItem.getItems())); } else { item.add(new ItemDisableFragment("item", menuItem)); item.add(new EmptyPanel("menu")); } } }); }
Source:
<code>public DocumentModel newDocumentModel(DocumentRef parentRef, String name, String typeName) { if (parentRef == null && name == null) { return createDocumentModel(typeName); } String parentPath = null; if (parentRef != null) { <START> parentPath = resolveReference(parentRef).getPath(); <END> } Map<String, Serializable> options = new HashMap<>(); options.put(CoreEventConstants.PARENT_PATH, parentPath); options.put(CoreEventConstants.DOCUMENT_MODEL_ID, name); options.put(CoreEventConstants.DESTINATION_NAME, name); DocumentModel model = createDocumentModelByParentAndType(parentRef, typeName, options); model.setPathInfo(parentPath, name); return model; }</code><technical_language>I prefer String parentPath = parentRef == null ? null : resolveReference(parentRef).getPath();</technical_language>

Target:
public DocumentModel newDocumentModel(DocumentRef parentRef, String name, String typeName) { if (parentRef == null && name == null) { return createDocumentModel(typeName); } String parentPath = parentRef == null ? null : resolveReference(parentRef).getPath(); Map<String, Serializable> options = new HashMap<>(); options.put(CoreEventConstants.PARENT_PATH, parentPath); options.put(CoreEventConstants.DOCUMENT_MODEL_ID, name); options.put(CoreEventConstants.DESTINATION_NAME, name); DocumentModel model = createDocumentModelFromParentAndType(parentRef, typeName, options); model.setPathInfo(parentPath, name); return model; }
Source:
<code><START> void updateGlobalPieChart() { <END> if (getGlobalPC() == null) { fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); getGlobalPC().getLegend().setVisible(true); getGlobalPC().getLegend().setPosition(SWT.RIGHT); getGlobalPC().addListener(SWT.MouseMove, fMouseListener); } else if (getGlobalPC().isDisposed() || fModel == null || fModel.getPieChartGlobalModel() == null) { return; } Map<String, Long> totalEventCountForChart = getTotalEventCountForChart(true); if(totalEventCountForChart == null){ return; } updatePieChartWithData(fGlobalPC, totalEventCountForChart, MIN_PRECENTAGE_TO_SHOW_SLICE, fOthersSliceName); }</code><technical_language>needs synchronized</technical_language>

Target:
synchronized void updateGlobalPieChart() { if (getGlobalPC() == null) { fGlobalPC = new PieChart(this, SWT.NONE); getGlobalPC().getTitle().setText(fGlobalPCname); getGlobalPC().getAxisSet().getXAxis(0).getTitle().setText(""); getGlobalPC().getLegend().setVisible(true); getGlobalPC().getLegend().setPosition(SWT.RIGHT); getGlobalPC().addListener(SWT.MouseMove, fMouseListener); } else if (getGlobalPC().isDisposed() || fModel == null || fModel.getPieChartGlobalModel() == null) { return; } Map<String, Long> totalEventCountForChart = getTotalEventCountForChart(true); if(totalEventCountForChart == null){ return; } updatePieChartWithData(fGlobalPC, totalEventCountForChart, MIN_PRECENTAGE_TO_SHOW_SLICE, fOthersSliceName); }
Source:
<code>public SWTBotMenu contextMenu(int row, int col, String text) throws WidgetNotFoundException { assertIsLegalCell(row, col); <START> assertNotNull(text); <END> waitForEnabled(); rightClick(row, col); return NatTableContextMenuFinder.contextMenu(widget, text); }</code><technical_language>mixing assert swt.finder assert junit. Is OK</technical_language>

Target:
public SWTBotMenu contextMenu(int row, int col, String text) throws WidgetNotFoundException { assertIsLegalCell(row, col); Assert.isNotNull(text); waitForEnabled(); rightClick(row, col); return NatTableContextMenuFinder.contextMenu(widget, text); }
Source:
<code>public ExecutionResult executeInVR(String routerIP, String script, String args, Duration timeout) { Pair<Boolean, String> result; if (s_logger.isDebugEnabled()) { s_logger.debug("Run command on VR: " + routerIP + ", script: " + script + " with args: " + args); } try { VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); result = SshHelper.sshExecute(routerIP, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/" + script + " " + args, <START> 60000, 60000, (int)timeout.getMillis()); <END> } catch (Exception e) { String msg = "Command failed due to " + VmwareHelper.getExceptionMessage(e); s_logger.error(msg); result = new Pair<Boolean, String>(false, msg); } if (s_logger.isDebugEnabled()) { s_logger.debug(script + " execution result: " + result.first().toString()); } return new ExecutionResult(result.first(), result.second()); }</code><technical_language>Please consider adding overridden version of SshHelper.sshExecute(String, int, String, String, ??, String, int, int, int) method accepts Duration encapsulate this type conversion</technical_language>

Target:
public ExecutionResult executeInVR(String routerIP, String script, String args, Duration timeout) { Pair<Boolean, String> result; if (s_logger.isDebugEnabled()) { s_logger.debug("Run command on VR: " + routerIP + ", script: " + script + " with args: " + args); } try { VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); result = SshHelper.sshExecute(routerIP, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/" + script + " " + args, VRScripts.CONNECTION_TIMEOUT, VRScripts.CONNECTION_TIMEOUT, timeout); } catch (Exception e) { String msg = "Command failed due to " + VmwareHelper.getExceptionMessage(e); s_logger.error(msg); result = new Pair<Boolean, String>(false, msg); } if (s_logger.isDebugEnabled()) { s_logger.debug(script + " execution result: " + result.first().toString()); } return new ExecutionResult(result.first(), result.second()); }
Source:
<code>protected Map<Object, Object> getCacheByType(Object type) { if (allResourcesMap != null) { Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap != null) { return resourcesMap; } } <START> return Collections.<Object, Object> emptyMap(); <END> }</code><technical_language><Object, Object> necessary</technical_language>

Target:
protected Map<Object, Object> getCacheByType(Object type) { if (allResourcesMap != null) { Map<Object, Object> resourcesMap = allResourcesMap.get(type); if (resourcesMap != null) { return resourcesMap; } } return Collections.emptyMap(); }
Source:
<code>private MethodSpec(Builder builder) { CodeBlock code = builder.code.build(); checkArgument(!(builder.modifiers.contains(Modifier.ABSTRACT) <START> && hasDefaultModifier(builder.modifiers)), <END> "abstract method %s cannot be default", builder.name); checkArgument(code.isEmpty() || !builder.modifiers.contains(Modifier.ABSTRACT) || hasDefaultModifier(builder.modifiers), "abstract method %s cannot have code", builder.name); checkArgument(!builder.varargs || lastParameterIsArray(builder.parameters), "last parameter of varargs method %s must be an array", builder.name); this.name = checkNotNull(builder.name, "name == null"); this.javadoc = builder.javadoc.build(); this.annotations = Util.immutableList(builder.annotations); this.modifiers = Util.immutableSet(builder.modifiers); this.typeVariables = Util.immutableList(builder.typeVariables); this.returnType = builder.returnType; this.parameters = Util.immutableList(builder.parameters); this.varargs = builder.varargs; this.exceptions = Util.immutableList(builder.exceptions); this.defaultValue = builder.defaultValue; this.code = code; }</code><technical_language>builder.modifiers.contains(Modifier.DEFAULT)</technical_language>

Target:
private MethodSpec(Builder builder) { CodeBlock code = builder.code.build(); checkArgument(code.isEmpty() || !builder.modifiers.contains(Modifier.ABSTRACT), "abstract method %s cannot have code", builder.name); checkArgument(!builder.varargs || lastParameterIsArray(builder.parameters), "last parameter of varargs method %s must be an array", builder.name); this.name = checkNotNull(builder.name, "name == null"); this.javadoc = builder.javadoc.build(); this.annotations = Util.immutableList(builder.annotations); this.modifiers = Util.immutableSet(builder.modifiers); this.typeVariables = Util.immutableList(builder.typeVariables); this.returnType = builder.returnType; this.parameters = Util.immutableList(builder.parameters); this.varargs = builder.varargs; this.exceptions = Util.immutableList(builder.exceptions); this.defaultValue = builder.defaultValue; this.code = code; }
Source:
<code>protected SelectRootNodeWizardPage(TmfExperimentElement experiment) { super(""); <START> setTitle(Messages.SelectRootNodeWizardPage_WindowTitle); <END> setDescription(Messages.SelectRootNodeWizardPage_Description); fExperiment = experiment; }</code><technical_language>this is overridable in createcontrol</technical_language>

Target:
protected SelectRootNodeWizardPage(TmfExperimentElement experiment) { super(""); fExperiment = experiment; }
Source:
<code>public void writeObject(ObjectOutput output, EncoderValueMapper object) throws IOException { <START> output.writeObject(object.encodingClasses); <END> }</code><technical_language>decoder necessary in</technical_language>

Target:
public void writeObject(ObjectOutput output, EncoderValueMapper object) throws IOException { EncodingClasses.writeTo(output, object.encodingClasses); }
Source:
<code>private void executeVariable(VariableTree variableTree, @Nullable Tree terminator) { if (variableTree.initializer() == null) { SymbolicValue sv = null; if (terminator != null && terminator.is(Tree.Kind.FOR_EACH_STATEMENT)) { sv = constraintManager.createSymbolicValue(variableTree); } else if (variableTree.parent().is(Tree.Kind.CATCH)) { SymbolicValue thrownSV = getCaughtException(variableTree.symbol().type()); <START> sv = new SymbolicValue() { <END> @Override public SymbolicValue wrappedValue() { return thrownSV; } }; programState = programState.addConstraint(sv, ObjectConstraint.NOT_NULL); } if (sv != null) { programState = programState.put(variableTree.symbol(), sv); } } else { ProgramState.Pop unstack = programState.unstackValue(1); programState = unstack.state; programState = programState.put(variableTree.symbol(), unstack.values.get(0)); } }</code><technical_language>I dedicated static class for this type of symbolic value, avoid capturing implicit reference outer ExplodedGraphWalker . I prefer override wrappedValue provide specific method for this purpose. constraintManager symbolic factory mechanism create instance of SV</technical_language>

Target:
private void executeVariable(VariableTree variableTree, @Nullable Tree terminator) { if (variableTree.initializer() == null) { SymbolicValue sv = null; if (terminator != null && terminator.is(Tree.Kind.FOR_EACH_STATEMENT)) { sv = constraintManager.createSymbolicValue(variableTree); } else if (variableTree.parent().is(Tree.Kind.CATCH)) { sv = handleCatchVariable(variableTree.symbol().type()); programState = programState.clearStack(); programState = programState.addConstraint(sv, ObjectConstraint.NOT_NULL); } if (sv != null) { programState = programState.put(variableTree.symbol(), sv); } } else { ProgramState.Pop unstack = programState.unstackValue(1); programState = unstack.state; programState = programState.put(variableTree.symbol(), unstack.values.get(0)); } }
Source:
<code>public File exportAPIOrAPIProductArchive(ApiTypeWrapper apiTypeWrapper, boolean isStatusPreserved, ExportFormat exportFormat) throws APIImportExportException { String archiveBasePath; if (!apiTypeWrapper.isAPIProduct()) { APIIdentifier apiIdentifier = apiTypeWrapper.getApi().getId(); archiveBasePath = exportAPIArtifacts(apiTypeWrapper.getApi(), isStatusPreserved, exportFormat); <START> log.info("API" + apiIdentifier.getApiName() + "-" + apiIdentifier.getVersion() + " exported successfully"); <END> } else { APIProductIdentifier apiProductIdentifier = apiTypeWrapper.getApiProduct().getId(); archiveBasePath = exportAPIProductArtifacts(apiTypeWrapper.getApiProduct(), isStatusPreserved, exportFormat); log.info("API Product" + apiProductIdentifier.getName() + "-" + apiProductIdentifier.getVersion() + " exported successfully"); } CommonUtil.archiveDirectory(archiveBasePath); FileUtils.deleteQuietly(new File(archiveBasePath)); return new File(archiveBasePath + APIConstants.ZIP_FILE_EXTENSION); }</code><technical_language>Do need this info log? this "debug"</technical_language>

Target:
public File exportAPIOrAPIProductArchive(ApiTypeWrapper apiTypeWrapper, boolean isStatusPreserved, ExportFormat exportFormat) throws APIImportExportException { String archiveBasePath; if (!apiTypeWrapper.isAPIProduct()) { APIIdentifier apiIdentifier = apiTypeWrapper.getApi().getId(); archiveBasePath = exportAPIArtifacts(apiTypeWrapper.getApi(), isStatusPreserved, exportFormat); if (log.isDebugEnabled()) { log.debug("API" + apiIdentifier.getApiName() + "-" + apiIdentifier.getVersion() + " exported successfully"); } } else { APIProductIdentifier apiProductIdentifier = apiTypeWrapper.getApiProduct().getId(); archiveBasePath = exportAPIProductArtifacts(apiTypeWrapper.getApiProduct(), isStatusPreserved, exportFormat); if (log.isDebugEnabled()) { log.info("API Product" + apiProductIdentifier.getName() + "-" + apiProductIdentifier.getVersion() + " exported successfully"); } } CommonUtil.archiveDirectory(archiveBasePath); FileUtils.deleteQuietly(new File(archiveBasePath)); return new File(archiveBasePath + APIConstants.ZIP_FILE_EXTENSION); }
Source:
<code>public void testActual() { Subscriber<Integer> actual = new Subscriber<Integer>() { @Override public void onNext(Integer t) { } @Override public void onError(Throwable e) { } @Override public void onCompleted() { } }; SafeSubscriber<Integer> s = new SafeSubscriber<Integer>(actual); <START> assertEquals(actual, s.getActual()); <END> }</code><technical_language>assertSame() instead of assertEquals()</technical_language>

Target:
public void testActual() { Subscriber<Integer> actual = new Subscriber<Integer>() { @Override public void onNext(Integer t) { } @Override public void onError(Throwable e) { } @Override public void onCompleted() { } }; SafeSubscriber<Integer> s = new SafeSubscriber<Integer>(actual); assertSame(actual, s.getActual()); }
Source:
<code>protected List<Name> getLogNames(LogManager manager, String names) { if (ALL_LOGS.equalsIgnoreCase(names)) { return manager.listAll(); } <START> List<Name> ret = Arrays.asList(names.split(",")).stream().map(Name::ofUrn).collect(Collectors.toList()); <END> for (Name name : ret) { if (!manager.exists(name)) { throw new IllegalArgumentException("Unknown log name: " + name); } } return ret; }</code><technical_language>Stream#of instead of Arrays.asList().stream()</technical_language>

Target:
protected List<Name> getLogNames(LogManager manager, String names) { if (ALL_LOGS.equalsIgnoreCase(names)) { return manager.listAllNames(); } List<Name> ret = Arrays.stream(names.split(",")).map(Name::ofUrn).collect(Collectors.toList()); for (Name name : ret) { if (!manager.exists(name)) { throw new IllegalArgumentException("Unknown log name: " + name); } } return ret; }
Source:
<code>void register(TriggerType triggerType, Action<ListViewActionContext> action) { ListViewAction viewAction = new ListViewAction(triggerType, action); <START> actionMap.put(triggerType, viewAction); <END> actionList.add(viewAction); }</code><technical_language>is this actionMap anywhere? is put data</technical_language>

Target:
void register(TriggerType triggerType, Action<ListViewActionContext> action) { assertValidAction(triggerType); ListViewAction viewAction = new ListViewAction(triggerType, action); actionMap.put(triggerType, viewAction); actionList.add(viewAction); }
Source:
<code>public static final GlusterBrickEntity getBrickByQualifiedName(List<GlusterBrickEntity> bricksList, String qualifiedBrickName) { for (GlusterBrickEntity brick : bricksList) { if ((brick.getServerName() + ":" + brick.getBrickDirectory()).equals(qualifiedBrickName) <START> || (brick.getNetworkAddress() + ":" + brick.getBrickDirectory()).equals(qualifiedBrickName)) { <END> return brick; } } return null; }</code><technical_language>this is getQualifiedName() method of Brick entity does</technical_language>

Target:
public static final GlusterBrickEntity getBrickByQualifiedName(List<GlusterBrickEntity> bricksList, String qualifiedBrickName) { for (GlusterBrickEntity brick : bricksList) { if (brick.getQualifiedName().equals(qualifiedBrickName)) { return brick; } } return null; }
Source:
<code>public static void main(String[] args) throws Exception { String idpEndpoint = "https://IDP-HOST:IDP-PORT/auth/realms/master/protocol/openid-connect/token"; String clientId = "IDP-CLIENT-ID"; String clientSecret = "IDP-CLIENT-SECRET"; String stsEndpoint = "http://STS-HOST:STS-PORT/"; Provider provider = new ClientGrantsProvider( () -> getJwt(clientId, clientSecret, idpEndpoint), stsEndpoint, null, <START> null, END> null); MinioClient minioClient = MinioClient.builder() .endpoint("https://MINIO-HOST:MINIO-PORT") .credentialsProvider(provider) .build(); StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build()); System.out.println(stat); }</code><technical_language>String policy = null; line no.79 change needed</technical_language>

Target:
public static void main(String[] args) throws Exception { String idpEndpoint = "https://IDP-HOST:IDP-PORT/auth/realms/master/protocol/openid-connect/token"; String clientId = "IDP-CLIENT-ID"; String clientSecret = "IDP-CLIENT-SECRET"; String stsEndpoint = "http://STS-HOST:STS-PORT/"; String policy = null; Provider provider = new ClientGrantsProvider( () -> getJwt(clientId, clientSecret, idpEndpoint), stsEndpoint, null, policy, null); MinioClient minioClient = MinioClient.builder() .endpoint("https://MINIO-HOST:MINIO-PORT") .credentialsProvider(provider) .build(); StatObjectResponse stat = minioClient.statObject( StatObjectArgs.builder().bucket("my-bucketname").object("my-objectname").build()); System.out.println(stat); }
Source:
<code>private void initializeWriter(StoreConfiguration cfg, CacheWriter writer, InitializationContextImpl ctx) { if (writer != null) { <START> if (writer instanceof DelegatingCacheWriter) <END> writer.init(ctx); if (writer instanceof TransactionalCacheWriter && cfg.transactional()) txWriters.add((TransactionalCacheWriter) writer); else writers.add(writer); configMap.put(writer, cfg); } }</code><technical_language>this for example a singleton writer participate in transaction added txWriters below</technical_language>

Target:
private void initializeWriter(StoreConfiguration cfg, CacheWriter writer, InitializationContextImpl ctx) { if (writer != null) { if (writer instanceof DelegatingCacheWriter) writer.init(ctx); if (undelegate(writer) instanceof TransactionalCacheWriter && cfg.transactional()) { if (configuration.transaction().transactionMode().isTransactional()) { txWriters.add((TransactionalCacheWriter) writer); } else { nonTxWriters.add(writer); } } else { nonTxWriters.add(writer); } configMap.put(writer, cfg); } }
Source:
<code>protected void initProcessor(StreamProcessorDescriptor descriptor) { if (processors.containsKey(descriptor.getId())) { log.error("Processor already initialized: {}", descriptor.getId()); return; } log.info("Init Stream processor: with manager: ", descriptor.getId(), descriptor.config); LogManager manager = getLogManager(descriptor.config); Topology topology; try { topology = descriptor.klass.getDeclaredConstructor().newInstance().getTopology(descriptor.options); } catch (ReflectiveOperationException e) { throw new StreamRuntimeException("Can not create topology for processor: " + descriptor.getId(), e); } StreamProcessor streamProcessor = new LogStreamProcessor(manager); Settings settings = getSettings(descriptor); <START> log.debug("Starting computation topology: {}\n", descriptor::getId, () -> topology.toPlantuml(settings)); <END> streamProcessor.init(topology, settings); processors.put(descriptor.getId(), streamProcessor); }</code><technical_language>Missing {}</technical_language>

Target:
protected void initProcessor(StreamProcessorDescriptor descriptor) { if (processors.containsKey(descriptor.getId())) { log.error("Processor already initialized: {}", descriptor.getId()); return; } log.info("Init Stream processor: with manager: {}", descriptor.getId(), descriptor.config); LogManager manager = getLogManager(descriptor.config); Topology topology; try { topology = descriptor.klass.getDeclaredConstructor().newInstance().getTopology(descriptor.options); } catch (ReflectiveOperationException e) { throw new StreamRuntimeException("Can not create topology for processor: " + descriptor.getId(), e); } StreamProcessor streamProcessor = new LogStreamProcessor(manager); Settings settings = getSettings(descriptor); log.debug("Starting computation topology: {}\n{}", descriptor::getId, () -> topology.toPlantuml(settings)); streamProcessor.init(topology, settings); processors.put(descriptor.getId(), streamProcessor); }
Source:
<code>private void executeBatchActions( final User user, final WorkflowAction action, final ConcurrentMap<String, Object> actionsContext, final BiConsumer<List<?>, Exception> failsConsumer) throws DotDataException { final List<WorkflowActionClass> actionClasses = this.findActionClasses(action); for (final WorkflowActionClass actionClass : actionClasses) { final WorkFlowActionlet actionlet = actionClass.getActionlet(); if (actionlet instanceof BatchAction) { final Map<String, WorkflowActionClassParameter> params = findParamsForActionClass(actionClass); final BatchAction batchAction = BatchAction.class.cast(actionlet); final List <?> objects = batchAction.getObjectsForBatch(actionsContext, actionClass); try { batchAction.executeBatchAction(user, actionsContext, actionClass, params); } catch (Exception e) { <START> failsConsumer.accept(objects, e); <END> Logger.error(getClass(), String.format("Exception while Trying to execute action %s, in batch", actionClass.getName() ), e ); } } } }</code><technical_language>If a batch action fails continue rest of batch actions</technical_language>

Target:
private void executeBatchActions( final User user, final WorkflowAction action, final ConcurrentMap<String, Object> actionsContext, final BiConsumer<List<?>, Exception> failsConsumer) throws DotDataException { final List<WorkflowActionClass> actionClasses = this.findActionClasses(action); for (final WorkflowActionClass actionClass : actionClasses) { final WorkFlowActionlet actionlet = actionClass.getActionlet(); if (actionlet instanceof BatchAction) { final Map<String, WorkflowActionClassParameter> params = findParamsForActionClass(actionClass); final BatchAction batchAction = BatchAction.class.cast(actionlet); final List <?> objects = batchAction.getObjectsForBatch(actionsContext, actionClass); try { batchAction.executeBatchAction(user, actionsContext, actionClass, params); } catch (Exception e) { failsConsumer.accept(objects, e); Logger.error(getClass(), String.format("Exception while Trying to execute action %s, in batch", actionClass.getName() ), e ); break; } } } }