auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void runAnalysisAndUpdateMarkers(@Nullable Server server, Map<ISonarLintFile, IDocument> docPerFiles, final IProgressMonitor monitor, Map<String, String> mergedExtraProps, List<ClientInputFile> inputFiles, Path analysisWorkDir) throws CoreException { StandaloneAnalysisConfiguration config; IPath projectLocation = getProject().getResource().getLocation(); Path projectBaseDir = projectLocation != null ? projectLocation.toFile().toPath() : analysisWorkDir; if (server != null) { SonarLintLogger.get().debug("Connected mode (using configuration of '" + getProjectConfig().getModuleKey() + "' in server '" + getProjectConfig().getServerId() + "')"); config = new ConnectedAnalysisConfiguration(trimToNull(getProjectConfig().getModuleKey()), projectBaseDir, getProject().getWorkingDir(), inputFiles, mergedExtraProps); } else { SonarLintLogger.get().debug("Standalone mode (project not bound)"); config = new StandaloneAnalysisConfiguration(projectBaseDir, getProject().getWorkingDir(), inputFiles, mergedExtraProps); } Map<ISonarLintIssuable, List<Issue>> issuesPerResource = new LinkedHashMap<>(); filesToAnalyze.keySet().forEach(slFile -> issuesPerResource.put(slFile, new ArrayList<>())); long start = System.currentTimeMillis(); AnalysisResults result = run(server, config, issuesPerResource, monitor); if (!monitor.isCanceled() && result != null) { <START> updateTelemetry(inputFiles, start); <END> updateMarkers(server, docPerFiles, issuesPerResource, result, triggerType, monitor); } }</code><technical_language>Is intended count marker processing in analysis time? IMO count</technical_language>

Target:
private void runAnalysisAndUpdateMarkers(@Nullable Server server, Map<ISonarLintFile, IDocument> docPerFiles, final IProgressMonitor monitor, Map<String, String> mergedExtraProps, List<ClientInputFile> inputFiles, Path analysisWorkDir) throws CoreException { StandaloneAnalysisConfiguration config; IPath projectLocation = getProject().getResource().getLocation(); Path projectBaseDir = projectLocation != null ? projectLocation.toFile().toPath() : analysisWorkDir; if (server != null) { SonarLintLogger.get().debug("Connected mode (using configuration of '" + getProjectConfig().getModuleKey() + "' in server '" + getProjectConfig().getServerId() + "')"); config = new ConnectedAnalysisConfiguration(trimToNull(getProjectConfig().getModuleKey()), projectBaseDir, getProject().getWorkingDir(), inputFiles, mergedExtraProps); } else { SonarLintLogger.get().debug("Standalone mode (project not bound)"); config = new StandaloneAnalysisConfiguration(projectBaseDir, getProject().getWorkingDir(), inputFiles, mergedExtraProps); } Map<ISonarLintIssuable, List<Issue>> issuesPerResource = new LinkedHashMap<>(); filesToAnalyze.keySet().forEach(slFile -> issuesPerResource.put(slFile, new ArrayList<>())); long start = System.currentTimeMillis(); AnalysisResults result = run(server, config, issuesPerResource, monitor); if (!monitor.isCanceled() && result != null) { updateMarkers(server, docPerFiles, issuesPerResource, result, triggerType, monitor); updateTelemetry(inputFiles, start); } }
Source:
<code>public void choiceParameterIssue() throws Exception { try (MockSCMController c = MockSCMController.create()) { c.createRepository("foo"); BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo"); prj.setCriteria(null); BranchSource source = new BranchSource(new MockSCMSource(c, "foo", new MockSCMDiscoverBranches())); ParameterDefinitionBranchPropertyImpl instance = new ParameterDefinitionBranchPropertyImpl(); instance.setParameterDefinitions(Collections.<ParameterDefinition>singletonList( new ChoiceParameterDefinition("CHOOSE", new String[] { "a", "b" }, "choose one") )); source.setStrategy(new DefaultBranchPropertyStrategy(new BranchProperty[]{ instance, new BasicDummyStepBranchProperty() })); prj.getSourcesList().add(source); <START> r.configRoundtrip(prj); <END> assertThat(prj.getSources().get(0).getStrategy(), instanceOf(DefaultBranchPropertyStrategy.class)); DefaultBranchPropertyStrategy strategy = (DefaultBranchPropertyStrategy) prj.getSources().get(0).getStrategy(); assertThat(strategy.getProps().get(0), instanceOf(ParameterDefinitionBranchPropertyImpl.class)); ParameterDefinitionBranchPropertyImpl property = (ParameterDefinitionBranchPropertyImpl) strategy.getProps().get(0); assertThat(property.getParameterDefinitions(), contains( allOf( instanceOf(ChoiceParameterDefinition.class), hasProperty("name", is("CHOOSE")), hasProperty("choices", is(Arrays.asList("a", "b"))), hasProperty("description", is("choose one")) ) )); } }</code><technical_language>Is this test fails</technical_language>

Target:
public void choiceParameterIssue() throws Exception { assumeThat(Jenkins.getVersion(), greaterThanOrEqualTo(new VersionNumber("2.242"))); try (MockSCMController c = MockSCMController.create()) { c.createRepository("foo"); BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo"); prj.setCriteria(null); BranchSource source = new BranchSource(new MockSCMSource(c, "foo", new MockSCMDiscoverBranches())); ParameterDefinitionBranchPropertyImpl instance = new ParameterDefinitionBranchPropertyImpl(); instance.setParameterDefinitions(Collections.<ParameterDefinition>singletonList( new ChoiceParameterDefinition("CHOOSE", new String[] { "a", "b" }, "choose one") )); source.setStrategy(new DefaultBranchPropertyStrategy(new BranchProperty[]{ instance, new BasicDummyStepBranchProperty() })); prj.getSourcesList().add(source); r.configRoundtrip(prj); assertThat(prj.getSources().get(0).getStrategy(), instanceOf(DefaultBranchPropertyStrategy.class)); DefaultBranchPropertyStrategy strategy = (DefaultBranchPropertyStrategy) prj.getSources().get(0).getStrategy(); assertThat(strategy.getProps().get(0), instanceOf(ParameterDefinitionBranchPropertyImpl.class)); ParameterDefinitionBranchPropertyImpl property = (ParameterDefinitionBranchPropertyImpl) strategy.getProps().get(0); assertThat(property.getParameterDefinitions(), contains( allOf( instanceOf(ChoiceParameterDefinition.class), hasProperty("name", is("CHOOSE")), hasProperty("choices", is(Arrays.asList("a", "b"))), hasProperty("description", is("choose one")) ) )); } }
Source:
<code>public void onNodeDragDrop(TreeDragDropEvent event) { int dropIndex = event.getDropIndex(); DocStructInterface dropDocStruct = (DocStructInterface) event.getDropNode().getData(); DocStructInterface dragDocStruct = (DocStructInterface) event.getDragNode().getData(); if (event.getDropNode().getParent().getData().equals("root")) { Helper.setFehlerMeldung("Only one root element allowed"); } else { if (dropDocStruct.isDocStructTypeAllowedAsChild(dragDocStruct.getDocStructType())) { this.docStruct = dragDocStruct; this.docStruct.getParent().removeChild(dragDocStruct); try { addNewDocStructToExistingDocStruct(dropDocStruct, dragDocStruct, dropIndex); } catch (TypeNotAllowedAsChildException e) { <START> logger.error(e.getMessage(), e); <END> Helper.setFehlerMeldung(e.getMessage()); } } else { Helper.setFehlerMeldung( dragDocStruct.getDocStructType() + " ot allowed as child of " + dropDocStruct.getDocStructType()); } } }</code><technical_language>setErrorMessage</technical_language>

Target:
public void onNodeDragDrop(TreeDragDropEvent event) { int dropIndex = event.getDropIndex(); DocStructInterface dropDocStruct = (DocStructInterface) event.getDropNode().getData(); DocStructInterface dragDocStruct = (DocStructInterface) event.getDragNode().getData(); if (event.getDropNode().getParent().getData().equals("root")) { Helper.setFehlerMeldung("Only one root element allowed"); } else { if (dropDocStruct.isDocStructTypeAllowedAsChild(dragDocStruct.getDocStructType())) { this.docStruct = dragDocStruct; this.docStruct.getParent().removeChild(dragDocStruct); try { addNewDocStructToExistingDocStruct(dropDocStruct, dragDocStruct, dropIndex); } catch (TypeNotAllowedAsChildException e) { Helper.setErrorMessage(e.getMessage(), logger, e); } } else { Helper.setFehlerMeldung( dragDocStruct.getDocStructType() + " not allowed as child of " + dropDocStruct.getDocStructType()); } } }
Source:
<code>public void run() { <START> ACL.impersonate(ACL.SYSTEM); <END> super.run(); }</code><technical_language>ACL.impersonate(ACL.SYSTEM); set thread context SYSTEM "forever" normal pattern is ACL.SYSTEM.impersonate(new Runnable() { public void run() { ... } });</technical_language>

Target:
public void run() { SecurityContext old = ACL.impersonate(ACL.SYSTEM); try { super.run(); } finally { SecurityContextHolder.setContext(old); } }
Source:
<code>public List<Span> getChildren(String tenant, String id) { <START> return null; <END> }</code><technical_language>null -> UnsupportedOperationException</technical_language>

Target:
public List<Span> getChildren(String tenant, String id) { throw new UnsupportedOperationException(); }
Source:
<code>public static boolean filteredEquals(EObject property, EObject other, EStructuralFeature... filteredFeatures) { if (property == null) { return other == null; } if (other == null) { return false; } if (property.eClass() != other.eClass()) { return false; } final List<EStructuralFeature> filter = Arrays.asList(filteredFeatures); for (final EStructuralFeature esf : <START> property.eClass().getEStructuralFeatures()) <END> { if (filter.contains(esf)) { continue; } if (!equalFeature(property, other, esf)) { return false; } } return true; }</code><technical_language>Afaik this returns features defined in EClass. This missed features parent-EClasses. I getEAllStructuralFeatures instead</technical_language>

Target:
public static boolean filteredEquals(EObject property, EObject other, EStructuralFeature... filteredFeatures) { if (property == null) { return other == null; } if (other == null) { return false; } if (property.eClass() != other.eClass()) { return false; } final List<EStructuralFeature> filter = Arrays.asList(filteredFeatures); for (final EStructuralFeature esf : property.eClass().getEAllStructuralFeatures()) { if (filter.contains(esf)) { continue; } if (!equalFeature(property, other, esf)) { return false; } } return true; }
Source:
<code>public AboutDialogContents(ProductInfo info, ProductEditionInfo editionInfo) { initWidget(uiBinder.createAndBindUi(this)); <START> versionLabel.setText(info.version + "for " + info.os); <END> productInfo.getElement().setId("productinfo"); gplLinkLabel.getElement().setId("gplLinkLabel"); Roles.getLinkRole().setAriaDescribedbyProperty(gplLink.getElement(), Id.of(gplLinkLabel.getElement())); userAgentLabel.setText( Window.Navigator.getUserAgent()); buildLabel.setText( "\"" + info.release_name + "\" (" + info.commit.substring(0, 8) + ", " + info.date + ")"); productName.setText(editionInfo.editionName()); copyrightYearLabel.setText("2009-" + info.copyright_year); showNoticelink_.setClickHandler(() -> { RStudioGinjector.INSTANCE.getServer().getProductNotice(new ServerRequestCallback<ProductNotice>() { @Override public void onResponseReceived(ProductNotice notice) { AboutOpenSourceDialog about = new AboutOpenSourceDialog(notice); about.showModal(); } @Override public void onError(ServerError error) { Debug.logError(error); } }); }); if (editionInfo.proLicense()) { gplNotice.setVisible(false); if (Desktop.hasDesktopFrame()) { licenseBox.setVisibleLines(3); licenseLabel.setVisible(true); licenseBox.setVisible(true); licenseBox.setText("Loading..."); Desktop.getFrame().getLicenseStatusMessage(licenseStatus -> { licenseBox.setText(licenseStatus); }); } } }</code><technical_language>I making part of version number emphasize more is necessary. put in build info release name commit hash</technical_language>

Target:
public AboutDialogContents(ProductInfo info, ProductEditionInfo editionInfo) { initWidget(uiBinder.createAndBindUi(this)); versionLabel.setText(info.version); productInfo.getElement().setId("productinfo"); gplLinkLabel.getElement().setId("gplLinkLabel"); Roles.getLinkRole().setAriaDescribedbyProperty(gplLink.getElement(), Id.of(gplLinkLabel.getElement())); userAgentLabel.setText( Window.Navigator.getUserAgent()); buildLabel.setText( "\"" + info.release_name + "\" (" + info.commit.substring(0, 8) + ", " + info.date + ") for " + info.os); productName.setText(editionInfo.editionName()); copyrightYearLabel.setText("2009-" + info.copyright_year); showNoticelink_.setClickHandler(() -> { RStudioGinjector.INSTANCE.getServer().getProductNotice(new ServerRequestCallback<ProductNotice>() { @Override public void onResponseReceived(ProductNotice notice) { AboutOpenSourceDialog about = new AboutOpenSourceDialog(notice); about.showModal(); } @Override public void onError(ServerError error) { Debug.logError(error); } }); }); if (editionInfo.proLicense()) { gplNotice.setVisible(false); if (Desktop.hasDesktopFrame()) { licenseBox.setVisibleLines(3); licenseLabel.setVisible(true); licenseBox.setVisible(true); licenseBox.setText("Loading..."); Desktop.getFrame().getLicenseStatusMessage(licenseStatus -> { licenseBox.setText(licenseStatus); }); } } }
Source:
<code>public String evaluate(TransactionContext txnCtx, Input[] args) { assert args.length >= 2 : "number of args must be 2 or 3"; if (args[0].value() == null) { return null; } if (args[1].value() == null) { <START> return (String) args[0].value(); <END> } LpadRpadFunctionImplHelper helper = new LpadRpadFunctionImplHelper(args); helper.pad(); helper.copyString(); return helper.getRet().toString(); }</code><technical_language>need avoid multiple calls Input functions multiple evaluations of expressions. This add kill performance</technical_language>

Target:
public String evaluate(TransactionContext txnCtx, Input[] args) { assert args.length >= 2 : "number of args must be 2 or 3"; String toPad = (String) args[0].value(); Number length = (Number) args[1].value(); if (toPad == null) { return null; } if (length == null) { return toPad; } String filler = null; if (args.length == 3) { filler = (String) args[2].value(); } int len = length.intValue(); final String fillerChars = (filler == null) ? " " : filler; int fillerLen = fillerChars.length(); if (len < 0) { return ""; } if (toPad.length() > len) { return toPad.substring(0, len); } if (fillerLen <= 0) { return toPad; } int toPadLen = len - toPad.length(); StringBuilder ret = new StringBuilder(len); Collections.nCopies(toPadLen / fillerLen, fillerLen) .forEach(n -> ret.append(fillerChars)); ret.append(fillerChars.substring(0, toPadLen % fillerLen)); ret.append(toPad); return ret.toString(); }
Source:
<code>private boolean deQueueAction(ContainerPlacementRequestMessage requestMessage) { if (checkIfActiveOrStandbyContainerHasActivePlacementAction(requestMessage)) { <START> return false; } if (samzaApplicationState.failedProcessors.containsKey(requestMessage.getProcessorId())) { return true; <END> } if (!samzaApplicationState.runningProcessors.containsKey(requestMessage.getProcessorId()) || samzaApplicationState.pendingProcessors.containsKey(requestMessage.getProcessorId())) { LOG.info("ContainerPlacement request: is en-queued because container is pending start", requestMessage); return false; } return true; }</code><technical_language>Log statements needed</technical_language>

Target:
private boolean deQueueAction(ContainerPlacementRequestMessage requestMessage) { if (checkIfActiveOrStandbyContainerHasActivePlacementAction(requestMessage)) { return false; } if (samzaApplicationState.failedProcessors.containsKey(requestMessage.getProcessorId())) { LOG.info("ContainerPlacement request: is de-queued, container with Processor ID: has exhausted all retries and is in failed state", requestMessage, requestMessage.getProcessorId()); return true; } if (!samzaApplicationState.runningProcessors.containsKey(requestMessage.getProcessorId()) || samzaApplicationState.pendingProcessors.containsKey(requestMessage.getProcessorId())) { LOG.info("ContainerPlacement request: is en-queued because container is pending start", requestMessage); return false; } return true; }
Source:
<code>public StackWalker.StackFrame apply(Stream<StackWalker.StackFrame> stackFrameStream) { boolean foundFqcn = false; <START> Object[] frames = stackFrameStream.toArray(); <END> for (int i = 0; i < frames.length ; ++i) { final String className = ((StackWalker.StackFrame) frames[i]).getClassName(); if (!foundFqcn) { foundFqcn = className.equals(fqcn); } else if (!className.equals(fqcn)) { return (StackWalker.StackFrame) frames[i]; } } return null; }</code><technical_language>Is this more expensive for logging occurs a large stack</technical_language>

Target:
public StackWalker.StackFrame apply(Stream<StackWalker.StackFrame> stackFrameStream) { String fqcn = FQCN.get(); boolean foundFqcn = false; Object[] frames = stackFrameStream.toArray(); for (int i = 0; i < frames.length ; ++i) { final String className = ((StackWalker.StackFrame) frames[i]).getClassName(); if (!foundFqcn) { foundFqcn = className.equals(fqcn); } else if (!className.equals(fqcn)) { return (StackWalker.StackFrame) frames[i]; } } return null; }
Source:
<code>public <T extends LwM2mResponse> T send(final Registration destination, final DownlinkRequest<T> request, Long timeout) throws InterruptedException { <START> if (destination.getLwM2mQueue().isClientSleeping()) { <END> return null; } final LwM2mModel model = modelProvider.getObjectModel(destination); CoapRequestBuilder coapRequestBuilder = new CoapRequestBuilder( new InetSocketAddress(destination.getAddress(), destination.getPort()), destination.getRootPath(), destination.getId(), destination.getEndpoint(), model, encoder); request.accept(coapRequestBuilder); final Request coapRequest = coapRequestBuilder.getRequest(); SyncRequestObserver<T> syncMessageObserver = new SyncRequestObserver<T>(coapRequest, timeout) { @Override public T buildResponse(Response coapResponse) { LwM2mResponseBuilder<T> lwm2mResponseBuilder = new LwM2mResponseBuilder<>(coapRequest, coapResponse, destination, model, observationService, decoder); request.accept(lwm2mResponseBuilder); return lwm2mResponseBuilder.getResponse(); } }; coapRequest.addMessageObserver(syncMessageObserver); addPendingRequest(destination, coapRequest); Endpoint endpoint = getEndpointForClient(destination); endpoint.sendRequest(coapRequest); if (destination.usesQueueMode() && !destination.getLwM2mQueue().isClientSleeping()) { destination.getLwM2mQueue().startClientAwakeTimer(); } return syncMessageObserver.waitForResponse(); }</code><technical_language>returning feedback users a good idea</technical_language>

Target:
public <T extends LwM2mResponse> T send(final Registration destination, final DownlinkRequest<T> request, Long timeout) throws InterruptedException { if (destination.getLwM2mQueue().isClientSleeping()) { LOG.info("The destination client is sleeping, request couldn't been sent."); return null; } final LwM2mModel model = modelProvider.getObjectModel(destination); CoapRequestBuilder coapRequestBuilder = new CoapRequestBuilder( new InetSocketAddress(destination.getAddress(), destination.getPort()), destination.getRootPath(), destination.getId(), destination.getEndpoint(), model, encoder); request.accept(coapRequestBuilder); final Request coapRequest = coapRequestBuilder.getRequest(); SyncRequestObserver<T> syncMessageObserver = new SyncRequestObserver<T>(coapRequest, timeout) { @Override public T buildResponse(Response coapResponse) { LwM2mResponseBuilder<T> lwm2mResponseBuilder = new LwM2mResponseBuilder<>(coapRequest, coapResponse, destination, model, observationService, decoder); request.accept(lwm2mResponseBuilder); return lwm2mResponseBuilder.getResponse(); } }; coapRequest.addMessageObserver(syncMessageObserver); addPendingRequest(destination, coapRequest); Endpoint endpoint = getEndpointForClient(destination); endpoint.sendRequest(coapRequest); if (destination.usesQueueMode() && !destination.getLwM2mQueue().isClientSleeping()) { destination.getLwM2mQueue().startClientAwakeTimer(); } return syncMessageObserver.waitForResponse(); }
Source:
<code>public void trade() { for(Entry<String, ArrayList<Order>> buyList : buyOrders.entrySet()) { for ( Entry<String, ArrayList<Order>> sellList : sellOrders.entrySet()) { if (buyList.getKey() == sellList.getKey()) { ArrayList<Order> buySorted = buyOrderSort(buyList.getValue()); ArrayList<Order> sellSorted = sellOrderSort(sellList.getValue()); int buyNum = 0; int sellNum = 0; double price = 0.0; int sellVolume = 0; ArrayList<Double> values = findMarketPrice(buySorted, sellSorted); buyNum = values.get(0).intValue(); sellNum = values.get(1).intValue(); price = values.get(2); sellVolume = values.get(3).intValue(); if (buyNum != -1 && sellNum != -1 && price != -1.0){ PriceSetter set = new PriceSetter(); set.registerObserver(m.getMarketHistory()); m.getMarketHistory().setSubject(set); set.setNewPrice(m, (String)buyList.getKey(), price); for (int i = 0; i <= buyNum; i++) { Order <START> o1 = <END> buySorted.get(i); if (o1.getSize() <= sellVolume) { buyOrders.get(o1.getStockSymbol()).remove(o1); sellVolume -= o1.getSize(); } else { o1.setSize(o1.getSize() - sellVolume); } try { o1.getTrader().tradePerformed(o1, price); } catch (StockMarketExpection e) { e.printStackTrace(); } } for (int i = 0; i <= sellNum; i++) { Order o2 = sellSorted.get(i); sellOrders.get(o2.getStockSymbol()).remove(o2); try { o2.getTrader().tradePerformed(o2, price); } catch (StockMarketExpection e) { e.printStackTrace(); } } } } } } }</code><technical_language>Rename this variable name references purpose. helps understand loop is glance instead of evaluate it</technical_language>

Target:
public void trade() { for(Entry<String, ArrayList<Order>> buyList : buyOrders.entrySet()) { for ( Entry<String, ArrayList<Order>> sellList : sellOrders.entrySet()) { if (buyList.getKey() == sellList.getKey()) { ArrayList<Order> buySorted = buyOrderSort(buyList.getValue()); ArrayList<Order> sellSorted = sellOrderSort(sellList.getValue()); int buyNum = 0; int sellNum = 0; double price = 0.0; int sellVolume = 0; ArrayList<Double> values = findMarketPrice(buySorted, sellSorted); buyNum = values.get(0).intValue(); sellNum = values.get(1).intValue(); price = values.get(2); sellVolume = values.get(3).intValue(); if (buyNum != -1 && sellNum != -1 && price != -1.0){ PriceSetter set = new PriceSetter(); set.registerObserver(m.getMarketHistory()); m.getMarketHistory().setSubject(set); set.setNewPrice(m, (String)buyList.getKey(), price); for (int i = 0; i <= buyNum; i++) { Order order = buySorted.get(i); if (buyOrder.getSize() <= sellVolume) { buyOrders.get(order.getStockSymbol()).remove(order); sellVolume -= order.getSize(); } else { order.setSize(o1.getSize() - sellVolume); } try { order.getTrader().tradePerformed(order, price); } catch (StockMarketExpection e) { e.printStackTrace(); } } for (int i = 0; i <= sellNum; i++) { Order order = sellSorted.get(i); sellOrders.get(order.getStockSymbol()).remove(order); try { order.getTrader().tradePerformed(order, price); } catch (StockMarketExpection e) { e.printStackTrace(); } } } } } } }
Source:
<code>public <VO, VR> KStream<K, VR> join(final KStream<K, VO> otherStream, final ValueJoiner<? super V, ? super VO, ? extends VR> joiner, final JoinWindows windows, final Joined<K, V, VO> joined) { return doJoin(otherStream, joiner, windows, joined, null, <START> new KStreamImplJoin(false, false)); <END> }</code><technical_language>nit: fix indention (best, move otherStream new line reduce indention for other parameters too)</technical_language>

Target:
public <VO, VR> KStream<K, VR> join(final KStream<K, VO> otherStream, final ValueJoiner<? super V, ? super VO, ? extends VR> joiner, final JoinWindows windows, final Joined<K, V, VO> joined) { Objects.requireNonNull(joined, "Joined can't be null"); final JoinedInternal<K, V, VO> joinedInternal = new JoinedInternal<>(joined); final StreamJoined<K, V, VO> streamJoined = StreamJoined.with(joinedInternal.keySerde(), joinedInternal.valueSerde(), joinedInternal.otherValueSerde()).withName(joinedInternal.name()); return join(otherStream, joiner, windows, streamJoined); }
Source:
<code>private void initialFetchAndSchedule() { Runnable updater = () -> { try { fetchAndUpdateCache(false); } catch (Exception e) { logger.error("Exception occurred when fetching remote account data", e); accountServiceMetrics.fetchRemoteAccountErrorCount.inc(); } }; updater.run(); if (accountInfoMapRef.get().isEmpty() && config.enableServeFromBackup && !backup.isEmpty()) { <START> long aMonthAgo = System.currentTimeMillis() / 1000 - 30 * 24 * 60 * 60; <END> Map<String, String> accountMap = backup.getLatestState(aMonthAgo); if (accountMap != null) { AccountInfoMap newAccountInfoMap = new AccountInfoMap(accountServiceMetrics, accountMap); AccountInfoMap oldAccountInfoMap = accountInfoMapRef.getAndSet(newAccountInfoMap); notifyAccountUpdateConsumers(newAccountInfoMap, oldAccountInfoMap, false); } } if (scheduler != null) { int initialDelay = new Random().nextInt(config.updaterPollingIntervalMs + 1); scheduler.scheduleAtFixedRate(updater, initialDelay, config.updaterPollingIntervalMs, TimeUnit.MILLISECONDS); logger.info( "Background account updater will fetch accounts from remote starting ms from now and repeat with interval={} ms", initialDelay, config.updaterPollingIntervalMs); } if (notifier != null) { notifier.subscribe(ACCOUNT_METADATA_CHANGE_TOPIC, changeTopicListener); } else { logger.warn("Notifier is null. Account updates cannot be notified to other entities. Local account cache may not " + "be in sync with remote account data."); accountServiceMetrics.nullNotifierCount.inc(); } }</code><technical_language>TimeUnit.DAYS.toSeconds(30)</technical_language>

Target:
private void initialFetchAndSchedule() { Runnable updater = () -> { try { fetchAndUpdateCache(false); } catch (Exception e) { logger.error("Exception occurred when fetching remote account data", e); accountServiceMetrics.fetchRemoteAccountErrorCount.inc(); } }; updater.run(); if (accountInfoMapRef.get().isEmpty() && config.enableServeFromBackup && !backupFileManager.isEmpty()) { long aMonthAgo = System.currentTimeMillis() / 1000 - TimeUnit.DAYS.toSeconds(30); Map<String, String> accountMap = backupFileManager.getLatestAccountMap(aMonthAgo); if (accountMap != null) { AccountInfoMap newAccountInfoMap = new AccountInfoMap(accountServiceMetrics, accountMap); AccountInfoMap oldAccountInfoMap = accountInfoMapRef.getAndSet(newAccountInfoMap); notifyAccountUpdateConsumers(newAccountInfoMap, oldAccountInfoMap, false); } } if (scheduler != null) { int initialDelay = new Random().nextInt(config.updaterPollingIntervalMs + 1); scheduler.scheduleAtFixedRate(updater, initialDelay, config.updaterPollingIntervalMs, TimeUnit.MILLISECONDS); logger.info( "Background account updater will fetch accounts from remote starting ms from now and repeat with interval={} ms", initialDelay, config.updaterPollingIntervalMs); } if (notifier != null) { notifier.subscribe(ACCOUNT_METADATA_CHANGE_TOPIC, changeTopicListener); } else { logger.warn("Notifier is null. Account updates cannot be notified to other entities. Local account cache may not " + "be in sync with remote account data."); accountServiceMetrics.nullNotifierCount.inc(); } }
Source:
<code>public void testSimpleParsing() throws Exception { LayerDescriptor layerDescriptor; layerDescriptor = new LayerDescriptor("imos:some_layer/sea_water_velocity"); assertEquals("imos", layerDescriptor.workspace); <START> assertEquals("some_layer", layerDescriptor.layer); <END> assertEquals("sea_water_velocity", layerDescriptor.variable); assertEquals("imos:some_layer", layerDescriptor.geoserverName()); assertEquals("imos:some_layer/sea_water_velocity", layerDescriptor.toString()); layerDescriptor = new LayerDescriptor("some_layer/sea_water_velocity"); assertEquals(null, layerDescriptor.workspace); assertEquals("some_layer", layerDescriptor.layer); assertEquals("sea_water_velocity", layerDescriptor.variable); assertEquals("some_layer", layerDescriptor.geoserverName()); assertEquals("some_layer/sea_water_velocity", layerDescriptor.toString()); }</code><technical_language>some_layer is a group layer in this case sea_water_velocity is a layer name. Assigning variable in this code simply weird. interested in is layer name</technical_language>

Target:
public void testSimpleParsing() throws Exception { LayerDescriptor layerDescriptor; layerDescriptor = new LayerDescriptor("imos:some_layer/sea_water_velocity"); assertEquals("imos", layerDescriptor.workspace); assertEquals("some_layer", layerDescriptor.layer); assertEquals("sea_water_velocity", layerDescriptor.variable); assertEquals("imos:some_layer", layerDescriptor.geoserverName()); assertEquals("imos:some_layer/sea_water_velocity", layerDescriptor.toString()); assertEquals("time", layerDescriptor.getTimeFieldName()); assertEquals("file_url", layerDescriptor.getUrlFieldName()); layerDescriptor = new LayerDescriptor("some_layer/sea_water_velocity"); assertEquals(null, layerDescriptor.workspace); assertEquals("some_layer", layerDescriptor.layer); assertEquals("sea_water_velocity", layerDescriptor.variable); assertEquals("some_layer", layerDescriptor.geoserverName()); assertEquals("some_layer/sea_water_velocity", layerDescriptor.toString()); assertEquals("time", layerDescriptor.getTimeFieldName()); assertEquals("file_url", layerDescriptor.getUrlFieldName()); }
Source:
<code>public List<JDK> getJDKs() { <START> if(jdks==null) <END> jdks = new ArrayList<JDK>(); return jdks; }</code><technical_language>I this null is if a configuration saved <jdks> entry reloaded. I happen - some version of Jenkins done it. sense modify a readResolve() set empty list remove this check theoretical possibility</technical_language>

Target:
public List<JDK> getJDKs() { return jdks; }
Source:
<code>public void testHashFirstTwoRowComponents() { HashComponentsTestTable.HashComponentsTestRow testRow = HashComponentsTestTable.HashComponentsTestRow.of(TEST_VALUE_INTEGER, TEST_VALUE_STRING); byte[] component1Bytes = EncodingUtils.encodeUnsignedVarLong(TEST_VALUE_INTEGER); byte[] component2Bytes = EncodingUtils.encodeVarString(TEST_VALUE_STRING); long hashOfFirstTwoComponents = Hashing.murmur3_128().hashBytes(EncodingUtils.add(component1Bytes, component2Bytes)).asLong(); byte[] hashOfComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfFirstTwoComponents); <START> assertThat(testRow.persistToBytes()) <END> .isEqualTo(EncodingUtils.add(hashOfComponentsBytes, component1Bytes, component2Bytes)); }</code><technical_language>test hydrate bytes persist give testRow. a complete (ser/deser)ialization test</technical_language>

Target:
public void testHashFirstTwoRowComponents() { HashComponentsTestTable.HashComponentsTestRow testRow = HashComponentsTestTable.HashComponentsTestRow.of(TEST_VALUE_INTEGER, TEST_VALUE_STRING); byte[] component1Bytes = EncodingUtils.encodeUnsignedVarLong(TEST_VALUE_INTEGER); byte[] component2Bytes = EncodingUtils.encodeVarString(TEST_VALUE_STRING); long hashOfFirstTwoComponents = Hashing.murmur3_128().hashBytes(EncodingUtils.add(component1Bytes, component2Bytes)).asLong(); byte[] hashOfComponentsBytes = PtBytes.toBytes(Long.MIN_VALUE ^ hashOfFirstTwoComponents); byte[] persistedRow = testRow.persistToBytes(); assertThat(persistedRow) .isEqualTo(EncodingUtils.add(hashOfComponentsBytes, component1Bytes, component2Bytes)); assertThat(HashComponentsTestTable.HashComponentsTestRow.BYTES_HYDRATOR.hydrateFromBytes(persistedRow)) .isEqualTo(testRow); }
Source:
<code>public boolean equalWithTolerance(CurveParameterSensitivity other, double tolerance) { Set<SensitivityKey> intersection = sensitivities.keySet(); if (!sensitivities.keySet().equals(other.sensitivities.keySet())) { <START> Set<SensitivityKey> amb = new HashSet<>(sensitivities.keySet()); <END> amb.removeAll(other.sensitivities.keySet()); if (!checkSmall(amb, sensitivities, tolerance)) { return false; } Set<SensitivityKey> bma = new HashSet<>(other.sensitivities.keySet()); bma.removeAll(sensitivities.keySet()); if (!checkSmall(bma, other.sensitivities, tolerance)) { return false; } intersection = new HashSet<>(sensitivities.keySet()); intersection.retainAll(other.sensitivities.keySet()); } for (SensitivityKey key : intersection) { double[] vector1 = sensitivities.get(key); double[] vector2 = other.sensitivities.get(key); if (vector1.length != vector2.length) { return false; } for (int i = 0; i < vector1.length; i++) { if (!DoubleMath.fuzzyEquals(vector1[i], vector2[i], tolerance)) { return false; } } } return true; }</code><technical_language>Guava Sets.difference() Sets.intersection()</technical_language>

Target:
public boolean equalWithTolerance(CurveParameterSensitivity other, double tolerance) { if (!sensitivities.keySet().equals(other.sensitivities.keySet())) { Set<SensitivityKey> amb = Sets.difference(sensitivities.keySet(), other.sensitivities.keySet()); if (!checkSmall(amb, sensitivities, tolerance)) { return false; } Set<SensitivityKey> bma = Sets.difference(other.sensitivities.keySet(), sensitivities.keySet()); if (!checkSmall(bma, other.sensitivities, tolerance)) { return false; } Set<SensitivityKey> intersection = Sets.intersection(sensitivities.keySet(), other.sensitivities.keySet()); return checkCommon(intersection, sensitivities, other.sensitivities, tolerance); } return checkCommon(sensitivities.keySet(), sensitivities, other.sensitivities, tolerance); }
Source:
<code>public VmTemplate readVmTemplateFromOvf(String ovf) throws OvfReaderException { ArrayList<DiskImage> diskImages = new ArrayList<>(); ArrayList<VmNetworkInterface> interfaces = new ArrayList<>(); VmTemplate template = new VmTemplate(); ovfManager.importTemplate(ovf, template, diskImages, interfaces); template.setInterfaces(interfaces); for (DiskImage disk : diskImages) { template.getDiskTemplateMap().put(disk.getId(), disk); } if (template.getMaxMemorySizeMb() == 0) { template.setMaxMemorySizeMb( VmCommonUtils.maxMemorySizeWithHotplugInMb(template.getOsId(), <START> template.getCompatibilityVersion())); <END> } return template; }</code><technical_language>I this return null - please verify</technical_language>

Target:
public VmTemplate readVmTemplateFromOvf(String ovf) throws OvfReaderException { ArrayList<DiskImage> diskImages = new ArrayList<>(); ArrayList<VmNetworkInterface> interfaces = new ArrayList<>(); VmTemplate template = new VmTemplate(); ovfManager.importTemplate(ovf, template, diskImages, interfaces); template.setInterfaces(interfaces); for (DiskImage disk : diskImages) { template.getDiskTemplateMap().put(disk.getId(), disk); } return template; }
Source:
<code>public void init(Map<String, Object> conf) throws StatefulStorageException { checkpointRootPath = (String) conf.get(ROOT_PATH_KEY); <START> maxCheckpoints = (int) conf.get(MAX_CHECKPOINTS_KEY); <END> if (checkpointRootPath != null) { checkpointRootPath = checkpointRootPath.replaceFirst("^~", System.getProperty("user.home")); } LOG.info("Initialing LocalFileSystemStorage with Checkpoint root path: " + checkpointRootPath + " Max checkpoints: " + maxCheckpoints); }</code><technical_language>helpful a default value</technical_language>

Target:
public void init(Map<String, Object> conf) throws StatefulStorageException { checkpointRootPath = (String) conf.get(ROOT_PATH_KEY); maxCheckpoints = (int) conf.getOrDefault(MAX_CHECKPOINTS_KEY, DEFAULT_MAX_CHECKPOINTS); if (checkpointRootPath != null) { checkpointRootPath = checkpointRootPath.replaceFirst("^~", System.getProperty("user.home")); } LOG.info("Initialing LocalFileSystemStorage with Checkpoint root path: " + checkpointRootPath + " Max checkpoints: " + maxCheckpoints); }
Source:
<code>public void generateInsightsByCategory(final Long accountId, final Long deviceId, final InsightCard.Category category) { Optional<InsightCard> insightCardOptional = Optional.absent(); if (category == InsightCard.Category.LIGHT) { insightCardOptional = Lights.getInsights(accountId, deviceId, deviceDataDAO, lightData); } else if (category == InsightCard.Category.TEMPERATURE) { final AccountInfo.SleepTempType tempPref = this.accountInfoProcessor.checkTemperaturePreference(accountId); final AccountPreference.TemperatureUnit tempUnit = this.getTemperatureUnitString(accountId); insightCardOptional = TemperatureHumidity.getInsights(accountId, deviceId, deviceDataDAO, tempPref, tempUnit); } else if (category == InsightCard.Category.SLEEP_QUALITY) { insightCardOptional = SleepMotion.getInsights(accountId, deviceId, trendsInsightsDAO, sleepStatsDAODynamoDB, false); } else if (category == InsightCard.Category.WAKE_VARIANCE) { <START> DateTime queryEndDate = DateTime.now().withTimeAtStartOfDay(); <END> int numDays = DAYS_ONE_WEEK; LOGGER.debug("for wake variance calling getInsights with accountId and date with numDays {}", accountId, queryEndDate, numDays); insightCardOptional = WakeVariance.getInsights(sleepStatsDAODynamoDB, accountId, wakeStdDevData, queryEndDate, numDays); } if (insightCardOptional.isPresent()) { LOGGER.debug("Insight card present, Inserting insight into DynamoDB"); this.insightsDAODynamoDB.insertInsight(insightCardOptional.get()); } }</code><technical_language>final</technical_language>

Target:
public void generateInsightsByCategory(final Long accountId, final Long deviceId, final InsightCard.Category category) { Optional<InsightCard> insightCardOptional = Optional.absent(); if (category == InsightCard.Category.LIGHT) { insightCardOptional = Lights.getInsights(accountId, deviceId, deviceDataDAO, lightData); } else if (category == InsightCard.Category.TEMPERATURE) { final AccountInfo.SleepTempType tempPref = this.accountInfoProcessor.checkTemperaturePreference(accountId); final AccountPreference.TemperatureUnit tempUnit = this.getTemperatureUnitString(accountId); insightCardOptional = TemperatureHumidity.getInsights(accountId, deviceId, deviceDataDAO, tempPref, tempUnit); } else if (category == InsightCard.Category.SLEEP_QUALITY) { insightCardOptional = SleepMotion.getInsights(accountId, deviceId, trendsInsightsDAO, sleepStatsDAODynamoDB, false); } else if (category == InsightCard.Category.WAKE_VARIANCE) { final DateTime queryEndDate = DateTime.now().withTimeAtStartOfDay(); LOGGER.debug("for wake variance calling getInsights with accountId and date with numDays {}", accountId, queryEndDate, DAYS_ONE_WEEK); insightCardOptional = WakeVariance.getInsights(sleepStatsDAODynamoDB, accountId, wakeStdDevData, queryEndDate, DAYS_ONE_WEEK); } if (insightCardOptional.isPresent()) { LOGGER.debug("Category insight card present for account {}, Inserting insight into DynamoDB", category, accountId); this.insightsDAODynamoDB.insertInsight(insightCardOptional.get()); } }
Source:
<code>public View getView(int position, View convertView, ViewGroup parent) { FeedHolder holder; Feed feed = feedTime.get(position).feed; if (convertView == null) { holder = new FeedHolder(); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); <START> convertView = inflater.inflate(R.layout.nav_feedlistitem, parent, false); <END> holder.image = (ImageView) convertView.findViewById(R.id.imgvCover); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.failure = (IconTextView) convertView.findViewById(R.id.itxtvFailure); holder.count = (TextView) convertView.findViewById(R.id.txtvCount); convertView.setTag(holder); } else { holder = (FeedHolder) convertView.getTag(); } Glide.with(context) .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.image); holder.title.setText(feed.getTitle()); holder.failure.setVisibility(View.GONE); holder.count.setVisibility(View.VISIBLE); holder.count.setText(timeToText(feedTime.get(position).timePlayed)); return convertView; }</code><technical_language>While this creative re-use of a layout, this is a good idea. create additional, non-obvious dependency here. change navbar listitem layout in future, consider layout is here. failure count (of new/unused/unused+new episodes) for total runtime a bad smell it. give variables names</technical_language>

Target:
public View getView(int position, View convertView, ViewGroup parent) { StatisticsHolder holder; Feed feed = feedTime.get(position).feed; if (convertView == null) { holder = new StatisticsHolder(); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.statistics_listitem, parent, false); holder.image = (ImageView) convertView.findViewById(R.id.imgvCover); holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.time = (TextView) convertView.findViewById(R.id.txtvTime); convertView.setTag(holder); } else { holder = (StatisticsHolder) convertView.getTag(); } Glide.with(context) .load(feed.getImageUri()) .placeholder(R.color.light_gray) .error(R.color.light_gray) .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) .fitCenter() .dontAnimate() .into(holder.image); holder.title.setText(feed.getTitle()); holder.time.setText(Converter.shortLocalizedDuration(context, feedTime.get(position).timePlayed)); return convertView; }
Source:
<code>public M filter(BiPredicate<? super K, ? super V> predicate) { Objects.requireNonNull(predicate, "predicate is null"); <START> return filter(t -> predicate.test(t._1(), t._2())); <END> }</code><technical_language>Great, thank you! In ideomatic Javaslang access tuple fields directly, e.g. t._1, t._2 instead of t._1(), t._2(). change please for methods here? methods useful in case of method references, e.g. t::_1 t::_2</technical_language>

Target:
public M filter(BiPredicate<? super K, ? super V> predicate) { Objects.requireNonNull(predicate, "predicate is null"); return filter(t -> predicate.test(t._1, t._2)); }
Source:
<code>private <C extends org.atlasapi.content.Content> C setContentFields(C c, Content input) { c.setYear(input.getYear()); c.setLanguages(input.getLanguages()); c.setCountriesOfOrigin(input.getCountriesOfOrigin()); c.setTags( translateTopicRefs( legacyTagTopicMerger.mergeTags( input.getTopicRefs(), legacyGenreToTagTransformer.mapGenresToTopicRefs(input.getGenres()) ))); c.setGenericDescription(input.getGenericDescription()); c.setEventRefs(translateEventRefs(input.events())); c.setCertificates(input.getCertificates().stream() <START> .map(input1 -> new Certificate(input1.classification(), input1.country())) <END> .collect(Collectors.toList())); c.setClips(transformClipsOfContent(input)); c.setPeople( input.people().stream() .map(legacyCrewMemberTransformer::apply) .filter(java.util.Objects::nonNull) .collect(Collectors.toList()) ); transformEncodings(c, input.getVersions()); return c; }</code><technical_language>name gooderer</technical_language>

Target:
private <C extends org.atlasapi.content.Content> C setContentFields(C c, Content input) { c.setYear(input.getYear()); c.setLanguages(input.getLanguages()); c.setCountriesOfOrigin(input.getCountriesOfOrigin()); c.setTags( translateTopicRefs( legacyTagTopicMerger.mergeTags( input.getTopicRefs(), legacyGenreToTagTransformer.mapGenresToTopicRefs(input.getGenres()) ))); c.setGenericDescription(input.getGenericDescription()); c.setEventRefs(translateEventRefs(input.events())); c.setCertificates(input.getCertificates().stream() .map(certificate -> new Certificate( certificate.classification(), certificate.country() )) .collect(Collectors.toList())); c.setClips(transformClipsOfContent(input)); c.setPeople( input.people().stream() .map(legacyCrewMemberTransformer::apply) .filter(java.util.Objects::nonNull) .collect(Collectors.toList()) ); transformEncodings(c, input.getVersions()); return c; }
Source:
<code>public PipelineStats summarize() { return new PipelineStats( pipelineId, firstStartTime, lastStartTime, lastEndTime, inputPipeline, outputPipeline, totalDrivers, queuedDrivers, queuedPartitionedDrivers, runningDrivers, runningPartitionedDrivers, completedDrivers, memoryReservation, systemMemoryReservation, queuedTime, elapsedTime, totalScheduledTime, totalCpuTime, totalUserTime, totalBlockedTime, fullyBlocked, blockedReasons, rawInputDataSize, rawInputPositions, processedInputDataSize, processedInputPositions, outputDataSize, outputPositions, spilledDataSize, operatorSummaries.stream() .map(OperatorStats::summarize) .collect(Collectors.toList()), <START> ImmutableList.of() <END> ); }</code><technical_language>Revert</technical_language>

Target:
public PipelineStats summarize() { return new PipelineStats( pipelineId, firstStartTime, lastStartTime, lastEndTime, inputPipeline, outputPipeline, totalDrivers, queuedDrivers, queuedPartitionedDrivers, runningDrivers, runningPartitionedDrivers, blockedDrivers, completedDrivers, memoryReservation, systemMemoryReservation, queuedTime, elapsedTime, totalScheduledTime, totalCpuTime, totalUserTime, totalBlockedTime, fullyBlocked, blockedReasons, rawInputDataSize, rawInputPositions, processedInputDataSize, processedInputPositions, outputDataSize, outputPositions, spilledDataSize, operatorSummaries.stream() .map(OperatorStats::summarize) .collect(Collectors.toList()), ImmutableList.of()); }
Source:
<code>public void onCacheEventModified( CacheEntryEvent event ) { <START> if ( event.getKey() == this.key ) <END> { FileBlock updatedBlock = (FileBlock) event.getValue(); if( updatedBlock.isEOF() ) { this.lock.signal(); } } }</code><technical_language>I want .equals() instead of == here, deserialization lead physical instances compared</technical_language>

Target:
public void onCacheEventModified( CacheEntryEvent event ) { if ( event.getKey().equals( this.key ) ) { FileBlock updatedBlock = (FileBlock) event.getValue(); if ( updatedBlock.isEOF() ) { this.lock.signal(); } } }
Source:
<code>private boolean labelRenamed() { return NetworkUtils.isLabeled(getOldNetwork()) && NetworkUtils.isLabeled(getNetwork()) <START> && !getOldNetwork().getLabel().equals(getNetwork().getLabel()); <END> }</code><technical_language>call labelChanged() instead of comparing</technical_language>

Target:
private boolean labelRenamed() { return NetworkUtils.isLabeled(getOldNetwork()) && NetworkUtils.isLabeled(getNetwork()) && labelChanged(); }
Source:
<code>public Object generateValue(Object key, int size, Random random) { <START> return new RandomStream(key.hashCode(), size); <END> }</code><technical_language>Generating identical streams for key is a good property of a *random value* generator</technical_language>

Target:
public Object generateValue(Object key, int size, Random random) { return new RandomStream(size); }
Source:
<code>public static Event getEvent(Context context, long id) { ContentResolver cr = context.getContentResolver(); Cursor evtCur = cr.query( CalendarContract.Events.CONTENT_URI, EVENT_PROJECTION, CalendarContract.Events._ID + "=" + id, null, null); evtCur.moveToFirst(); <START> Event event = eventFromCusrsor(context, evtCur); <END> evtCur.close(); return event; }</code><technical_language>FromCusror</technical_language>

Target:
public static Event getEvent(Context context, long id) { ContentResolver cr = context.getContentResolver(); Cursor evtCur = cr.query( CalendarContract.Events.CONTENT_URI, EVENT_PROJECTION, CalendarContract.Events._ID + "=" + id, null, null); evtCur.moveToFirst(); if(evtCur.getCount() < 1) { return null; } Event event = fromCursor(context, evtCur); evtCur.close(); return event; }