auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private SampleListDTO translateToSampleListDto(final SampleListDto dto) throws ParseException { final SampleListDTO sampleListDTO = new SampleListDTO(); sampleListDTO.setCreatedBy(securityService.getCurrentlyLoggedInUser().getName()); sampleListDTO.setCropName(dto.getCropName()); sampleListDTO.setDescription(dto.getDescription()); sampleListDTO.setInstanceIds(dto.getInstanceIds()); sampleListDTO.setNotes(dto.getNotes()); if (!dto.getSamplingDate().isEmpty()) { sampleListDTO.setSamplingDate(DateUtil.getSimpleDateFormat(DateUtil.FRONTEND_DATE_FORMAT).parse(dto.getSamplingDate())); } sampleListDTO.setSelectionVariableId(dto.getSelectionVariableId()); sampleListDTO.setStudyId(dto.getStudyId()); sampleListDTO.setTakenBy(dto.getTakenBy()); return sampleListDTO; }

Target:
private SampleListDTO translateToSampleListDto(final SampleListDto dto) throws ParseException { final SampleListDTO sampleListDTO = new SampleListDTO(); sampleListDTO.setCreatedBy(this.securityService.getCurrentlyLoggedInUser().getName()); sampleListDTO.setCropName(dto.getCropName()); sampleListDTO.setDescription(dto.getDescription()); sampleListDTO.setInstanceIds(dto.getInstanceIds()); sampleListDTO.setNotes(dto.getNotes()); if (!dto.getSamplingDate().isEmpty()) { sampleListDTO.setSamplingDate(DateUtil.getSimpleDateFormat(DateUtil.FRONTEND_DATE_FORMAT).parse(dto.getSamplingDate())); } sampleListDTO.setSelectionVariableId(dto.getSelectionVariableId()); sampleListDTO.setStudyId(dto.getStudyId()); sampleListDTO.setTakenBy(dto.getTakenBy()); return sampleListDTO; }
Source:
private ForwardIndexReader<?> getForwardIndexReader(ColumnMetadata columnMetadata) throws IOException { if (!columnMetadata.hasDictionary()) { PinotDataBuffer buffer = _segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); return new VarByteChunkSVForwardIndexReader(buffer, DataType.STRING); } else { PinotDataBuffer buffer = _segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); int numRows = columnMetadata.getTotalDocs(); int numBitsPerValue = columnMetadata.getBitsPerElement(); return new FixedBitSVForwardIndexReader(buffer, numRows, numBitsPerValue); } }

Target:
private ForwardIndexReader<?> getForwardIndexReader(ColumnMetadata columnMetadata) throws IOException { if (!columnMetadata.hasDictionary()) { PinotDataBuffer buffer = _segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); return new VarByteChunkSVForwardIndexReader(buffer, DataType.STRING); } else { PinotDataBuffer buffer = _segmentWriter.getIndexFor(columnMetadata.getColumnName(), ColumnIndexType.FORWARD_INDEX); int numRows = columnMetadata.getTotalDocs(); int numBitsPerValue = columnMetadata.getBitsPerElement(); if (columnMetadata.isSorted()) { return new SortedIndexReaderImpl(buffer, columnMetadata.getCardinality()); } else { return new FixedBitSVForwardIndexReader(buffer, numRows, numBitsPerValue); } } }
Source:
public void setDate(long timeInMilliseconds) { Calendar tempDate = Calendar.getInstance(mConstant.locale); tempDate.setTimeInMillis(timeInMilliseconds); setDate(tempDate.get(Calendar.YEAR), tempDate.get(Calendar.MONTH), tempDate.get(Calendar.DAY_OF_MONTH), false); }

Target:
public void setDate(long timeInMilliseconds) { mTempDate.setTimeInMillis(timeInMilliseconds); setDate(mTempDate.get(Calendar.YEAR), mTempDate.get(Calendar.MONTH), mTempDate.get(Calendar.DAY_OF_MONTH), false); }
Source:
private void flushAll() throws AuthException { for (DynamicMap.Entry<Cache<?, ?>> e : cacheMap) { CacheResource cacheResource = new CacheResource(e.getPluginName(), e.getExportName(), e.getProvider()); if (FlushCache.WEB_SESSIONS.equals(cacheResource.getName())) { continue; } flushCache.get().apply(cacheResource, new FlushCache.Input()); } }

Target:
private void flushAll() throws AuthException { for (DynamicMap.Entry<Cache<?, ?>> e : cacheMap) { CacheResource cacheResource = new CacheResource(e.getPluginName(), e.getExportName(), e.getProvider()); if (FlushCache.WEB_SESSIONS.equals(cacheResource.getName())) { continue; } flushCache.apply(cacheResource, null); } }
Source:
public void testElementMultipleRoots() throws XMLStreamException { XMLStreamWriter writer = new JsonXMLOutputFactory().createXMLStreamWriter(new StringWriter()); writer.writeStartDocument(); writer.writeStartElement("foo"); writer.writeEndElement(); writer.writeStartElement("bar"); Assert.fail("execution successful without expected exception"); }

Target:
public void testElementMultipleRoots() throws XMLStreamException { XMLStreamWriter writer = new JsonXMLOutputFactory().createXMLStreamWriter(new StringWriter()); writer.writeStartDocument(); writer.writeStartElement("foo"); writer.writeEndElement(); writer.writeStartElement("bar"); }
Source:
public boolean softKill(final long time, final TimeUnit unit) throws InterruptedException { checkStarted(); if (processId != 0 && isStarted()) { try { if (isExecuteAsUser) { String cmd = String.format("%s %s kill %d", executeAsUserBinary, effectiveUser, processId); Runtime.getRuntime().exec(cmd); } else { Runtime.getRuntime().exec("kill " + processId); } return completeLatch.await(time, unit); } catch (IOException e) { logger.error("Kill attempt failed.", e); } return false; } return false; }

Target:
public boolean softKill(final long time, final TimeUnit unit) throws InterruptedException { checkStarted(); if (processId != 0 && isStarted()) { try { if (isExecuteAsUser) { String cmd = String.format("%s %s %s %d", executeAsUserBinary, effectiveUser, KILL_COMMAND, processId); Runtime.getRuntime().exec(cmd); } else { String cmd = String.format("%s %d", KILL_COMMAND, processId); Runtime.getRuntime().exec(cmd); } return completeLatch.await(time, unit); } catch (IOException e) { logger.error("Kill attempt failed.", e); } return false; } return false; }
Source:
private void createTableReplLogTask(String tableName, TableType tableType) throws SemanticException { ReplStateLogWork replLogWork = new ReplStateLogWork(replLogger,tableName, tableType); Task<ReplStateLogWork> replLogTask = TaskFactory.get(replLogWork, context.hiveConf); ReplLoadTask.dependency(tracker.tasks(), replLogTask); }

Target:
private void createTableReplLogTask(String tableName, TableType tableType) throws SemanticException { ReplStateLogWork replLogWork = new ReplStateLogWork(replLogger,tableName, tableType); Task<ReplStateLogWork> replLogTask = TaskFactory.get(replLogWork, context.hiveConf); ReplLoadTask.dependency(tracker.tasks(), replLogTask); if (tracker.tasks().isEmpty()) { tracker.addTask(replLogTask); } else { ReplLoadTask.dependency(tracker.tasks(), replLogTask); List<Task<? extends Serializable>> visited = new ArrayList<>(); tracker.updateTaskCount(replLogTask, visited); } }
Source:
public static List<Trackable> parse(final InputSource page) { try { SAXParserFactory saxPF = SAXParserFactory.newInstance(); SAXParser saxP = saxPF.newSAXParser(); XMLReader xmlR = saxP.getXMLReader(); final GeokretyHandler gkXMLHandler = new GeokretyHandler(); xmlR.setContentHandler(gkXMLHandler); xmlR.parse(page); return gkXMLHandler.getTrackables(); } catch (final Exception e) { Log.w("Cannot parse geokrety", e); } return null; }

Target:
public static List<Trackable> parse(final InputSource page) { try { final SAXParserFactory saxPF = SAXParserFactory.newInstance(); final SAXParser saxP = saxPF.newSAXParser(); final XMLReader xmlR = saxP.getXMLReader(); final GeokretyHandler gkXMLHandler = new GeokretyHandler(); xmlR.setContentHandler(gkXMLHandler); xmlR.parse(page); return gkXMLHandler.getTrackables(); } catch (final Exception e) { Log.w("Cannot parse geokrety", e); } return null; }
Source:
public void showIfNeeded(Context context, Feed feed) { if (dontShowNotification) { return; } long feedId = feed.getId(); int episodeCount = PodDBAdapter.getInstance().getFeedCounters(feedId).get(feedId); int newEpisodes = episodeCount - lastEpisodeCount; if (newEpisodes > 0) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); showNotification(newEpisodes, feed, context, notificationManager); } }

Target:
public void showIfNeeded(Context context, Feed feed) { if (!shouldShowNotification) { return; } long feedId = feed.getId(); int newEpisodes = getNewEpisodeCount(feedId); if (newEpisodes > lastEpisodeCount) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); showNotification(newEpisodes, feed, context, notificationManager); } }
Source:
public void shouldConcatenateDoseStrengthAndUnits() throws IOException, SQLException { upgradeTestUtil.executeDataset("/org/openmrs/util/databasechange/standardTest-1.9.7-dataSet.xml"); upgradeTestUtil.executeDataset("/org/openmrs/util/databasechange/database1_9To1_10UpgradeTest-dataSet.xml"); createOrderEntryUpgradeFileWithTestData("mg=111\ntab(s)=112\n1/day\\ x\\ 7\\ days/week=113\n2/day\\ x\\ 7\\ days/week=114"); upgradeTestUtil.upgrade(); List<Map<String, String>> drugs = upgradeTestUtil.select("drug", "strength"); Assert.assertThat(drugs.size(), Matchers.is(3)); Assert.assertTrue(drugs.get(1).containsValue("325.0mg")); }

Target:
public void shouldConcatenateDoseStrengthAndUnits() throws IOException, SQLException { upgradeTestUtil.executeDataset("/org/openmrs/util/databasechange/standardTest-1.9.7-dataSet.xml"); upgradeTestUtil.executeDataset("/org/openmrs/util/databasechange/database1_9To1_10UpgradeTest-dataSet.xml"); createOrderEntryUpgradeFileWithTestData("mg=111\ntab(s)=112\n1/day\\ x\\ 7\\ days/week=113\n2/day\\ x\\ 7\\ days/week=114"); upgradeTestUtil.upgrade(); List<Map<String, String>> drugs = upgradeTestUtil.select("drug", "strength"); Assert.assertThat(drugs.size(), Matchers.is(3)); Assert.assertTrue(drugs.get(0).containsValue("1.0tab(s)")); Assert.assertTrue(drugs.get(1).containsValue("325.0mg")); Assert.assertTrue(drugs.get(2).get("strength").isEmpty()); }
Source:
private static boolean hasFakeSequence(PoolableElementView view) { return view.getIndices().stream() .map(Index::getFamily) .map(IndexFamily::getFake) .reduce(false, (a, b) -> a || b); }

Target:
private static boolean hasFakeSequence(PoolableElementView view) { return view.getIndices().stream() .map(Index::getFamily) .anyMatch(f -> f.hasFakeSequence()); }
Source:
public T createOrReplace(T... items) { T itemToCreateOrReplace = getItem(); if (items.length > 1) { throw new IllegalArgumentException("Too many items to create."); } else if (items.length == 1) { itemToCreateOrReplace = items[0]; } if (itemToCreateOrReplace == null) { throw new IllegalArgumentException("Nothing to create."); } if (Utils.isNullOrEmpty(name)) { return withName(itemToCreateOrReplace.getMetadata().getName()).createOrReplace(itemToCreateOrReplace); } String resourceVersion = KubernetesResourceUtil.getResourceVersion(itemToCreateOrReplace); try { KubernetesResourceUtil.setResourceVersion(itemToCreateOrReplace, null); return create(itemToCreateOrReplace); } catch (KubernetesClientException exception) { if (exception.getCode() != HttpURLConnection.HTTP_CONFLICT) { throw exception; } T itemFromServer = fromServer().get(); if (ResourceCompare.equals(itemFromServer, itemToCreateOrReplace)) { return itemToCreateOrReplace; } else { KubernetesResourceUtil.setResourceVersion(itemToCreateOrReplace, resourceVersion); return replace(itemToCreateOrReplace); } } }

Target:
public T createOrReplace(T... items) { T itemToCreateOrReplace = getItem(); if (items.length > 1) { throw new IllegalArgumentException("Too many items to create."); } else if (items.length == 1) { itemToCreateOrReplace = items[0]; } if (itemToCreateOrReplace == null) { throw new IllegalArgumentException("Nothing to create."); } if (Utils.isNullOrEmpty(name)) { return withName(itemToCreateOrReplace.getMetadata().getName()).createOrReplace(itemToCreateOrReplace); } try { KubernetesResourceUtil.setResourceVersion(itemToCreateOrReplace, null); return create(itemToCreateOrReplace); } catch (KubernetesClientException exception) { if (exception.getCode() != HttpURLConnection.HTTP_CONFLICT) { throw exception; } T itemFromServer = fromServer().get(); if (ResourceCompare.equals(itemFromServer, itemToCreateOrReplace)) { return itemToCreateOrReplace; } else { KubernetesResourceUtil.setResourceVersion(itemToCreateOrReplace, KubernetesResourceUtil.getResourceVersion(itemFromServer)); return replace(itemToCreateOrReplace); } } }
Source:
public void initTempFile() throws Exception { _tempFile = File.createTempFile("csv_file_analyzer", ".csv"); }

Target:
public void initTempFile() throws Exception { if(columnToBeSortedOn != null) { _targetFile = File.createTempFile("csv_file_analyzer", ".csv"); } else { _targetFile = file ; } }
Source:
public List<BeanComponentDefinition> registerRepositoriesIn(BeanDefinitionRegistry registry, RepositoryConfigurationExtension extension) { extension.registerBeansForRoot(registry, configurationSource); RepositoryBeanDefinitionBuilder builder = new RepositoryBeanDefinitionBuilder(registry, extension, resourceLoader, environment); List<BeanComponentDefinition> definitions = new ArrayList<BeanComponentDefinition>(); for (RepositoryConfiguration<? extends RepositoryConfigurationSource> configuration : extension .getRepositoryConfigurations(configurationSource, resourceLoader, inMultiStoreMode)) { BeanDefinitionBuilder definitionBuilder = builder.build(configuration); extension.postProcess(definitionBuilder, configurationSource); if (isXml) { extension.postProcess(definitionBuilder, (XmlRepositoryConfigurationSource) configurationSource); } else { extension.postProcess(definitionBuilder, (AnnotationRepositoryConfigurationSource) configurationSource); } AbstractBeanDefinition beanDefinition = definitionBuilder.getBeanDefinition(); String beanName = configurationSource.getBeanNameGenerator().generateBeanName(beanDefinition); if (LOGGER.isDebugEnabled()) { LOGGER.debug(REPOSITORY_REGISTRATION, extension.getModuleName(), beanName, configuration.getRepositoryInterface(), extension.getRepositoryFactoryClassName()); } beanDefinition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, configuration.getRepositoryInterface()); registry.registerBeanDefinition(beanName, beanDefinition); definitions.add(new BeanComponentDefinition(beanDefinition, beanName)); } return definitions; }

Target:
public List<BeanComponentDefinition> registerRepositoriesIn(BeanDefinitionRegistry registry, RepositoryConfigurationExtension extension) { extension.registerBeansForRoot(registry, configurationSource); RepositoryBeanDefinitionBuilder builder = new RepositoryBeanDefinitionBuilder(registry, extension, resourceLoader, environment); List<BeanComponentDefinition> definitions = new ArrayList<>(); for (RepositoryConfiguration<? extends RepositoryConfigurationSource> configuration : extension .getRepositoryConfigurations(configurationSource, resourceLoader, inMultiStoreMode)) { BeanDefinitionBuilder definitionBuilder = builder.build(configuration); extension.postProcess(definitionBuilder, configurationSource); if (isXml) { extension.postProcess(definitionBuilder, (XmlRepositoryConfigurationSource) configurationSource); } else { extension.postProcess(definitionBuilder, (AnnotationRepositoryConfigurationSource) configurationSource); } AbstractBeanDefinition beanDefinition = definitionBuilder.getBeanDefinition(); String beanName = configurationSource.generateBeanName(beanDefinition); if (LOGGER.isDebugEnabled()) { LOGGER.debug(REPOSITORY_REGISTRATION, extension.getModuleName(), beanName, configuration.getRepositoryInterface(), configuration.getRepositoryFactoryBeanClassName()); } beanDefinition.setAttribute(FACTORY_BEAN_OBJECT_TYPE, configuration.getRepositoryInterface()); registry.registerBeanDefinition(beanName, beanDefinition); definitions.add(new BeanComponentDefinition(beanDefinition, beanName)); } return definitions; }
Source:
private int executeWithTimeout(CommandLine command, int timeout) throws LbAdapterExecuteException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler(baos)); DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); try { long start = System.currentTimeMillis(); executor.execute(command, resultHandler); while (System.currentTimeMillis() - start < timeout && !resultHandler.hasResult()) { Thread.sleep(50); } if (resultHandler.hasResult()) { return resultHandler.getExitValue(); } else { throw new LbAdapterExecuteException(baos.toString(Charsets.UTF_8.name()), command.toString()); } } catch (ExecuteException|InterruptedException e) { throw new LbAdapterExecuteException(baos.toString(Charsets.UTF_8.name()), e, command.toString()); } }

Target:
private int executeWithTimeout(CommandLine command, int timeout) throws LbAdapterExecuteException, IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler(baos)); DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); try { long start = System.currentTimeMillis(); executor.execute(command, resultHandler); while (System.currentTimeMillis() - start < timeout && !resultHandler.hasResult()) { Thread.sleep(50); } if (resultHandler.hasResult()) { if (resultHandler.getException() != null) { throw resultHandler.getException(); } return resultHandler.getExitValue(); } else { throw new LbAdapterExecuteException(baos.toString(Charsets.UTF_8.name()), command.toString()); } } catch (ExecuteException|InterruptedException e) { throw new LbAdapterExecuteException(baos.toString(Charsets.UTF_8.name()), e, command.toString()); } }
Source:
public TransactionHandle bindConnection(Object connection) throws ConnectionException, TransactionException { checkArgument(connection != null, "Cannot bind a null connection"); if (this.connection != null) { throw new IllegalStateException("Connection can only be set once per " + SourceCallbackContext.class.getSimpleName()); } this.connection = connection; try { if (sourceCallback.getTransactionConfig().isTransacted() && connection instanceof TransactionalConnection) { ConnectionHandler<Object> connectionHandler = sourceCallback.getSourceConnectionManager().getConnectionHandler(connection) .orElseThrow(() -> new TransactionException(createWrongConnectionMessage(connection))); sourceCallback.getTransactionSourceBinder().bindToTransaction(sourceCallback.getTransactionConfig(), sourceCallback.getConfigurationInstance(), sourceCallback.getSourceLocation(), connectionHandler); transactionHandle = DEFAULT_TRANSACTION_HANDLE; } } catch (TransactionException txE) { releaseConnection(); throw txE; } return transactionHandle; }

Target:
public TransactionHandle bindConnection(Object connection) throws ConnectionException, TransactionException { checkArgument(connection != null, "Cannot bind a null connection"); if (this.connection != null) { throw new IllegalStateException("Connection can only be set once per " + SourceCallbackContext.class.getSimpleName()); } this.connection = connection; try { if (sourceCallback.getTransactionConfig().isTransacted() && connection instanceof TransactionalConnection) { ConnectionHandler<Object> connectionHandler = sourceCallback.getSourceConnectionManager().getConnectionHandler(connection) .orElseThrow(() -> new TransactionException(createWrongConnectionMessage(connection))); sourceCallback.getTransactionSourceBinder().bindToTransaction(sourceCallback.getTransactionConfig(), sourceCallback.getConfigurationInstance(), sourceCallback.getSourceLocation(), connectionHandler); transactionHandle = DEFAULT_TRANSACTION_HANDLE; } } catch (Exception e) { releaseConnection(); throw e; } return transactionHandle; }
Source:
public Result getResult(Input input) { this.master.doWork(input); return master.getFinalResult(); }

Target:
public Result getResult(Input input) { this.master.doWork(input); return this.master.getFinalResult(); }
Source:
protected boolean canDoAction() { List<String> canDoActionMessages = getReturnValue().getCanDoActionMessages(); Map<Guid, storage_domains> domainsMap = new HashMap<Guid, storage_domains>(); if (!canDoAction_beforeCloneVm(canDoActionMessages, domainsMap)) { return false; } if (getParameters().isImportAsNewEntity()) { initImportClonedVm(); } if (!canDoAction_afterCloneVm(canDoActionMessages, domainsMap)) { return false; } return true; }

Target:
protected boolean canDoAction() { Map<Guid, storage_domains> domainsMap = new HashMap<Guid, storage_domains>(); if (!canDoAction_beforeCloneVm(domainsMap)) { return false; } if (getParameters().isImportAsNewEntity()) { initImportClonedVm(); } return canDoAction_afterCloneVm(domainsMap); }
Source:
public GarbageCollectionStatus getGarbageCollectionStatus() { boolean forceCompacting = ledgerStorageList.stream() .anyMatch(single -> single.getGarbageCollectionStatus().isForceCompacting()); boolean majorCompacting = ledgerStorageList.stream() .anyMatch(single -> single.getGarbageCollectionStatus().isMajorCompacting()); boolean minorCompacting = ledgerStorageList.stream() .anyMatch(single -> single.getGarbageCollectionStatus().isMinorCompacting()); long lastMajorCompactionTime = ledgerStorageList.stream() .mapToLong(single -> single.getGarbageCollectionStatus().getLastMajorCompactionTime()).max().getAsLong(); long lastMinorCompactionTime = ledgerStorageList.stream() .mapToLong(single -> single.getGarbageCollectionStatus().getLastMinorCompactionTime()).max().getAsLong(); long majorCompactionCounter = ledgerStorageList.stream() .mapToLong(single -> single.getGarbageCollectionStatus().getMajorCompactionCounter()).sum(); long minorCompactionCounter = ledgerStorageList.stream() .mapToLong(single -> single.getGarbageCollectionStatus().getMinorCompactionCounter()).sum(); return GarbageCollectionStatus.builder() .forceCompacting(forceCompacting) .majorCompacting(majorCompacting) .minorCompacting(minorCompacting) .lastMajorCompactionTime(lastMajorCompactionTime) .lastMinorCompactionTime(lastMinorCompactionTime) .majorCompactionCounter(majorCompactionCounter) .minorCompactionCounter(minorCompactionCounter) .build(); }

Target:
public List<GarbageCollectionStatus> getGarbageCollectionStatus() { return ledgerStorageList.stream() .map(single -> single.getGarbageCollectionStatus().get(0)).collect(Collectors.toList()); }
Source:
public void testXmlElements() throws Exception { File in = new File(COMPILE_JSP_SEVER_XML); FileInputStream input = new FileInputStream(in); DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory.newInstance(); inputBuilderFactory.setIgnoringComments(true); inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); XPath xPath = XPathFactory.newInstance().newXPath(); String expression = "/server/featureManager/feature[text()]"; NodeList nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET); Assert.assertEquals("Number of <feature/> elements ==>", 3, nodes.getLength()); Assert.assertEquals("Value of first <feature/> ==>", "ejbLite-3.2", nodes.item(0).getTextContent()); Assert.assertEquals("Value of second <feature/> ==>", "mongodb-2.0", nodes.item(1).getTextContent()); Assert.assertEquals("Value of third <feature/> ==>", "jsp-2.3", nodes.item(2).getTextContent()); }

Target:
public void testXmlElements() throws Exception { File in = new File(COMPILE_JSP_SEVER_XML); FileInputStream input = new FileInputStream(in); DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory.newInstance(); inputBuilderFactory.setIgnoringComments(true); inputBuilderFactory.setCoalescing(true); inputBuilderFactory.setIgnoringElementContentWhitespace(true); inputBuilderFactory.setValidating(false); DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder(); Document inputDoc=inputBuilder.parse(input); XPath xPath = XPathFactory.newInstance().newXPath(); String expression = "/server/featureManager/feature[text()]"; NodeList nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET); Assert.assertEquals("Number of <feature/> elements ==>", 3, nodes.getLength()); ArrayList<String> features = new ArrayList<String>(); for(int i = 0; i < nodes.getLength(); i++) { features.add(nodes.item(i).getTextContent().trim()); } Assert.assertTrue("ejbLite-3.2 <feature/> found ==>", features.contains("ejbLite-3.2")); Assert.assertTrue("mongodb-2.0 <feature/> found ==>", features.contains("mongodb-2.0")); Assert.assertTrue("jsp-2.3 <feature/> found ==>", features.contains("jsp-2.3")); }
Source:
public void testStorageLocation() throws Exception { long expectedAvail = 1000L; File location = temporaryFolder.newFolder("/tmp"); StorageLocation loc = new StorageLocation(location, expectedAvail); verifyLoc(expectedAvail, loc); final DataSegment secondSegment = makeSegment("2012-01-02/2012-01-03", 23); loc.addSegment(makeSegment("2012-01-01/2012-01-02", 10)); expectedAvail -= 10; verifyLoc(expectedAvail, loc); loc.addSegment(makeSegment("2012-01-01/2012-01-02", 10)); verifyLoc(expectedAvail, loc); loc.addSegment(secondSegment); expectedAvail -= 23; verifyLoc(expectedAvail, loc); loc.removeSegment(makeSegment("2012-01-01/2012-01-02", 10)); expectedAvail += 10; verifyLoc(expectedAvail, loc); loc.removeSegment(makeSegment("2012-01-01/2012-01-02", 10)); verifyLoc(expectedAvail, loc); loc.removeSegment(secondSegment); expectedAvail += 23; verifyLoc(expectedAvail, loc); }

Target:
public void testStorageLocation() throws Exception { long expectedAvail = 1000L; File location = temporaryFolder.newFolder(); StorageLocation loc = new StorageLocation(location, expectedAvail); verifyLoc(expectedAvail, loc); final DataSegment secondSegment = makeSegment("2012-01-02/2012-01-03", 23); loc.addSegment(makeSegment("2012-01-01/2012-01-02", 10)); expectedAvail -= 10; verifyLoc(expectedAvail, loc); loc.addSegment(makeSegment("2012-01-01/2012-01-02", 10)); verifyLoc(expectedAvail, loc); loc.addSegment(secondSegment); expectedAvail -= 23; verifyLoc(expectedAvail, loc); loc.removeSegment(makeSegment("2012-01-01/2012-01-02", 10)); expectedAvail += 10; verifyLoc(expectedAvail, loc); loc.removeSegment(makeSegment("2012-01-01/2012-01-02", 10)); verifyLoc(expectedAvail, loc); loc.removeSegment(secondSegment); expectedAvail += 23; verifyLoc(expectedAvail, loc); }
Source:
private void asyncNewSession() { if (refreshing.compareAndSet(false, true)) { try { new Thread() { @Override public void run() { if (asyncRefreshing.compareAndSet(false, true)) { try { casNewSession(); } finally { asyncRefreshing.set(false); } } } }.start(); } finally { refreshing.set(false); } } }

Target:
private void asyncNewSession() { if (asyncRefreshing.compareAndSet(false, true)) { try { refreshThread.set(new Thread() { @Override public void run() { try { newSessionLock.lock(); sessionCredentials.compareAndSet(sessionCredentials.get(), newSession()); newSessionCondition.signalAll(); lastException.set(null); } catch (Exception e) { lastException.set(e); } finally { asyncRefreshing.set(false); newSessionLock.unlock(); } } }); refreshThread.get().start(); } catch (RuntimeException ex) { asyncRefreshing.set(false); throw ex; } } }
Source:
private InputStream loadResource() { final String RESOURCE_LOC = "/heron/common/tests/resources/defaults.yaml"; InputStream inputStream = ConfigReaderTest.class. getResourceAsStream(RESOURCE_LOC); if (inputStream == null) { throw new RuntimeException("Sample output file not found"); } return inputStream; }

Target:
private InputStream loadResource() { InputStream inputStream = ConfigReaderTest.class. getResourceAsStream(RESOURCE_LOC); if (inputStream == null) { throw new RuntimeException("Sample output file not found"); } return inputStream; }
Source:
public static XDDFCategoryDataSource fromDataSource(final CTAxDataSource categoryDS) { if (categoryDS.getStrRef() == null) { return new XDDFCategoryDataSource() { private CTNumData category = (CTNumData) categoryDS.getNumRef().getNumCache().copy(); @Override public String getFormula() { return categoryDS.getNumRef().getF(); } @Override public boolean isNumeric() { return true; } @Override public boolean isReference() { return true; } @Override public int getPointCount() { return (int) category.getPtCount().getVal(); } @Override public String getPointAt(int index) { return category.getPtArray(index).getV(); } @Override public String getDataRangeReference() { return categoryDS.getStrRef().getF(); } @Override public int getColIndex() { return 0; } }; } else { return new XDDFCategoryDataSource() { private CTStrData category = (CTStrData) categoryDS.getStrRef().getStrCache().copy(); @Override public String getFormula() { return categoryDS.getStrRef().getF(); } @Override public boolean isNumeric() { return false; } @Override public boolean isReference() { return true; } @Override public int getPointCount() { return (int) category.getPtCount().getVal(); } @Override public String getPointAt(int index) { return category.getPtArray(index).getV(); } @Override public String getDataRangeReference() { return categoryDS.getStrRef().getF(); } @Override public int getColIndex() { return 0; } }; } }

Target:
public static XDDFCategoryDataSource fromDataSource(final CTAxDataSource categoryDS) { if (categoryDS.getStrRef() == null) { return new XDDFCategoryDataSource() { private CTNumData category = (CTNumData) categoryDS.getNumRef().getNumCache().copy(); @Override public boolean isNumeric() { return true; } @Override public String getFormula() { return categoryDS.getNumRef().getF(); } @Override public int getPointCount() { return (int) category.getPtCount().getVal(); } @Override public String getPointAt(int index) { return category.getPtArray(index).getV(); } }; } else { return new XDDFCategoryDataSource() { private CTStrData category = (CTStrData) categoryDS.getStrRef().getStrCache().copy(); @Override public String getFormula() { return categoryDS.getStrRef().getF(); } @Override public int getPointCount() { return (int) category.getPtCount().getVal(); } @Override public String getPointAt(int index) { return category.getPtArray(index).getV(); } }; } }
Source:
public Handle<?> upload(LogFilePath localPath) throws Exception { String prefix = FileUtil.getPrefix(localPath.getTopic(), mConfig); LogFilePath path = localPath.withPrefix(prefix); final String localLogFilename = localPath.getLogFilePath(); final String logFileName; final String topicName = localPath.getTopic(); final Map<String,String> customTopicsNamesMap = getCustomTopicsNamesMap(mConfig); if (FileUtil.s3PathPrefixIsAltered(path.getLogFilePath(), mConfig)) { logFileName = localPath.withPrefix(FileUtil.getS3AlternativePrefix(mConfig)).getLogFilePath(); LOG.info("Will upload file to alternative s3 prefix path {}", logFileName); } else { logFileName = path.getLogFilePath(); } LOG.info("uploading file to {}", localLogFilename, logFileName); final Future<?> f = executor.submit(new Runnable() { @Override public void run() { try { if (customTopicsNamesMap != null) { String logFileNameCustomTopicName = logFileName; logFileNameCustomTopicName = logFileNameCustomTopicName.replace(topicName, customTopicsNamesMap.get(topicName)); FileUtil.moveToCloud(localLogFilename, logFileNameCustomTopicName); }else { FileUtil.moveToCloud(localLogFilename, logFileName); } } catch (IOException e) { throw new RuntimeException(e); } } }); return new FutureHandle(f); }

Target:
public Handle<?> upload(LogFilePath localPath) throws Exception { String prefix = FileUtil.getPrefix(localPath.getTopic(), mConfig); LogFilePath path = localPath.withPrefix(prefix); path.setCustomTopicsNames(mConfig.getCustomTopicsNames()); final String localLogFilename = localPath.getLogFilePath(); final String logFileName; if (FileUtil.s3PathPrefixIsAltered(path.getLogFilePath(), mConfig)) { logFileName = localPath.withPrefix(FileUtil.getS3AlternativePrefix(mConfig)) .getLogFilePath(); LOG.info("Will upload file to alternative s3 prefix path {}", logFileName); } else { logFileName = path.getLogFilePath(); } LOG.info("uploading file to {}", localLogFilename, logFileName); final Future<?> f = executor.submit(new Runnable() { @Override public void run() { try { FileUtil.moveToCloud(localLogFilename, logFileName); } catch (IOException e) { throw new RuntimeException(e); } } }); return new FutureHandle(f); }
Source:
public Connection getConnection(IDatabaseInfo dbInfo) throws Exception { Class.forName(JDBC_DRIVER); if (firstTime.compareAndSet(true, false)) { Pair<String, Integer> addressAndPort = OseeProperties.getOseeDbEmbeddedServerAddress(); if (addressAndPort != null) { int webPort = OseeProperties.getOseeDbEmbeddedWebServerPort(); if (webPort < 0) { webPort = PortUtil.getInstance().getValidPort(); } HyperSqlDbServer.startServer(addressAndPort.getFirst(), addressAndPort.getSecond(), webPort, dbInfo); } } Properties props = dbInfo.getConnectionProperties(); StringBuilder builder = new StringBuilder(); builder.append(dbInfo.getConnectionUrl()); HyperSqlServerUtil.appendProperties(builder, props); String url = builder.toString(); Connection connection = DriverManager.getConnection(url, props); return connection; }

Target:
public Connection getConnection(IDatabaseInfo dbInfo) throws Exception { Class.forName(JDBC_DRIVER); if (firstTime.compareAndSet(true, false)) { Pair<String, Integer> addressAndPort = OseeProperties.getOseeDbEmbeddedServerAddress(); if (addressAndPort != null) { int webPort = OseeProperties.getOseeDbEmbeddedWebServerPort(); if (webPort < 0) { webPort = PortUtil.getInstance().getValidPort(); } HyperSqlDbServer.startServer(addressAndPort.getFirst(), addressAndPort.getSecond(), webPort, dbInfo); } } Properties props = dbInfo.getConnectionProperties(); StringBuilder builder = new StringBuilder(); builder.append(dbInfo.getConnectionUrl()); HyperSqlServerUtil.appendProperties(builder, props); String url = builder.toString(); return DriverManager.getConnection(url, props); }
Source:
public boolean filterOut(final SAMRecord record) { boolean read1 = findOverlaps(record.getReferenceName(), record.getStart(), record.getEnd()); boolean read2 = true; if (!record.getMateUnmappedFlag()) { read2 = findOverlaps(record.getMateReferenceName(), record.getMateAlignmentStart(), SAMUtils.getMateAlignmentEnd(record)); } if (read1 || read2) { return false; } else { return true; } }

Target:
public boolean filterOut(final SAMRecord record) { if (record.isSecondaryOrSupplementary()) { return true; } if (!record.getReadUnmappedFlag() && hasOverlaps(record.getReferenceName(), record.getStart(), record.getEnd())) { return false; } return record.getMateUnmappedFlag() || !hasOverlaps(record.getMateReferenceName(), record.getMateAlignmentStart(), SAMUtils.getMateAlignmentEnd(record)); }
Source:
public void refreshTable(boolean needToSort) { if (Ode.getInstance().getCurrentView() == 8) { refreshTable(needToSort, true); } else { refreshTable(needToSort, false); } }

Target:
public void refreshTable(boolean needToSort) { if (Ode.getInstance().getCurrentView() == Ode.TRASHCAN) { refreshTable(needToSort, true); } else { refreshTable(needToSort, false); } }
Source:
protected String checkAndTransformValue(Value input) { if (nullable && input.isEmptyString()) { return null; } return input.getString(); }

Target:
protected String checkAndTransformValue(Value input) { if (input.isEmptyString()) { return null; } return input.getString(); }
Source:
public static Long getWSClientReceiveTimeout() throws Exception { String defaultTimeout = "60000"; String inputTimeout = System.getProperty(WS_CLIENT_RECEIVE_TIME_VALUE); if (inputTimeout != null) { try { long timeout = Long.parseLong(inputTimeout); if (timeout > 0) { return new Long(inputTimeout); } } catch (Exception exception) { throw new RuntimeException("Webservice client receive timeout value '" + inputTimeout + "' is invalid", exception); } } return new Long(defaultTimeout); }

Target:
public static int getWSClientReceiveTimeout() throws Exception { int defaultTimeout = 60000; String inputTimeout = System.getProperty(WS_CLIENT_RECEIVE_TIME_VALUE); if (inputTimeout != null) { try { int timeout = Integer.parseInt(inputTimeout); if (timeout > 0) { return timeout; } } catch (Exception exception) { throw new RuntimeException("Webservice client receive timeout value '" + inputTimeout + "' is invalid", exception); } } return defaultTimeout; }
Source:
private void checkUnsupportedOperationsForFSTIndex(ColumnMetadata columnMetadata) { String column = columnMetadata.getColumnName(); if (columnMetadata.getDataType() != FieldSpec.DataType.STRING) { throw new UnsupportedOperationException("FST index is currently only supported on STRING columns: " + column); } if (!columnMetadata.hasDictionary()) { throw new UnsupportedOperationException("FST index is currently only supported on dictionary encoded columns: " + column); } if (!columnMetadata.isSingleValue()) { throw new UnsupportedOperationException( "Text index is currently not supported on multi-value columns: " + column); } }

Target:
private void checkUnsupportedOperationsForFSTIndex(ColumnMetadata columnMetadata) { String column = columnMetadata.getColumnName(); if (columnMetadata.getDataType() != FieldSpec.DataType.STRING) { throw new UnsupportedOperationException("FST index is currently only supported on STRING columns: " + column); } if (!columnMetadata.hasDictionary()) { throw new UnsupportedOperationException( "FST index is currently only supported on dictionary encoded columns: " + column); } if (!columnMetadata.isSingleValue()) { throw new UnsupportedOperationException("FST index is currently not supported on multi-value columns: " + column); } }
Source:
public Configuration getServiceConfigurationWithoutNameResolver() { final Configuration networkConf = getNetworkConfigurationBuilder() .bindNamedParameter(EMMessageHandler.class, edu.snu.cay.services.em.evaluator.ElasticMemoryMsgHandler.class) .build(); final Configuration serviceConf = ServiceConfiguration.CONF .set(ServiceConfiguration.SERVICES, MemoryStoreImpl.class) .build(); final String evalId = EVAL_ID_PREFIX + numEvals.getAndIncrement(); partitionManager.registerEvaluator(evalId.toString()); final Configuration otherConf = Tang.Factory.getTang().newConfigurationBuilder() .bindImplementation(MemoryStore.class, MemoryStoreImpl.class) .bindNamedParameter(EMEvalId.class, evalId) .bindNamedParameter(DriverIdentifier.class, driverId) .build(); return Configurations.merge(networkConf, serviceConf, otherConf); }

Target:
public Configuration getServiceConfigurationWithoutNameResolver() { final Configuration networkConf = getNetworkConfigurationBuilder() .bindNamedParameter(EMMessageHandler.class, edu.snu.cay.services.em.evaluator.ElasticMemoryMsgHandler.class) .build(); final Configuration serviceConf = ServiceConfiguration.CONF .set(ServiceConfiguration.SERVICES, MemoryStoreImpl.class) .build(); final String evalId = EVAL_ID_PREFIX + numEvals.getAndIncrement(); partitionManager.registerEvaluator(evalId); final Configuration otherConf = Tang.Factory.getTang().newConfigurationBuilder() .bindImplementation(MemoryStore.class, MemoryStoreImpl.class) .bindNamedParameter(EMEvalId.class, evalId) .bindNamedParameter(DriverIdentifier.class, driverId) .build(); return Configurations.merge(networkConf, serviceConf, otherConf); }
Source:
public void tearDown() throws Exception { workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); workspaceServiceClient.delete(WORKSPACE_NAME2, defaultTestUser.getName()); workspaceServiceClient.delete(WORKSPACE_NAME3, defaultTestUser.getName()); }

Target:
public void tearDown() throws Exception { workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); workspaceServiceClient.delete(WORKSPACE_NAME2, defaultTestUser.getName()); workspaceServiceClient.delete(NEWEST_CREATED_WORKSPACE_NAME, defaultTestUser.getName()); }
Source:
public void testShouldThrottle() { LeaveGroupResponse response = new LeaveGroupResponse(new LeaveGroupResponseData()); assertFalse(response.shouldClientThrottle((short) 0)); assertFalse(response.shouldClientThrottle((short) 1)); assertTrue(response.shouldClientThrottle((short) 2)); }

Target:
public void testShouldThrottle() { LeaveGroupResponse response = new LeaveGroupResponse(new LeaveGroupResponseData()); for (short version = 0; version <= ApiKeys.LEAVE_GROUP.latestVersion(); version++) { if (version >= 2) { assertTrue(response.shouldClientThrottle(version)); } else { assertFalse(response.shouldClientThrottle(version)); } } }
Source:
public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node, IXmlStateSystemContainer container, String eventField) { super(modelFactory, node, container, new ArrayList<ITmfXmlStateAttribute>(), eventField); }

Target:
public TmfXmlReadOnlyStateValue(TmfXmlReadOnlyModelFactory modelFactory, Element node, IXmlStateSystemContainer container, String eventField) { super(modelFactory, node, container, Collections.EMPTY_LIST, eventField); }
Source:
protected boolean authorize() { try { IAuthorizationContext context = client.getAuthorizationContext(); if (!context.isAuthorized() && credentialsPrompter != null && promptCredentialsEnabled){ credentialsPrompter.promptAndAuthenticate(this, null); } else { updateCredentials(context); } } catch (UnauthorizedException e) { if (isEnablePromptCredentials() && credentialsPrompter != null) { credentialsPrompter.promptAndAuthenticate(this, e.getAuthorizationDetails()); } else { throw e; } } return getToken() != null; }

Target:
protected boolean authorize() { try { IAuthorizationContext context = loadAuthorizationContext(); if (!context.isAuthorized() && credentialsPrompter != null && promptCredentialsEnabled){ credentialsPrompter.promptAndAuthenticate(this, null); } else { updateCredentials(context); } } catch (UnauthorizedException e) { if (isEnablePromptCredentials() && credentialsPrompter != null) { credentialsPrompter.promptAndAuthenticate(this, e.getAuthorizationDetails()); } else { throw e; } } return getToken() != null; }
Source:
private void checkStaticInitializer(MethodNode methodNode, IFilterOutput output) { AbstractInsnNode preClinitNode = null; for (AbstractInsnNode node = methodNode.instructions.getFirst(); node != null; node = node.getNext()) { if (node.getOpcode() == Opcodes.INVOKESTATIC) { String name = ((MethodInsnNode) node).name; if (name.equals("ajc$preClinit")) { if (isEffectivelyLast(node.getNext())) { output.ignore(methodNode.instructions.getFirst(), methodNode.instructions.getLast()); return; } else { preClinitNode = node; output.ignore(methodNode.instructions.getFirst(), node); } } if (name.equals("ajc$postClinit")) { if (isEffectivelyFirst(node.getPrevious()) || (preClinitNode != null && node == getNextRealOp(preClinitNode)) ) { output.ignore(methodNode.instructions.getFirst(), methodNode.instructions.getLast()); return; } else { output.ignore(node, methodNode.instructions.getLast()); } } } } }

Target:
private void checkStaticInitializer(MethodNode methodNode, IFilterOutput output) { PreClinitMatcher preClinitMatcher = new PreClinitMatcher(methodNode); AbstractInsnNode match = preClinitMatcher.match(); if (match != null) { output.ignore(methodNode.instructions.getFirst(), match); } for (TryCatchBlockNode tryCatchBlock : methodNode.tryCatchBlocks) { PostClinitMatcher postClinitMatcher = new PostClinitMatcher(tryCatchBlock.start); AbstractInsnNode end = postClinitMatcher.match(); if (end != null) { output.ignore(tryCatchBlock.start, end); } } }
Source:
public void testCompareLocalWithLocal() { StorageDomain sd_local = new StorageDomain(); sd_local.setStorageType(StorageType.LOCALFS); StorageDomain sd_local2 = new StorageDomain(); sd_local2.setStorageType(StorageType.LOCALFS); int comparatorReturnValue = comparator.compare(sd_local, sd_local2); assertTrue(comparatorReturnValue == 0); }

Target:
public void testCompareLocalWithLocal() { storageDomain1.setStorageType(StorageType.LOCALFS); storageDomain2.setStorageType(StorageType.LOCALFS); assertEqualsTo(storageDomain1, storageDomain2); }
Source:
public AccountAttributes getAccount(String googleId, boolean retrieveStudentProfile) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, googleId); Account a = getAccountEntity(googleId, retrieveStudentProfile); if (a == null || JDOHelper.isDeleted(a)) { return null; } closePM(); AccountAttributes accAttr = new AccountAttributes(a); return accAttr; }

Target:
public AccountAttributes getAccount(String googleId, boolean retrieveStudentProfile) { Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, googleId); Account a = getAccountEntity(googleId, retrieveStudentProfile); if (a == null) { return null; } closePM(); AccountAttributes accAttr = new AccountAttributes(a); return accAttr; }
Source:
public List<MemorySegment> requestMemorySegments(int numberOfSegmentsToRequest) throws IOException { synchronized (factoryLock) { if (isDestroyed) { throw new IllegalStateException("Network buffer pool has already been destroyed."); } tryRedistributeBuffers(numberOfSegmentsToRequest); } final List<MemorySegment> segments = new ArrayList<>(numberOfSegmentsToRequest); try { final Deadline deadline = Deadline.fromNow(requestSegmentsTimeout); while (true) { if (isDestroyed) { throw new IllegalStateException("Buffer pool is destroyed."); } MemorySegment segment; synchronized (availableMemorySegments) { if ((segment = internalRequestMemorySegment()) == null) { availableMemorySegments.wait(2000); } } if (segment != null) { segments.add(segment); } if (segments.size() >= numberOfSegmentsToRequest) { break; } if (!deadline.hasTimeLeft()) { throw new IOException(String.format("Timeout triggered when requesting exclusive buffers: %s, " + " or you may increase the timeout which is %dms by setting the key '%s'.", getConfigDescription(), requestSegmentsTimeout.toMillis(), NettyShuffleEnvironmentOptions.NETWORK_EXCLUSIVE_BUFFERS_REQUEST_TIMEOUT_MILLISECONDS.key())); } } } catch (Throwable e) { try { recycleMemorySegments(segments, numberOfSegmentsToRequest); } catch (IOException inner) { e.addSuppressed(inner); } ExceptionUtils.rethrowIOException(e); } return segments; }

Target:
public List<MemorySegment> requestMemorySegments(int numberOfSegmentsToRequest) throws IOException { checkArgument(numberOfSegmentsToRequest > 0, "Number of buffers to request must be larger than 0."); synchronized (factoryLock) { if (isDestroyed) { throw new IllegalStateException("Network buffer pool has already been destroyed."); } tryRedistributeBuffers(numberOfSegmentsToRequest); } final List<MemorySegment> segments = new ArrayList<>(numberOfSegmentsToRequest); try { final Deadline deadline = Deadline.fromNow(requestSegmentsTimeout); while (true) { if (isDestroyed) { throw new IllegalStateException("Buffer pool is destroyed."); } MemorySegment segment; synchronized (availableMemorySegments) { if ((segment = internalRequestMemorySegment()) == null) { availableMemorySegments.wait(2000); } } if (segment != null) { segments.add(segment); } if (segments.size() >= numberOfSegmentsToRequest) { break; } if (!deadline.hasTimeLeft()) { throw new IOException(String.format("Timeout triggered when requesting exclusive buffers: %s, " + " or you may increase the timeout which is %dms by setting the key '%s'.", getConfigDescription(), requestSegmentsTimeout.toMillis(), NettyShuffleEnvironmentOptions.NETWORK_EXCLUSIVE_BUFFERS_REQUEST_TIMEOUT_MILLISECONDS.key())); } } } catch (Throwable e) { try { recycleMemorySegments(segments, numberOfSegmentsToRequest); } catch (IOException inner) { e.addSuppressed(inner); } ExceptionUtils.rethrowIOException(e); } return segments; }
Source:
public synchronized void connect(StompSessionHandler handler) { this.compositeStompSessionHandler.addHandler(handler); if (this.stompSessionListenableFuture == null) { this.stompSessionListenableFuture = doConnect(this.compositeStompSessionHandler); this.stompSessionListenableFuture.addCallback(new ListenableFutureCallback<StompSession>() { @Override public void onFailure(Throwable e) { logger.error("STOMP connect error.", e); if (applicationEventPublisher != null) { applicationEventPublisher.publishEvent( new StompExceptionEvent(AbstractStompSessionManager.this, e)); } AbstractStompSessionManager.this.stompSession = null; AbstractStompSessionManager.this.stompSessionListenableFuture = null; } @Override public void onSuccess(StompSession stompSession) { AbstractStompSessionManager.this.stompSession = stompSession; AbstractStompSessionManager.this.stompSession.setAutoReceipt(autoReceipt); } }); } }

Target:
public void connect(StompSessionHandler handler) { this.compositeStompSessionHandler.addHandler(handler); }