auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public <U> Vector<U> map(Function<? super T, ? extends U> mapper) { Objects.requireNonNull(mapper, "mapper is null"); final MutableWrapper<Object[]> newLeading = new MutableWrapper<>(Arrays.empty()); final Object[] newMiddle = new Object[middle.leafCount()]; final MutableWrapper<Object[]> newTrailing = new MutableWrapper<>(Arrays.empty()); leafVisitor((ordinal, leaf, start, end) -> { final Object[] copy = copyMap(mapper, leaf, start, end); if (ordinal == 0) { newLeading.val = copy; } else if (ordinal <= newMiddle.length) { newMiddle[ordinal - 1] = copy); } else { newTrailing.val = copy; } }); final BitMappedTrie<U> middle = BitMappedTrie.ofAll(newMiddle, this.middle.length(), BRANCHING_BASE); return ofAll(newLeading.val, leadingOffset, middle, newTrailing.val, trailingLength); }

Target:
public <U> Vector<U> map(Function<? super T, ? extends U> mapper) { return ofAll(trie.map(mapper)); }
Source:
private void addViewerToSelectionProvider() { IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart(); ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); if (selectionProvider instanceof EMFCompareEditorSelectionProviderWrapper) { Viewer leftViewer = getSelectionViewer(fLeft); Viewer rightViewer = getSelectionViewer(fRight); Viewer ancestorViewer = getSelectionViewer(fAncestor); if (leftViewer != null && rightViewer != null && ancestorViewer != null) { EMFCompareEditorSelectionProviderWrapper compareSelectionProvider = (EMFCompareEditorSelectionProviderWrapper)selectionProvider; compareSelectionProvider .addViewers(Lists.newArrayList(leftViewer, rightViewer, ancestorViewer), leftViewer); } } }

Target:
private void addViewerToSelectionProvider() { IWorkbenchPart part = getCompareConfiguration().getContainer().getWorkbenchPart(); ISelectionProvider selectionProvider = part.getSite().getSelectionProvider(); if (selectionProvider instanceof EMFCompareEditorSelectionProviderWrapper) { Viewer leftViewer = getSelectionViewer(fLeft); Viewer rightViewer = getSelectionViewer(fRight); Viewer ancestorViewer = getSelectionViewer(fAncestor); List<Viewer> selectionViewers = Lists.newArrayList(leftViewer, rightViewer, ancestorViewer); Iterables.removeIf(selectionViewers, isNull()); if (!selectionViewers.isEmpty()) { EMFCompareEditorSelectionProviderWrapper compareSelectionProvider = (EMFCompareEditorSelectionProviderWrapper)selectionProvider; compareSelectionProvider.addViewers(selectionViewers, selectionViewers.get(0)); } } }
Source:
public void shouldCompileKotlinCodeWithBackticks() { ProcessResult buildResult = workspace.runBuckCommand("build", " buildResult.assertSuccess("Build should have succeeded."); }

Target:
public void shouldCompileKotlinCodeWithBackticks() { workspace.runBuckBuild(" }
Source:
public void release() { if ( labelStatesMap != null ) { labelStatesMap.close(); } if ( createdLabelTokens != null ) { createdLabelTokens.close(); } if ( createdRelationshipTypeTokens != null ) { createdRelationshipTypeTokens.close(); } if ( nodeStatesMap != null ) { nodeStatesMap.close(); } if ( relationshipStatesMap != null ) { relationshipStatesMap.close(); } if ( propertyChangesForNodes != null ) { propertyChangesForNodes.release(); } if ( nodes != null && nodes.removedFromAdded != null ) { nodes.removedFromAdded.close(); } if ( relationships != null && relationships.removedFromAdded != null ) { relationships.removedFromAdded.close(); } }

Target:
public void release() { if ( !collectionsFactory.collectionsMustBeReleased() ) { return; } if ( labelStatesMap != null ) { labelStatesMap.close(); } if ( createdLabelTokens != null ) { createdLabelTokens.close(); } if ( createdRelationshipTypeTokens != null ) { createdRelationshipTypeTokens.close(); } if ( nodeStatesMap != null ) { nodeStatesMap.close(); } if ( relationshipStatesMap != null ) { relationshipStatesMap.close(); } if ( propertyChangesForNodes != null ) { propertyChangesForNodes.release(); } if ( nodes != null && nodes.removedFromAdded != null ) { nodes.removedFromAdded.close(); } if ( relationships != null && relationships.removedFromAdded != null ) { relationships.removedFromAdded.close(); } }
Source:
public CompletableFuture<Void> anoint() { if (role.role() == RaftServer.Role.LEADER) { return CompletableFuture.completedFuture(null); } CompletableFuture<Void> future = new CompletableFuture<>(); threadContext.execute(() -> { Consumer<RaftMember> electionListener = new Consumer<RaftMember>() { @Override public void accept(RaftMember member) { if (member.memberId().equals(cluster.getMember().memberId())) { future.complete(null); } else { future.completeExceptionally(new RaftException.ProtocolException("Failed to transfer leadership")); } removeLeaderElectionListener(this); } }; addLeaderElectionListener(electionListener); RaftMember member = getCluster().getMember(); RaftMember leader = getLeader(); if (leader != null) { protocol.transfer(leader.memberId(), TransferRequest.newBuilder() .withMember(member.memberId()) .build()).whenComplete((response, error) -> { if (error != null) { future.completeExceptionally(error); } else if (response.status() != RaftResponse.Status.ERROR) { future.completeExceptionally(response.error().createException()); } else { transition(RaftServer.Role.CANDIDATE); } }); } else { transition(RaftServer.Role.CANDIDATE); } }); return future; }

Target:
public CompletableFuture<Void> anoint() { if (role.role() == RaftServer.Role.LEADER) { return CompletableFuture.completedFuture(null); } CompletableFuture<Void> future = new CompletableFuture<>(); threadContext.execute(() -> { Consumer<RaftMember> electionListener = new Consumer<RaftMember>() { @Override public void accept(RaftMember member) { if (member.memberId().equals(cluster.getMember().memberId())) { future.complete(null); } else { future.completeExceptionally(new RaftException.ProtocolException("Failed to transfer leadership")); } removeLeaderElectionListener(this); } }; addLeaderElectionListener(electionListener); RaftMember member = getCluster().getMember(); RaftMember leader = getLeader(); if (leader != null) { protocol.transfer(leader.memberId(), TransferRequest.newBuilder() .withMember(member.memberId()) .build()).whenCompleteAsync((response, error) -> { if (error != null) { future.completeExceptionally(error); } else if (response.status() == RaftResponse.Status.ERROR) { future.completeExceptionally(response.error().createException()); } else { transition(RaftServer.Role.CANDIDATE); } }, threadContext); } else { transition(RaftServer.Role.CANDIDATE); } }); return future; }
Source:
public boolean execute(ExecutionContext context) { CoreSession session = getCoreSession(context); if (session == null) { log.error("Could not open CoreSession"); return false; } AutomationService as = Framework.getService(AutomationService.class); try (OperationContext automationCtx = new OperationContext(session)) { automationCtx.putAll(context); ExecutionContext initialContext = context.getInitialContext(); String parentPath = (String) initialContext.get(PARENT_PATH_KEY); DocumentModel mailFolder = session.getDocument(new PathRef(parentPath)); automationCtx.put("mailFolder", mailFolder); automationCtx.put("executionContext", initialContext); String subject = (String) context.get(SUBJECT_KEY); automationCtx.put("mailDocumentName", generateMailName(subject)); @SuppressWarnings("unchecked") List<FileBlob> attachments = (List<FileBlob>) context.get(ATTACHMENTS_KEY); if (attachments == null) { automationCtx.put(ATTACHMENTS_KEY, Collections.EMPTY_LIST); } try { as.run(automationCtx, getChainName()); } catch (OperationException e) { throw new NuxeoException(e); } } catch (Exception cause) { throw new NuxeoException(cause); } return true; }

Target:
public boolean execute(ExecutionContext context) { CoreSession session = getCoreSession(context); if (session == null) { log.error("Could not open CoreSession"); return false; } AutomationService as = Framework.getService(AutomationService.class); try (OperationContext automationCtx = new OperationContext(session)) { automationCtx.putAll(context); ExecutionContext initialContext = context.getInitialContext(); String parentPath = (String) initialContext.get(PARENT_PATH_KEY); DocumentModel mailFolder = session.getDocument(new PathRef(parentPath)); automationCtx.put("mailFolder", mailFolder); automationCtx.put("executionContext", initialContext); String subject = (String) context.get(SUBJECT_KEY); automationCtx.put("mailDocumentName", generateMailName(subject)); @SuppressWarnings("unchecked") List<FileBlob> attachments = (List<FileBlob>) context.get(ATTACHMENTS_KEY); if (attachments == null) { automationCtx.put(ATTACHMENTS_KEY, Collections.EMPTY_LIST); } try { as.run(automationCtx, getChainName()); } catch (OperationException e) { throw new NuxeoException(e); } } catch (Exception e) { ExceptionUtils.checkInterrupt(e); } return true; }
Source:
public NoActionsAvailableAction() { setText("No Actions Avaliable"); setEnabled(false); }

Target:
public NoActionsAvailableAction() { setText(UiMessages.Action_NoActionsAvailable_Text); setEnabled(false); }
Source:
private String getDocumentValueFromEntry(Entry entry) throws IOException { ObjectMapper mapper = Jackson.newObjectMapper(); StringBuilder builder = new StringBuilder(); Map<String, Object> doc = new HashMap<>(); JsonNode jsonNode = dockstoreEntryToElasticSearchObject(entry); doc.put("doc", jsonNode); doc.put("doc_as_upsert", true); try { builder.append(mapper.writeValueAsString(doc)); } catch (JsonProcessingException e) { e.printStackTrace(); } return builder.toString(); }

Target:
private String getDocumentValueFromEntry(Entry entry) { ObjectMapper mapper = Jackson.newObjectMapper(); StringBuilder builder = new StringBuilder(); Map<String, Object> doc = new HashMap<>(); try { JsonNode jsonNode = dockstoreEntryToElasticSearchObject(entry); doc.put("doc", jsonNode); doc.put("doc_as_upsert", true); builder.append(mapper.writeValueAsString(doc)); } catch (IOException e) { throw new CustomWebApplicationException(MAPPER_ERROR, HttpStatus.SC_INTERNAL_SERVER_ERROR); } return builder.toString(); }
Source:
private String[] getPath(String key) { String property = propertyKeys.get(key); if (property == null) { property = new String[] { key }; } return property; }

Target:
private String[] getPath(String key) { String property = propertyKeys.get(key); if (property == null) { throw new IllegalArgumentException(String.format("key %s is not known to the resource %s", key, getName().isEmpty()? getClass().getSimpleName() : getName())); } return property; }
Source:
public void shouldExpandEnvAndBuildVars() throws Exception { MessageExpander expander = new MessageExpander(new ExpandableMessage( format(MSG_FORMAT, asVar(ENV_VAR_JOB_NAME), asVar(CUSTOM_BUILD_PARAM), asTokenVar(ENV_VAR_JOB_NAME) ) )); FreeStyleProject job = jRule.createFreeStyleProject(); ParameterDefinition paramDef = new StringParameterDefinition(CUSTOM_BUILD_PARAM, "", ""); ParametersDefinitionProperty paramsDef = new ParametersDefinitionProperty(paramDef); job.addProperty(paramsDef); job.getBuildersList().add(expander); job.scheduleBuild2(0, new ParametersAction(new StringParameterValue(CUSTOM_BUILD_PARAM, CUSTOM_PARAM_VAL))) .get(5, TimeUnit.SECONDS); assertThat("job name - var param - template", expander.getResult(), startsWith(format(MSG_FORMAT, job.getFullName(), CUSTOM_PARAM_VAL, job.getFullName()))); }

Target:
public void shouldExpandEnvAndBuildVars() throws Exception { MessageExpander expander = new MessageExpander(new ExpandableMessage( format(MSG_FORMAT, asVar(ENV_VAR_JOB_NAME), asVar(CUSTOM_BUILD_PARAM), asTokenVar(ENV_VAR_JOB_NAME) ) )); FreeStyleProject job = jRule.createFreeStyleProject(); handleSecurity170(job); job.getBuildersList().add(expander); job.scheduleBuild2(0, new ParametersAction(new StringParameterValue(CUSTOM_BUILD_PARAM, CUSTOM_PARAM_VAL))) .get(5, TimeUnit.SECONDS); assertThat("job name - var param - template", expander.getResult(), startsWith(format(MSG_FORMAT, job.getFullName(), CUSTOM_PARAM_VAL, job.getFullName()))); }
Source:
private ByteBuffer parsePacketSPB(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; int packetLen = pcapPacketHeader.getInt(); long includedPacketLength = ConversionHelper.unsignedIntToLong(packetLen); SeekableByteChannel fFileChannel = getFileChannel(); if (fFileChannel.size() - fFileChannel.position() < includedPacketLength) { throw new BadPcapFileException(String.format("%04x", includedPacketLength) + " is causing buffer overrun."); } if (packetLen > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", packetLen) + " is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) includedPacketLength - 12); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); fFileChannel.read(pcapPacketData); pcapPacketData.flip(); return pcapPacketData; }

Target:
private ByteBuffer parsePacketSPB(ByteBuffer pcapPacketHeader, int blockLength) throws IOException, BadPcapFileException { ByteBuffer pcapPacketData; int packetLen = pcapPacketHeader.getInt(); long includedPacketLength = ConversionHelper.unsignedIntToLong(packetLen); SeekableByteChannel fileChannel = getFileChannel(); if (fileChannel.size() - fileChannel.position() < includedPacketLength) { throw new BadPcapFileException(String.format("%04x", includedPacketLength) + " is causing buffer overrun."); } if (packetLen > Integer.MAX_VALUE) { throw new BadPcapFileException(String.format("%04x", packetLen) + " is bigger than 2^31-1 bytes are not supported."); } pcapPacketData = ByteBuffer.allocate((int) includedPacketLength - 12); pcapPacketData.clear(); ByteOrder byteOrder = getByteOrder(); pcapPacketHeader.order(byteOrder); fileChannel.read(pcapPacketData); pcapPacketData.flip(); return pcapPacketData; }
Source:
public JobDeadline(Date absoluteDeadline) { this.absoluteDeadline = absoluteDeadline; this.relativeDeadline = null; Duration s; }

Target:
public JobDeadline(Date absoluteDeadline) { this.absoluteDeadline = absoluteDeadline; this.relativeDeadline = null; }
Source:
public void tearDown() throws Exception { mJobScheduler.cancel(CONNECTIVITY_JOB_ID); if (mInitialRestrictBackground) { SystemUtil.runShellCommand(getInstrumentation(), RESTRICT_BACKGROUND_ON_CMD); } if(!mHasWifi) { return; } if (mWifiManager.isWifiEnabled() == mInitialWiFiState) { return; } NetworkInfo.State expectedState = mInitialWiFiState ? NetworkInfo.State.CONNECTED : NetworkInfo.State.DISCONNECTED; ConnectivityActionReceiver receiver = new ConnectivityActionReceiver(ConnectivityManager.TYPE_WIFI, expectedState); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); mContext.registerReceiver(receiver, filter); assertTrue(mWifiManager.setWifiEnabled(mInitialWiFiState)); receiver.waitForStateChange(); assertTrue("Failure to restore previous WiFi state", mWifiManager.isWifiEnabled() == mInitialWiFiState); mContext.unregisterReceiver(receiver); super.tearDown(); }

Target:
public void tearDown() throws Exception { mJobScheduler.cancel(CONNECTIVITY_JOB_ID); if (mInitialRestrictBackground) { SystemUtil.runShellCommand(getInstrumentation(), RESTRICT_BACKGROUND_ON_CMD); } if (mHasWifi) { if (mWifiManager.isWifiEnabled() == mInitialWiFiState) { return; } NetworkInfo.State expectedState = mInitialWiFiState ? NetworkInfo.State.CONNECTED : NetworkInfo.State.DISCONNECTED; ConnectivityActionReceiver receiver = new ConnectivityActionReceiver(ConnectivityManager.TYPE_WIFI, expectedState); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); mContext.registerReceiver(receiver, filter); assertTrue(mWifiManager.setWifiEnabled(mInitialWiFiState)); receiver.waitForStateChange(); assertTrue("Failure to restore previous WiFi state", mWifiManager.isWifiEnabled() == mInitialWiFiState); mContext.unregisterReceiver(receiver); } super.tearDown(); }
Source:
public OtherFormatPane openOtherFormatPane() { WebElement linkPane = getDriver().findElementByLinkText(OTHER_FORMAT_PANE_LINK); linkPane.click(); if (linkPane.getAttribute("class").contains("collapsed")) { linkPane.click(); } By paneContent = By.className(CONTAINER_TREE_CLASS); getDriver().waitUntilElementIsVisible(paneContent); return new OtherFormatPane(); }

Target:
public OtherFormatPane openOtherFormatPane() { getDriver().waitUntilElementIsVisible(By.id(EXPORT_MODAL_ID)); getDriver().findElementByLinkText(OTHER_FORMAT_PANE_LINK).click(); getDriver().waitUntilElementIsVisible(By.cssSelector("#exportModelOtherCollapse.collapse.in")); return new OtherFormatPane(); }
Source:
public void thePlatformBuffersADeviceInstallationGetStatusResponseMessageForDevice(final String deviceIdentification, final Map<String, String> expectedResult) throws Throwable { GetStatusAsyncRequest request = new GetStatusAsyncRequest(); AsyncRequest asyncRequest = new AsyncRequest(); asyncRequest.setDeviceId(deviceIdentification); asyncRequest.setCorrelationUid((String) ScenarioContext.Current().get(Keys.KEY_CORRELATION_UID)); request.setAsyncRequest(asyncRequest); boolean success = false; int count = 0; while (!success) { if (count > configuration.getTimeout()) { Assert.fail("Timeout"); } count++; Thread.sleep(1000); try { GetStatusResponse response = client.getStatusResponse(request); Assert.assertEquals(Enum.valueOf(OsgpResultType.class, expectedResult.get(Keys.KEY_RESULT)), response.getResult()); success = true; } catch(Exception ex) { } } }

Target:
public void thePlatformBuffersADeviceInstallationGetStatusResponseMessageForDevice( final String deviceIdentification, final Map<String, String> expectedResult) throws Throwable { final GetStatusAsyncRequest request = new GetStatusAsyncRequest(); final AsyncRequest asyncRequest = new AsyncRequest(); asyncRequest.setDeviceId(deviceIdentification); asyncRequest.setCorrelationUid((String) ScenarioContext.Current().get(Keys.KEY_CORRELATION_UID)); request.setAsyncRequest(asyncRequest); GetStatusResponse response = null; boolean success = false; int count = 0; while (!success) { if (count > this.configuration.getTimeout()) { Assert.fail("Timeout"); } count++; Thread.sleep(1000); try { response = this.client.getStatusResponse(request); success = true; } catch (final Exception ex) { } } Assert.assertEquals(Enum.valueOf(OsgpResultType.class, expectedResult.get(Keys.KEY_RESULT)), response.getResult()); }
Source:
public void setBackgroundColor(Color bg) { super.setBackgroundColor(bg); if (bg == null) { ((AdvancedRoundedRectangle) top).setBorderColor(getLocalForegroundColor()); middle.setBorderColor(getLocalForegroundColor()); bottom.setBorderColor(getLocalForegroundColor()); } else { ((AdvancedRoundedRectangle) top).setBorderColor(ColorHelper.darker(bg)); middle.setBorderColor(ColorHelper.darker(bg)); bottom.setBorderColor(ColorHelper.darker(bg)); } }

Target:
public void setBackgroundColor(Color bg) { super.setBackgroundColor(bg); if (bg == null) { ((AdvancedRoundedRectangle) top).setBorderColor(getLocalForegroundColor()); middle.setBorderColor(getLocalForegroundColor()); bottom.setBorderColor(getLocalForegroundColor()); } else { Color darkerColor = ColorHelper.darker(bg); ((AdvancedRoundedRectangle) top).setBorderColor(darkerColor); middle.setBorderColor(darkerColor); bottom.setBorderColor(darkerColor); } }
Source:
protected void analyzeCivar() { int minimumTemplateSize = 0; boolean expands = false; int starCount = 0; boolean hasEmbeddedCivars = false; boolean hasOptionalElements = false; boolean allElementsAreOptional = true; boolean hasVariation = false; StringBuilder strBuffer = new StringBuilder(100); for (final Element e : elements) { strBuffer.append(e.toString()); if (e.operator() == Operator.EMBEDDED) { hasEmbeddedCivars = true; if (e.embedded.hasVariation()) { hasVariation = true; allElementsAreOptional &= (e.optional || e.embedded.allElementsAreOptional()); hasOptionalElements |= e.optional || e.embedded.hasOptionalVariationElements(); } minimumTemplateSize += e.embedded.minimumTemplateSequenceSize(); if (e.embedded.expands()) { expands = true; starCount += e.embedded.starCount(); } } else { if (e.isVariant()) { hasVariation = true; allElementsAreOptional &= e.optional; hasOptionalElements |= e.optional; } if (e.expands()) { starCount += e.size(); expands = true; continue; } if (e.operator() == Operator.INSERTION) continue; minimumTemplateSize += e.size(); } } this.string = strBuffer.toString(); this.hasVariation = hasVariation; this.allVariationIsOptional = allElementsAreOptional; this.hasOptionalVariation = hasOptionalElements; this.hasEmbeddedCivars = hasEmbeddedCivars; this.starCount = starCount; this.expands = expands; this.minimumTemplateSize = minimumTemplateSize; }

Target:
protected void analyzeCivar() { int minimumTemplateSize = 0; boolean expands = false; int starCount = 0; boolean hasEmbeddedCivars = false; boolean hasOptionalElements = false; boolean allElementsAreOptional = true; boolean hasVariation = false; StringBuilder strBuilder = new StringBuilder(100); for (final Element e : elements) { strBuilder.append(e.toString()); if (e.operator() == Operator.EMBEDDED) { hasEmbeddedCivars = true; if (e.embedded.hasVariation()) { hasVariation = true; allElementsAreOptional &= (e.optional || e.embedded.allElementsAreOptional()); hasOptionalElements |= e.optional || e.embedded.hasOptionalVariationElements(); } minimumTemplateSize += e.embedded.minimumTemplateSequenceSize(); if (e.embedded.expands()) { expands = true; starCount += e.embedded.starCount(); } } else { if (e.isVariant()) { hasVariation = true; allElementsAreOptional &= e.optional; hasOptionalElements |= e.optional; } if (e.expands()) { starCount += e.size(); expands = true; continue; } if (e.operator() == Operator.INSERTION) continue; minimumTemplateSize += e.size(); } } this.string = strBuilder.toString(); this.hasVariation = hasVariation; this.allVariationIsOptional = allElementsAreOptional; this.hasOptionalVariation = hasOptionalElements; this.hasEmbeddedCivars = hasEmbeddedCivars; this.starCount = starCount; this.expands = expands; this.minimumTemplateSize = minimumTemplateSize; }
Source:
Command[] getCommands() { if (root != null) { return root.getCommands(); } else { return commands; } }

Target:
Command[] getCommands() { return root != null ? root.getCommands() : commands; }
Source:
public static synchronized Long convertTimestampToMillis(String timestamp) { if (timestamp == null || timestamp.length() == 0) return null; timestamp = timestamp.replaceFirst("\\+.*", "Z"); try { return FORMATTER.parse(timestamp).getTime(); } catch (ParseException e) { return 0L; } }

Target:
public static Long convertTimestampToMillis(String timestamp) { if (timestamp == null || timestamp.length() == 0) return null; timestamp = timestamp.replaceFirst("\\+.*", "Z"); try { return DATE_FORMAT.get().parse(timestamp).getTime(); } catch (ParseException e) { return 0L; } }
Source:
public List<SolrInputDocument> add(List<Metacard> metacards, boolean forceAutoCommit) throws IOException, SolrServerException, MetacardCreationException { if (CollectionUtils.isEmpty(metacards)) { return Collections.emptyList(); } boolean isNrtCommit = false; List<SolrInputDocument> docs = new ArrayList<>(); for (Metacard metacard : metacards) { docs.add(getSolrInputDocument(metacard)); if (commitNrtMetacardType.contains(metacard.getMetacardType().getName())) { isNrtCommit = true; } } if (!forceAutoCommit) { if (isNrtCommit) { client.add(docs, commitNRtCommitWithinMs); } else { client.add(docs); } } else { softCommit(docs); } return docs; }

Target:
public List<SolrInputDocument> add(List<Metacard> metacards, boolean forceAutoCommit) throws IOException, SolrServerException, MetacardCreationException { if (CollectionUtils.isEmpty(metacards)) { return Collections.emptyList(); } boolean isNrtCommit = false; List<SolrInputDocument> docs = new ArrayList<>(); for (Metacard metacard : metacards) { docs.add(getSolrInputDocument(metacard)); if (commitNrtMetacardType.contains(metacard.getMetacardType().getName())) { isNrtCommit = true; } } if (!forceAutoCommit) { if (isNrtCommit) { client.add(docs, commitNrtCommitWithinMs); } else { client.add(docs); } } else { softCommit(docs); } return docs; }
Source:
public Object prepare(Object value) { Assert.notNull(value, "Value must not be null!"); Class<? extends T> expressionType = expression.getJavaType(); if (String.class.equals(expressionType)) { switch (type) { case STARTING_WITH: return value + "%"; case ENDING_WITH: return "%" + value; case CONTAINING: case NOT_CONTAINING: return "%" + value + "%"; default: return value; } } return Collection.class.isAssignableFrom(expressionType) ? persistenceProvider.potentiallyConvertEmptyCollection(upperIfIgnoreCase(part, toCollection(value))) : value; }

Target:
public Object prepare(Object value) { Assert.notNull(value, "Value must not be null!"); Class<? extends T> expressionType = expression.getJavaType(); if (String.class.equals(expressionType)) { switch (type) { case STARTING_WITH: return String.format("%s%%", value.toString()); case ENDING_WITH: return String.format("%%%s", value.toString()); case CONTAINING: case NOT_CONTAINING: return String.format("%%%s%%", value.toString()); default: return value; } } return Collection.class.isAssignableFrom(expressionType) ? persistenceProvider.potentiallyConvertEmptyCollection(upperIfIgnoreCase(ignoreCase, toCollection(value))) : value; }
Source:
public void testDirectReflection () throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Foo foo = new Foo(); foo.setMetadata(meta); assertTrue(ReflectUtils.objectMetadata(foo) == meta); }

Target:
public void testDirectReflection () throws ReflectiveOperationException { ObjectMeta meta = new ObjectMeta(); Foo foo = new Foo(); foo.setMetadata(meta); assertSame(meta, ReflectUtils.objectMetadata(foo)); }
Source:
protected void unblockOtherNode(Object waiter, Executor executor) { if (!(waiter instanceof Waiter)) { return; } Object value = resolve(state); if (waiter instanceof AcceptNode) { AcceptNode acceptNode = (AcceptNode) waiter; acceptNode.execute(executor, value); } else if (waiter instanceof ApplyNode) { ApplyNode applyNode = (ApplyNode) waiter; applyNode.execute(executor, value); } else if (waiter instanceof RunNode) { RunNode runNode = (RunNode) waiter; runNode.execute(executor, value); } else if (waiter instanceof AbstractInvocationFuture.WhenCompleteNode) { WhenCompleteNode whenCompleteNode = (WhenCompleteNode) waiter; Throwable t = (value instanceof ExceptionalResult) ? ((ExceptionalResult) value).cause : null; value = (value instanceof ExceptionalResult) ? null : value; whenCompleteNode.execute(executor, value, t); } else if (waiter instanceof HandleNode) { HandleNode handleNode = (HandleNode) waiter; Throwable t = (value instanceof ExceptionalResult) ? ((ExceptionalResult) value).cause : null; value = (value instanceof ExceptionalResult) ? null : value; handleNode.execute(executor, value, t); } else if (waiter instanceof ExceptionallyNode) { ((ExceptionallyNode) waiter).execute(value); } else if (waiter instanceof ComposeNode) { ((ComposeNode) waiter).execute(executor, value); } else if (waiter instanceof AbstractBiNode) { ((AbstractBiNode) waiter).execute(executor, value); } else if (waiter instanceof AbstractEitherNode) { ((AbstractEitherNode) waiter).execute(executor, value); } }

Target:
protected void unblockOtherNode(Object waiter, Executor executor) { if (!(waiter instanceof Waiter)) { return; } Object value = resolve(state); if (waiter instanceof UniWaiter) { ((UniWaiter) waiter).execute(executor, value); } else if (waiter instanceof BiWaiter) { Throwable t = (value instanceof ExceptionalResult) ? ((ExceptionalResult) value).cause : null; value = (value instanceof ExceptionalResult) ? null : value; ((BiWaiter) waiter).execute(executor, value, t); } else if (waiter instanceof ExceptionallyNode) { ((ExceptionallyNode) waiter).execute(value); } }
Source:
public CompletableFuture<String> getsAsync(String row, Column column) { if (asyncReader == null) { asyncReader = new AsyncReader(this); } return asyncReader.gets(row, column); }

Target:
public CompletableFuture<String> getsAsync(String row, Column column) { return getAsyncReader().gets(row, column); }
Source:
public static EndpointContextMatcher create(Connector connector, NetworkConfig config) { String protocol = null; if (null != connector) { protocol = connector.getProtocol(); if (CoAP.PROTOCOL_TCP.equalsIgnoreCase(protocol)) { return new TcpEndpointContextMatcher(); } else if (CoAP.PROTOCOL_TLS.equalsIgnoreCase(protocol)) { return new TlsEndpointContextMatcher(); } } String textualMode = "???"; MatcherMode mode = MatcherMode.STRICT; try { textualMode = config.getString(NetworkConfig.Keys.RESPONSE_MATCHING); mode = MatcherMode.valueOf(textualMode); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Response matching mode '" + textualMode + "' not supported!"); } catch (NullPointerException e) { throw new IllegalArgumentException("Response matching mode not provided/configured!"); } switch (mode) { case STRICT: break; case RELAXED: if (CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new UdpEndpointContextMatcher(false); } else { return new RelaxedDtlsEndpointContextMatcher(); } case PRINCIPAL: if (!CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new PrincipalEndpointContextMatcher(); } } if (CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new UdpEndpointContextMatcher(true); } else { return new StrictDtlsEndpointContextMatcher(); } }

Target:
public static EndpointContextMatcher create(Connector connector, NetworkConfig config) { String protocol = null; if (null != connector) { protocol = connector.getProtocol(); if (CoAP.PROTOCOL_TCP.equalsIgnoreCase(protocol)) { return new TcpEndpointContextMatcher(); } else if (CoAP.PROTOCOL_TLS.equalsIgnoreCase(protocol)) { return new TlsEndpointContextMatcher(); } } String textualMode = "???"; MatcherMode mode = MatcherMode.STRICT; try { textualMode = config.getString(NetworkConfig.Keys.RESPONSE_MATCHING); mode = MatcherMode.valueOf(textualMode); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Response matching mode '" + textualMode + "' not supported!"); } catch (NullPointerException e) { throw new IllegalArgumentException("Response matching mode not provided/configured!"); } switch (mode) { case RELAXED: if (CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new UdpEndpointContextMatcher(false); } else { return new RelaxedDtlsEndpointContextMatcher(); } case PRINCIPAL: if (CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new UdpEndpointContextMatcher(false); } else { return new PrincipalEndpointContextMatcher(); } case STRICT: default: if (CoAP.PROTOCOL_UDP.equalsIgnoreCase(protocol)) { return new UdpEndpointContextMatcher(true); } else { return new StrictDtlsEndpointContextMatcher(); } } }
Source:
public int onCollisionHighScoreIncrement() { return (int) Math.max(element.getSize() + element.getSpeed() - element.getSize(), 0); }

Target:
public int onCollisionHighScoreIncrement() { return (int) Math.max(element.getSize() + element.getSpeed(), 0); }
Source:
private static int readIntFromByteChannel(ReadableByteChannel channel) { ByteBuffer intBuffer = ByteBuffer.allocate(INT_BYTES); int result = -1; try { while (intBuffer.hasRemaining() && (channel.read(intBuffer) >= 0)) { } if (!intBuffer.hasRemaining()) { intBuffer.rewind(); result = intBuffer.asIntBuffer().get(0); } } catch (Exception ignored) { } return result; }

Target:
private static int readIntFromByteChannel(ReadableByteChannel channel) throws IOException { ByteBuffer intBuffer = ByteBuffer.allocate(INT_BYTES); int result = -1; while (intBuffer.hasRemaining() && (channel.read(intBuffer) >= 0)) { } if (!intBuffer.hasRemaining()) { intBuffer.rewind(); result = intBuffer.asIntBuffer().get(0); } return result; }
Source:
public Node getParentNode(long nodeId) { List<Node> nodes = new ArrayList<>(); getParentNodes(null, nodeContainer, nodes, nodeId); if (nodes.size() > 0) { return nodes.get(0); } return null; }

Target:
public Node getParentNode(long nodeId) { return getContainerNode(null, nodeContainer, nodeId); }
Source:
public synchronized void stop(final StopContext context) { ServiceName top = deploymentUnit.getParent() != null ? deploymentUnit.getParent().getServiceName() : deploymentUnit.getServiceName(); ServiceController<?> topController = context.getController().getServiceContainer().getService(top); if(topController.getMode() != Mode.REMOVE && topController.getMode() != Mode.NEVER && !context.getController().getServiceContainer().isShutdown()) { ServerLogger.DEPLOYMENT_LOGGER.deploymentRestartDetected(deploymentUnit.getName()); topController.addListener(new AbstractServiceListener<Object>() { @Override public void transition(final ServiceController<?> controller, final ServiceController.Transition transition) { if(transition.getAfter().equals(ServiceController.Substate.DOWN)) { controller.compareAndSetMode(Mode.NEVER, Mode.ACTIVE); controller.removeListener(this); } } }); topController.setMode(Mode.NEVER); } final DeploymentUnit deploymentUnitContext = deploymentUnit; final DeployerChains chains = deployerChainsInjector.getValue(); final List<RegisteredDeploymentUnitProcessor> list = chains.getChain(phase); final ListIterator<RegisteredDeploymentUnitProcessor> iterator = list.listIterator(list.size()); while (iterator.hasPrevious()) { final RegisteredDeploymentUnitProcessor prev = iterator.previous(); safeUndeploy(deploymentUnitContext, phase, prev); } }

Target:
public synchronized void stop(final StopContext context) { ServiceName top = deploymentUnit.getParent() != null ? deploymentUnit.getParent().getServiceName() : deploymentUnit.getServiceName(); ServiceController<?> topController = context.getController().getServiceContainer().getService(top); Mode mode = topController.getMode(); if (mode != Mode.REMOVE && mode != Mode.NEVER && !context.getController().getServiceContainer().isShutdown()) { AbstractServiceListener<Object> serviceListener = new AbstractServiceListener<Object>() { @Override public void transition(final ServiceController<?> controller, final ServiceController.Transition transition) { if (transition.getAfter().equals(ServiceController.Substate.DOWN)) { controller.compareAndSetMode(Mode.NEVER, Mode.ACTIVE); controller.removeListener(this); } } }; topController.addListener(serviceListener); if (topController.compareAndSetMode(mode, Mode.NEVER)) { ServerLogger.DEPLOYMENT_LOGGER.deploymentRestartDetected(deploymentUnit.getName()); } else { topController.removeListener(serviceListener); } } final DeploymentUnit deploymentUnitContext = deploymentUnit; final DeployerChains chains = deployerChainsInjector.getValue(); final List<RegisteredDeploymentUnitProcessor> list = chains.getChain(phase); final ListIterator<RegisteredDeploymentUnitProcessor> iterator = list.listIterator(list.size()); while (iterator.hasPrevious()) { final RegisteredDeploymentUnitProcessor prev = iterator.previous(); safeUndeploy(deploymentUnitContext, phase, prev); } }
Source:
private String getProcessorID(String stepping, String model, String family, String[] flags) { boolean procInfo = false; String marker = "Processor Information"; for (String checkLine : ExecutingCommand.runNative("dmidecode -t system")) { if (!procInfo && checkLine.contains(marker)) { marker = "ID:"; procInfo = true; } else if (procInfo && checkLine.contains(marker)) { return checkLine.split(marker)[1].trim(); } } marker = "eax="; for (String checkLine : ExecutingCommand.runNative("cpuid -1r")) { if (checkLine.contains(marker) && checkLine.trim().startsWith("0x00000001")) { String eax = ""; String edx = ""; for (String register : ParseUtil.whitespace.split(checkLine)) { if (register.startsWith("eax=")) { eax = StringUtils.replace(register, "eax=0x", ""); } else if (register.startsWith("edx=")) { edx = StringUtils.replace(register, "edx=0x", ""); } } return edx + eax; } } return createProcessorID(stepping, model, family, flags); }

Target:
private String getProcessorID(String stepping, String model, String family, String[] flags) { boolean procInfo = false; String marker = "Processor Information"; for (String checkLine : ExecutingCommand.runNative("dmidecode -t system")) { if (!procInfo && checkLine.contains(marker)) { marker = "ID:"; procInfo = true; } else if (procInfo && checkLine.contains(marker)) { return checkLine.split(marker)[1].trim(); } } marker = "eax="; for (String checkLine : ExecutingCommand.runNative("cpuid -1r")) { if (checkLine.contains(marker) && checkLine.trim().startsWith("0x00000001")) { String eax = ""; String edx = ""; for (String register : ParseUtil.whitespaces.split(checkLine)) { if (register.startsWith("eax=")) { eax = ParseUtil.removeMatchingString(register, "eax=0x"); } else if (register.startsWith("edx=")) { edx = ParseUtil.removeMatchingString(register, "edx=0x"); } } return edx + eax; } } return createProcessorID(stepping, model, family, flags); }
Source:
public ImmutableCollection<MapView> getLoadedMaps() { ImmutableList.Builder<MapView> builder = ImmutableList.builder(); loadedDataList.forEach(entry -> { if (entry instanceof MapView) { builder.add((MapView) entry); } }); return builder.build(); }

Target:
public ImmutableCollection<MapView> getLoadedMaps() { return loadedDataList.stream().filter(MapView.class::isInstance) .map(MapView.class::cast).collect(ImmutableList.toImmutableList()); }
Source:
public static <T> Option<T> empty() { return new Option<>(null); }

Target:
public static <T> Option<T> empty() { @SuppressWarnings("unchecked") Option<T> empty = (Option<T>) EMPTY; return empty; }
Source:
private void writeFeatures() { if (vm.getClusterArch().getFamily() != ArchitectureType.x86) { return; } boolean acpiEnabled = vm.getAcpiEnable(); boolean kaslr = vmInfoBuildUtils.isKASLRDumpEnabled(vm.getVmOsId()); boolean ovmfEnabled = vm.getBiosType().isOvmf(); if (!acpiEnabled && !hypervEnabled && !kaslr && !ovmfEnabled) { return; } writer.writeStartElement("features"); if (acpiEnabled) { writer.writeElement("acpi"); } if (hypervEnabled) { writer.writeStartElement("hyperv"); writer.writeStartElement("relaxed"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); writer.writeStartElement("vapic"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); writer.writeStartElement("spinlocks"); writer.writeAttributeString("state", "on"); writer.writeAttributeString("retries", "8191"); writer.writeEndElement(); writer.writeEndElement(); } if (kaslr) { writer.writeElement("vmcoreinfo"); } if (ovmfEnabled) { writer.writeStartElement("smm"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); } writer.writeEndElement(); }

Target:
private void writeFeatures() { if (vm.getClusterArch().getFamily() != ArchitectureType.x86) { return; } boolean acpiEnabled = vm.getAcpiEnable(); boolean kaslrEnabled = vmInfoBuildUtils.isKASLRDumpEnabled(vm.getVmOsId()); boolean ovmfEnabled = vm.getBiosType().isOvmf(); if (!acpiEnabled && !hypervEnabled && !kaslrEnabled && !ovmfEnabled) { return; } writer.writeStartElement("features"); if (acpiEnabled) { writer.writeElement("acpi"); } if (hypervEnabled) { writer.writeStartElement("hyperv"); writer.writeStartElement("relaxed"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); writer.writeStartElement("vapic"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); writer.writeStartElement("spinlocks"); writer.writeAttributeString("state", "on"); writer.writeAttributeString("retries", "8191"); writer.writeEndElement(); writer.writeEndElement(); } if (kaslrEnabled) { writer.writeElement("vmcoreinfo"); } if (ovmfEnabled) { writer.writeStartElement("smm"); writer.writeAttributeString("state", "on"); writer.writeEndElement(); } writer.writeEndElement(); }
Source:
public int addPartition(String table, String partition) throws IOException, InterruptedException { String queryStr = "ALTER TABLE " + table + " ADD IF NOT EXISTS PARTITION (" + partition + ")"; int commandId = query(queryStr); return waitForCompletion(commandId, MAX_QUBOLE_WAIT_TIME_MS); }

Target:
public void addPartition(String table, String partition) throws IOException, InterruptedException { String queryStr = "ALTER TABLE " + table + " ADD IF NOT EXISTS PARTITION (" + partition + ")"; int commandId = query(queryStr); waitForCompletion(commandId, MAX_QUBOLE_WAIT_TIME_MS); }
Source:
private void printCacheHelp() { log(i("The '" + CACHE + " subcommand' is used to get information about and perform actions with caches. The command has the following syntax:")); nl(); log(i(UTILITY_NAME_WITH_COMMON_OPTIONS + " " + CACHE + " [subcommand] <subcommand_parameters>")); nl(); log(i("The subcommands that take " + OP_NODE_ID + " as an argument ('" + LIST + "', '" + CONTENTION + "' and '" + VALIDATE_INDEXES + "') will be executed on the given node or on all server nodes if the option is not specified. Other commands will run on a random server node.")); nl(); nl(); log(i("Subcommands:")); String CACHES = "cacheName1,...,cacheNameN"; usageCache(LIST, "regexPattern", op(or(GROUP, SEQUENCE)), OP_NODE_ID, op(CONFIG), op(OUTPUT_FORMAT, MULTI_LINE)); usageCache(CONTENTION, "minQueueSize", OP_NODE_ID, op("maxPrint")); usageCache(IDLE_VERIFY, op(DUMP), op(SKIP_ZEROS), op(CHECK_CRC), op(EXCLUDE_CACHES, CACHES), op(CACHE_FILTER, or("ALL|USER|SYSTEM|PERSISTENT|NON_PERSISTENT")), op(CACHES)); usageCache(VALIDATE_INDEXES, op(CACHES), OP_NODE_ID, op(or(CHECK_FIRST + " N", CHECK_THROUGH + " K"))); usageCache(DISTRIBUTION, or(NODE_ID, NULL), op(CACHES), op(USER_ATTRIBUTES, "attrName1,...,attrNameN")); usageCache(RESET_LOST_PARTITIONS, CACHES); nl(); }

Target:
private void printCacheHelp() { log(i("The '" + CACHE + " subcommand' is used to get information about and perform actions with caches. The command has the following syntax:")); nl(); log(i(UTILITY_NAME_WITH_COMMON_OPTIONS + " " + CACHE + " [subcommand] <subcommand_parameters>")); nl(); log(i("The subcommands that take " + OP_NODE_ID + " as an argument ('" + LIST + "', '" + CONTENTION + "' and '" + VALIDATE_INDEXES + "') will be executed on the given node or on all server nodes if the option is not specified. Other commands will run on a random server node.")); nl(); nl(); log(i("Subcommands:")); String CACHES = "cacheName1,...,cacheNameN"; usageCache(LIST, "regexPattern", op(or(GROUP, SEQUENCE)), OP_NODE_ID, op(CONFIG), op(OUTPUT_FORMAT, MULTI_LINE)); usageCache(CONTENTION, "minQueueSize", OP_NODE_ID, op("maxPrint")); usageCache(IDLE_VERIFY, op(DUMP), op(SKIP_ZEROS), op(CHECK_CRC), op(EXCLUDE_CACHES, CACHES), op(CACHE_FILTER, or(ALL, USER, SYSTEM, PERSISTENT, NOT_PERSISTENT)), op(CACHES)); usageCache(VALIDATE_INDEXES, op(CACHES), OP_NODE_ID, op(or(CHECK_FIRST + " N", CHECK_THROUGH + " K"))); usageCache(DISTRIBUTION, or(NODE_ID, NULL), op(CACHES), op(USER_ATTRIBUTES, "attrName1,...,attrNameN")); usageCache(RESET_LOST_PARTITIONS, CACHES); nl(); }
Source:
protected void runAsync(final Runnable runnable) throws Exception { Executors.newSingleThreadExecutor().submit(runnable).get(); }

Target:
protected void runAsync(final Runnable runnable) throws Exception { final ExecutorService service = Executors.newSingleThreadExecutor(); service.submit(runnable); service.shutdown(); }
Source:
public <T> T insert(String containerName, T objectToSave) { return insert(getContainerName(objectToSave.getClass()), objectToSave, null); }

Target:
public <T> T insert(String containerName, T objectToSave) { return insert(containerName, objectToSave, null); }
Source:
public static <O> ScrollResult<O> emptyResult() { return EMPTY_RESULT; }

Target:
public static <O> ScrollResult<O> emptyResult() { return (ScrollResult<O>) EMPTY_RESULT; }
Source:
private Object getPropertyViaGetter(Object object, GraphQLOutputType outputType) { boolean isBooleanProperty = isBooleanProperty(outputType); String prefix = isBooleanProperty ? "is" : "get"; try { return getPropertyViaGetterUsingPrefix(object, outputType, prefix); } catch (NoSuchMethodException e) { if (isBooleanProperty){ try { return getPropertyViaGetterUsingPrefix(object, outputType, "get"); } catch (NoSuchMethodException e1) { return getPropertyViaFieldAccess(object, outputType); } }else{ return getPropertyViaFieldAccess(object, outputType); } } }

Target:
private Object getPropertyViaGetter(Object object, GraphQLOutputType outputType) { try { if (isBooleanProperty(outputType)) { try { return getPropertyViaGetterUsingPrefix(object, "is"); } catch (NoSuchMethodException e) { return getPropertyViaGetterUsingPrefix(object, "get"); } } else { return getPropertyViaGetterUsingPrefix(object, "get"); } } catch (NoSuchMethodException e1) { return getPropertyViaFieldAccess(object); } }
Source:
public synchronized ICommandResult executeCommand(List<String> command, IProgressMonitor monitor) throws ExecutionException { Map<String, ICommandResult> commands = fScenarioMap.get(fScenario); String commandLine = toCommandSring(command); String fullCommand = commandLine; Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(commandLine); if (matcher.matches() && !commandLine.matches(LTTNG_LIST_PROVIDER_PATTERN)) { String sessionName = matcher.group(1).trim(); Integer i = fSessionNameMap.get(sessionName); if (i != null) { i++; } else { i = 0; } fSessionNameMap.put(sessionName, i); fullCommand += String.valueOf(i); } if (commands.containsKey(fullCommand)) { return commands.get(fullCommand); } String[] output = new String[1]; output[0] = String.valueOf("Command not found"); CommandResult result = new CommandResult(0, null, null); result.setOutput(output); result.setErrorOutput(output); result.setResult(1); return result; }

Target:
public synchronized ICommandResult executeCommand(List<String> command, IProgressMonitor monitor) throws ExecutionException { Map<String, ICommandResult> commands = fScenarioMap.get(fScenario); String commandLine = LTTngControlService.toCommandString(command); String fullCommand = commandLine; Matcher matcher = LTTNG_LIST_SESSION_PATTERN.matcher(commandLine); if (matcher.matches() && !commandLine.matches(LTTNG_LIST_PROVIDER_PATTERN)) { String sessionName = matcher.group(1).trim(); Integer i = fSessionNameMap.get(sessionName); if (i != null) { i++; } else { i = 0; } fSessionNameMap.put(sessionName, i); fullCommand += String.valueOf(i); } if (commands.containsKey(fullCommand)) { return commands.get(fullCommand); } String[] output = new String[1]; output[0] = String.valueOf("Command not found"); CommandResult result = new CommandResult(0, null, null); result.setOutput(output); result.setErrorOutput(output); result.setResult(1); return result; }
Source:
private List evaluateExpressionsInContext(EvaluationContext ctx, List expressions) { List results = new ArrayList(); for (Object v : expressions) { try { ctx.enterFrame(); ctx.setValue("item", v); ctx.setRootObject(v); Object r = this.filter.evaluate(ctx); if (r == null) { return null; } if (r instanceof Boolean && ((Boolean) r) == Boolean.TRUE) { results.add(v); } } finally { ctx.exitFrame(); } } return results; }

Target:
private List evaluateExpressionsInContext(EvaluationContext ctx, List expressions) { List results = new ArrayList(); expressions.forEach(expression -> evaluateExpressionInContext( ctx, results, expression)); return results; }
Source:
protected Object calculate() { StringBuilder sb = new StringBuilder(); try { StringTokenizer tokenizer = new StringTokenizer(expression, "$", true); if (expression.isEmpty() || tokenizer.countTokens() == 0) { throw new IllegalArgumentException("Expression must not be empty."); } boolean inExpression = false; boolean foundToken = false; while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("$")) { if (inExpression && !foundToken) { throw new IllegalArgumentException("Empty reference ($$) in message is not allowed."); } inExpression = !inExpression; } else if (inExpression) { IObservableValue value = expressionMap.get(token); sb.append(value.getValue()); foundToken = true; } else { sb.append(token); } } if (inExpression) { throw new IllegalArgumentException("Inconsistent model references - a $ character is missing."); } } catch (IllegalArgumentException e) { return "ERROR: " + e.getMessage(); } return sb.toString(); }

Target:
protected Object calculate() { StringBuilder sb = new StringBuilder(); try { for (int i = 0; i < expressionTokens.size(); i++) { String token = expressionTokens.get(i); if ((i % 2) == 0) { Preconditions.checkState(expressionMap.containsKey(token), "Error while parsing expression " + token); IObservableValue value = expressionMap.get(token); sb.append(value.getValue()); } else { sb.append(token); } } } catch (Exception e) { return "ERROR: " + e.getMessage(); } return sb.toString(); }