auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testHttpDigestJson() { String cp = "REST_JSON_DIGEST"; RestConnectionProfileWizard.openWizard(cp) .setConnectionUrl("<LINK_0>") .setType(RestConnectionProfileWizard.TYPE_JSON) .setAuth(RestConnectionProfileWizard.AUTH_TYPE_DIGEST, "user", "user") .testConnection() .finish(); String sourceModel = "RestJsonDigestSource"; String viewModel = "RestJsonDigestView"; RestImportWizard.openWizard() .setProfileName(cp) .nextPage() .setProject(PROJECT_NAME) .setSourceModelName(sourceModel) .setViewModelName(viewModel) .setProcedureName(PROCEDURE_NAME) .nextPage() .setJndiName(sourceModel + "DS") .nextPage() .setRootPath("response/schedule/day/broadcasts") .setColumns("pid","start","end","programme/title") .finish(); String vdb = "RestJsonDigestVdb"; VdbWizard.openVdbWizard() .setLocation(PROJECT_NAME) .setName(vdb) .addModel(PROJECT_NAME, viewModel) .finish(); ServersViewExt.getInstance().refreshServer(teiidServer.getName()); modelExplorer.deployVdb(PROJECT_NAME, vdb); TeiidJDBCHelper jdbchelper = new TeiidJDBCHelper(teiidServer, vdb); assertEquals(16, jdbchelper.getNumberOfResults("exec " + viewModel + "." + PROCEDURE_NAME + "()")); }

Target:
public void testHttpDigestJson() { String sourceModel = "RestJsonDigestSource"; String viewModel = "RestJsonDigestView"; RestImportWizard.openWizard() .setProfileName(ConnectionProfileConstants.REST_JSON_SECURE) .nextPage() .setProject(PROJECT_NAME) .setSourceModelName(sourceModel) .setViewModelName(viewModel) .setProcedureName(PROCEDURE_NAME) .nextPage() .setJndiName(sourceModel + "DS") .nextPage() .setRootPath("response/schedule/day/broadcasts") .setColumns("pid","start","end","programme/title") .finish(); String vdb = "RestJsonDigestVdb"; VdbWizard.openVdbWizard() .setLocation(PROJECT_NAME) .setName(vdb) .addModel(PROJECT_NAME, viewModel) .finish(); ServersViewExt.getInstance().refreshServer(teiidServer.getName()); modelExplorer.deployVdb(PROJECT_NAME, vdb); TeiidJDBCHelper jdbchelper = new TeiidJDBCHelper(teiidServer, vdb); assertEquals(16, jdbchelper.getNumberOfResults("exec " + viewModel + "." + PROCEDURE_NAME + "()")); }
Source:
protected void run(final String[] argv) { try { if (!installConsole()) { AwtAuthenticator.install(); AwtCredentialsProvider.install(); } configureHttpProxy(); execute(argv); } catch (Die err) { if (err.isAborted()) { System.exit(1); } System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (showStackTrace) err.printStackTrace(); System.exit(128); } catch (Exception err) { if (err.getClass() == IOException.class) { if (err.getMessage().equals("Broken pipe")) System.exit(0); if (err.getMessage().equals("The pipe is being closed")) System.exit(0); } if (!showStackTrace && err.getCause() != null && err instanceof TransportException) System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage())); if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (showStackTrace) err.printStackTrace(); System.exit(128); } err.printStackTrace(); System.exit(1); } if (System.out.checkError()) { System.err.println(CLIText.get().unknownIoErrorStdout); System.exit(1); } if (System.err.checkError()) { System.exit(1); } }

Target:
protected void run(final String[] argv) { try { if (!installConsole()) { AwtAuthenticator.install(); AwtCredentialsProvider.install(); } configureHttpProxy(); execute(argv); } catch (Die err) { if (err.isAborted()) System.exit(1); System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (showStackTrace) err.printStackTrace(); System.exit(128); } catch (Exception err) { if (err.getClass() == IOException.class) { if (err.getMessage().equals("Broken pipe")) System.exit(0); if (err.getMessage().equals("The pipe is being closed")) System.exit(0); } if (!showStackTrace && err.getCause() != null && err instanceof TransportException) System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getCause().getMessage())); if (err.getClass().getName().startsWith("org.eclipse.jgit.errors.")) { System.err.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage())); if (showStackTrace) err.printStackTrace(); System.exit(128); } err.printStackTrace(); System.exit(1); } if (System.out.checkError()) { System.err.println(CLIText.get().unknownIoErrorStdout); System.exit(1); } if (System.err.checkError()) { System.exit(1); } }
Source:
public void initTestResultSummaries(IProgressMonitor monitor, List<TestresultSummaryDTO> trsListDtos, IProjectPO proj) throws InterruptedException { monitor.beginTask(Messages.ImportFileBPImporting, trsListDtos.size()); List<ITestResultSummaryPO> summaries = new ArrayList<ITestResultSummaryPO>(); int i = 0; for (TestresultSummaryDTO dto : trsListDtos) { m_ioHandle.checkCancel(m_monitor); i++; monitor.worked(1); monitor.subTask(Messages.ImportJsonImportResult + i + StringConstants.SLASH + trsListDtos.size()); ITestResultSummaryPO summary = PoMaker.createTestResultSummaryPO(dto.getGuid()); summary.setInternalProjectGuid(proj.getGuid()); fillTestresultSummary(summary, dto); List<MonitoringValuesDTO> tmpList = dto.getMonitoringValues(); Map<String, IMonitoringValue> tmpMap = new HashMap<String, IMonitoringValue>(); for (int k = 0; k < tmpList.size(); k++) { MonitoringValuesDTO tmpMon = tmpList.get(k); MonitoringValue tmp = new MonitoringValue(); tmp.setCategory(tmpMon.getCategory()); tmp.setSignificant(tmpMon.isSignificant()); tmp.setType(tmpMon.getType()); tmp.setValue(tmpMon.getValue()); tmpMap.put(tmpMon.getKey(), tmp); } summary.setMonitoringValues(tmpMap); if (!TestResultSummaryPM.doesTestResultSummaryExist(summary)) { summaries.add(summary); } } TestResultSummaryPM.storeTestResultSummariesInDB(summaries); }

Target:
public void initTestResultSummaries(IProgressMonitor monitor, List<TestresultSummaryDTO> trsListDtos, IProjectPO proj) throws InterruptedException { monitor.beginTask(Messages.ImportFileBPImporting, trsListDtos.size()); List<ITestResultSummaryPO> summaries = new ArrayList<ITestResultSummaryPO>(ImportExportUtil.PAGE_SIZE); int countOfTestResult = 0; for (TestresultSummaryDTO dto : trsListDtos) { ImportExportUtil.checkCancel(m_monitor); countOfTestResult++; monitor.worked(1); monitor.subTask(Messages.ImportJsonImportResult + countOfTestResult + StringConstants.SLASH + trsListDtos.size()); ITestResultSummaryPO summary = PoMaker.createTestResultSummaryPO(dto.getGuid()); summary.setInternalProjectGuid(proj.getGuid()); fillTestresultSummary(summary, dto); List<MonitoringValuesDTO> tmpList = dto.getMonitoringValues(); Map<String, IMonitoringValue> tmpMap = new HashMap<String, IMonitoringValue>(); for (int countOfValue = 0; countOfValue < tmpList.size(); countOfValue++) { MonitoringValuesDTO tmpMon = tmpList.get(countOfValue); MonitoringValue tmp = new MonitoringValue(); tmp.setCategory(tmpMon.getCategory()); tmp.setSignificant(tmpMon.isSignificant()); tmp.setType(tmpMon.getType()); tmp.setValue(tmpMon.getValue()); tmpMap.put(tmpMon.getKey(), tmp); } summary.setMonitoringValues(tmpMap); if (!TestResultSummaryPM.doesTestResultSummaryExist(summary)) { summaries.add(summary); } if (summaries.size() == ImportExportUtil.PAGE_SIZE) { TestResultSummaryPM.storeTestResultSummariesInDB(summaries); summaries.clear(); } } if (!summaries.isEmpty()) { TestResultSummaryPM.storeTestResultSummariesInDB(summaries); } }
Source:
public Object compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators); final double[] means = new double[sketch.getNumValues()]; final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { means[i] += values[i]; } } for (int i = 0; i < means.length; i++) { means[i] /= sketch.getRetainedEntries(); } return means; }

Target:
public double[] compute(final Map<String, Object> combinedAggregators) { final ArrayOfDoublesSketch sketch = (ArrayOfDoublesSketch) getField().compute(combinedAggregators); final SummaryStatistics[] stats = new SummaryStatistics[sketch.getNumValues()]; Arrays.setAll(stats, i -> new SummaryStatistics()); final ArrayOfDoublesSketchIterator it = sketch.iterator(); while (it.next()) { final double[] values = it.getValues(); for (int i = 0; i < values.length; i++) { stats[i].addValue(values[i]); } } final double[] means = new double[sketch.getNumValues()]; Arrays.setAll(means, i -> stats[i].getMean()); return means; }
Source:
public final ResourceLink build(final HttpServletRequest request, final User user, final Contentlet contentlet) throws DotDataException, DotSecurityException { if(!(contentlet.isFileAsset() || contentlet.isDotAsset())) { throw new DotStateException(getLocalizedMessageOrDefault(user,"File-asset-contentlet-type-expected", "Can only build Resource Links out of content with type `File Asset` or `DotAsset`.",getClass()) ); } return build(request, user, contentlet, FileAssetAPI.BINARY_FIELD); }

Target:
public final ResourceLink build(final HttpServletRequest request, final User user, final Contentlet contentlet) throws DotDataException, DotSecurityException { if(!(contentlet.isFileAsset() || contentlet.isDotAsset())) { throw new DotStateException(getLocalizedMessageOrDefault(user,"File-asset-contentlet-type-expected", "Can only build Resource Links out of content with type `File Asset` or `DotAsset`.",getClass()) ); } return build(request, user, contentlet, contentlet.isFileAsset()?FileAssetAPI.BINARY_FIELD: DotAssetContentType.ASSET_FIELD_VAR); }
Source:
public static void addCanningRecipe(ItemStack container, @Nullable ItemStack input, @Nullable ItemStack output) { if (input == null || output == null) return; try { Recipes.cannerBottle.addRecipe(new RecipeInputItemStack(container), new RecipeInputItemStack(input), output); } catch (Throwable error) { Game.logErrorAPI("IC2", error, Recipes.class); } }

Target:
public static void addCanningRecipe(ItemStack container, @Nullable ItemStack input, @Nullable ItemStack output) { if (InvTools.isEmpty(input) || InvTools.isEmpty(output)) return; try { Recipes.cannerBottle.addRecipe(new RecipeInputItemStack(container), new RecipeInputItemStack(input), output); } catch (Throwable error) { Game.logErrorAPI("IC2", error, Recipes.class); } }
Source:
public COREEnvelopeRealTimeResponse realTimeRequest(COREEnvelopeRealTimeRequest coreEnvelopeRealTimeRequest, AssertionType assertion) { COREEnvelopeRealTimeResponse oResponse = null; if (coreEnvelopeRealTimeRequest != null) { LOG.trace("Begin AdapterCORE_X12DSRealTimeOrchImpl.realTimeRequest()"); oResponse = buildAdapterCORE_X12DSRealTimeResponseMetadata(); LogAdapterCORE_X12DSRealTimeRequest(coreEnvelopeRealTimeRequest); LOG.trace("End AdapterCORE_X12DSRealTimeOrchImpl.realTimeRequest()"); } else { return oResponse; } return oResponse; }

Target:
public COREEnvelopeRealTimeResponse realTimeRequest(COREEnvelopeRealTimeRequest coreEnvelopeRealTimeRequest, AssertionType assertion) { COREEnvelopeRealTimeResponse oResponse = null; if (coreEnvelopeRealTimeRequest != null) { LOG.trace("Begin AdapterCORE_X12DSRealTimeOrchImpl.realTimeRequest()"); oResponse = buildAdapterCORE_X12DSRealTimeResponseMetadata(); logAdapterCORE_X12DSRealTimeRequest(coreEnvelopeRealTimeRequest); LOG.trace("End AdapterCORE_X12DSRealTimeOrchImpl.realTimeRequest()"); } else { oResponse = new COREEnvelopeRealTimeResponse(); } return oResponse; }
Source:
boolean joinGroupIfNeeded(final Timer timer) { while (rejoinNeededOrPending()) { if (!ensureCoordinatorReady(timer)) { return false; } RequestFuture<ByteBuffer> future; synchronized (this) { if (needsJoinPrepare) { needsJoinPrepare = false; onJoinPrepare(generation.generationId, generation.memberId); } future = initiateJoinGroup(); } client.poll(future, timer); if (!future.isDone()) { return false; } if (future.succeeded()) { synchronized (this) { if (generation.generationId != OffsetCommitRequest.DEFAULT_GENERATION_ID) { ByteBuffer memberAssignment = future.value().duplicate(); onJoinComplete(generation.generationId, generation.memberId, generation.protocol, memberAssignment); resetJoinGroupFuture(); needsJoinPrepare = true; } else { log.info("Generation data was cleared by heartbeat thread. Initiating rejoin."); resetStateAndRejoin(); return false; } } } else { resetJoinGroupFuture(); final RuntimeException exception = future.exception(); if (exception instanceof UnknownMemberIdException || exception instanceof RebalanceInProgressException || exception instanceof IllegalGenerationException || exception instanceof MemberIdRequiredException) continue; else if (!future.isRetriable()) throw exception; timer.sleep(rebalanceConfig.retryBackoffMs); } } return true; }

Target:
boolean joinGroupIfNeeded(final Timer timer) { while (rejoinNeededOrPending()) { if (!ensureCoordinatorReady(timer)) { return false; } if (needsJoinPrepare) { needsJoinPrepare = false; onJoinPrepare(generation.generationId, generation.memberId); } final RequestFuture<ByteBuffer> future = initiateJoinGroup(); client.poll(future, timer); if (!future.isDone()) { return false; } if (future.succeeded()) { Generation generationSnapshot; synchronized (this) { generationSnapshot = this.generation; } if (generationSnapshot != Generation.NO_GENERATION) { ByteBuffer memberAssignment = future.value().duplicate(); onJoinComplete(generationSnapshot.generationId, generationSnapshot.memberId, generationSnapshot.protocol, memberAssignment); resetJoinGroupFuture(); needsJoinPrepare = true; } else { log.info("Generation data was cleared by heartbeat thread. Initiating rejoin."); resetStateAndRejoin(); return false; } } else { resetJoinGroupFuture(); final RuntimeException exception = future.exception(); if (exception instanceof UnknownMemberIdException || exception instanceof RebalanceInProgressException || exception instanceof IllegalGenerationException || exception instanceof MemberIdRequiredException) continue; else if (!future.isRetriable()) throw exception; timer.sleep(rebalanceConfig.retryBackoffMs); } } return true; }
Source:
public MapEntriesWithCursor fetchEntries(int tableIndex, int size, SerializationService serializationService) { List<Map.Entry<Data, R>> entries = new ArrayList<Map.Entry<Data, R>>(size); int newTableIndex = records.fetchEntries(tableIndex, size, entries); List<Map.Entry<Data, Object>> entriesData = new ArrayList<Map.Entry<Data, Object>>(entries.size()); for (Map.Entry<Data, R> entry : entries) { R record = (R)(Record)entry.getValue(); Object value = record.getValue(); Object dataValue = (value instanceof com.hazelcast.map.Immutable) ? value : serializationService.toData(value); entriesData.add(new AbstractMap.SimpleEntry((Data)entry.getKey(), dataValue)); } return new MapEntriesWithCursor(entriesData, newTableIndex); }

Target:
public MapEntriesWithCursor fetchEntries(int tableIndex, int size, SerializationService serializationService) { List<Map.Entry<Data, R>> entries = new ArrayList<Map.Entry<Data, R>>(size); int newTableIndex = records.fetchEntries(tableIndex, size, entries); List<Map.Entry<Data, Object>> entriesData = new ArrayList<Map.Entry<Data, Object>>(entries.size()); for (Map.Entry<Data, R> entry : entries) { R record = entry.getValue(); Object value = record.getValue(); Object resultValue = (value instanceof Immutable) ? value : serializationService.toData(value); entriesData.add(new AbstractMap.SimpleEntry<Data, Object>(entry.getKey(), resultValue)); } return new MapEntriesWithCursor(entriesData, newTableIndex); }
Source:
public ExtensionFieldEntity getFieldForName(String fieldName, boolean caseInsensitive) { for (ExtensionFieldEntity field : fields) { if (!caseInsensitive) { if (field.getName().equals(fieldName)) { return field; } } else { if (field.getName().equalsIgnoreCase(fieldName)) { return field; } } } throw new InvalidConstraintException("Field " + fieldName + " not available in extension with urn " + urn); }

Target:
public ExtensionFieldEntity getFieldForName(String fieldName, boolean caseInsensitive) { for (ExtensionFieldEntity field : fields) { if (!caseInsensitive) { if (field.getName().equals(fieldName)) { return field; } } else { if (field.getName().equalsIgnoreCase(fieldName)) { return field; } } } throw new InvalidConstraintException(String.format("Field '%s' not available in extension with urn '%s'", fieldName, urn)); }
Source:
public void sent(Frame frame) { if (ResumeUtil.isTracked(frame)) { frames.put(currentPosition, frame.retain()); bufferSize += strategy.cost(frame); currentPosition += ResumeUtil.offset(frame); if (frames.size() > maxBufferSize) { Frame f = frames.remove(first(frames)); bufferSize -= strategy.cost(f); f.release(); } } }

Target:
public void sent(Frame frame) { if (ResumeUtil.isTracked(frame)) { frames.put(currentPosition, frame.copy()); bufferSize += strategy.cost(frame); currentPosition += ResumeUtil.offset(frame); if (frames.size() > maxBufferSize) { Frame f = frames.remove(first(frames)); bufferSize -= strategy.cost(f); } } }
Source:
public void onPreviousDiffClicked() { view.getEditableContent(content -> { if (isEdited(content)) { saveContent(content); } currentFileIndex--; showCompareForCurrentFile(); }); }

Target:
public void onPreviousDiffClicked() { if (currentFileIndex > 0) { onSaveChangesClicked(); currentFileIndex--; showCompareForCurrentFile(); } }
Source:
private void populateInterface(VdsNetworkInterface iface) { if (iface.getId() != null && StringUtils.isNotEmpty(iface.getName())) { return; } VdsNetworkInterface existingIface = null; if (iface.getId() != null && getExistingIfacesToIds().containsKey(iface.getId())) { existingIface = getExistingIfacesToIds().get(iface.getId()); if (existingIface != null) { iface.setName(existingIface.getName()); } } else if (StringUtils.isNotEmpty(iface.getName()) && getExistingIfaces().containsKey(iface.getName())) { existingIface = getExistingIfaces().get(iface.getName()); if (existingIface != null) { iface.setId(existingIface.getId()); } } }

Target:
private void populateInterface(VdsNetworkInterface iface) { if (iface.getId() != null && StringUtils.isNotEmpty(iface.getName())) { return; } if (iface.getId() != null && getExistingIfacesByIds().containsKey(iface.getId())) { iface.setName(getExistingIfacesByIds().get(iface.getId()).getName()); } else if (StringUtils.isNotEmpty(iface.getName()) && getExistingIfaces().containsKey(iface.getName())) { iface.setId(getExistingIfaces().get(iface.getName()).getId()); } }
Source:
public Set<ESparkVersion> getSparkVersions() { Set<ESparkVersion> version = new HashSet<>(); Set<ESparkVersion> sparkVersions = super.getSparkVersions(); if (sparkVersions == null || sparkVersions.isEmpty()) { version.add(ESparkVersion.SPARK_2_2); } else { version.addAll(sparkVersions); } return version; }

Target:
public Set<ESparkVersion> getSparkVersions() { Set<ESparkVersion> version = new HashSet<>(); Set<ESparkVersion> sparkVersions = super.getSparkVersions(); if (sparkVersions == null || sparkVersions.isEmpty()) { version.add(ESparkVersion.SPARK_2_4); } else { version.addAll(sparkVersions); } return version; }
Source:
public String getMySQLScript() { String sql = ""; final String fk_workflow_assign = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_assign FOREIGN KEY (assigned_to) REFERENCES cms_role (id);"; final String fk_workflow_task_asset = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_task_asset FOREIGN KEY (webasset) REFERENCES identifier (id);"; final String fk_workflow_step = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_step FOREIGN KEY (status) REFERENCES workflow_step (id);"; Connection conn = null; final List<String> tables = new ArrayList<String>( Arrays.asList("workflow_task")); try { conn = DbConnectionFactory.getDataSource().getConnection(); conn.setAutoCommit(true); final List<ForeignKey> listForeignKeys = this.getForeingKeys(conn, tables, false); final List<String> listForeignKeysNames = new ArrayList<String>(); for(ForeignKey foreignKey : listForeignKeys){ listForeignKeysNames.add(foreignKey.fkName()); } if(!listForeignKeysNames.contains("FK_workflow_assign")){ sql = sql + fk_workflow_assign; } if(!listForeignKeysNames.contains("FK_workflow_task_asset")){ sql = sql + fk_workflow_task_asset; } if(!listForeignKeysNames.contains("FK_workflow_step")){ sql = sql + fk_workflow_step; } } catch (Exception e) { Logger.error(this, String.format("Error running the upgrade task 4215", e.getMessage()), e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException ex) { Logger.error(this, String.format("Error closing the connection", ex.getMessage()), ex); } } return sql; }

Target:
public String getMySQLScript() { String sql = ""; final String FKWORKFLOWASSIGN = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_assign FOREIGN KEY (assigned_to) REFERENCES cms_role (id);"; final String FKWORKFLOWTASKASSET = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_task_asset FOREIGN KEY (webasset) REFERENCES identifier (id);"; final String FKWORKFLOWSTEP = "ALTER TABLE workflow_task ADD CONSTRAINT FK_workflow_step FOREIGN KEY (status) REFERENCES workflow_step (id);"; Connection conn = null; final List<String> tables = new ArrayList<>( Arrays.asList("workflow_task")); try { conn = DbConnectionFactory.getDataSource().getConnection(); conn.setAutoCommit(true); final List<ForeignKey> listForeignKeys = this.getForeingKeys(conn, tables, false); final List<String> listForeignKeysNames = listForeignKeys.stream().map(ForeignKey::fkName).collect( CollectionsUtils.toImmutableList()); if(!listForeignKeysNames.contains("FK_workflow_assign")){ sql += FKWORKFLOWASSIGN; } if(!listForeignKeysNames.contains("FK_workflow_task_asset")){ sql += FKWORKFLOWTASKASSET; } if(!listForeignKeysNames.contains("FK_workflow_step")){ sql += FKWORKFLOWSTEP; } } catch (Exception e) { Logger.error(this,"Error Running Upgrade Task 4215 " + e.getMessage(),e); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException ex) { Logger.error(this,"Error Closing the Connection " + ex.getMessage(),ex); } } return sql; }
Source:
public static GameObject getDefaultEntity(int id, EntityType type) { throw new UnsupportedOperationException("Not implemented"); }

Target:
public static GameObject getDefaultEntity(int id, EntityType type) { switch (type) { case WALL: return new Wall(id); case ENEMY_CHARACTER: GameObject enemy = new BoDCharacter(id, new Point2D(0, 0), 50, 50, 0, defaultImages.get(EntityType.ENEMY_CHARACTER)); return enemy; } return null; }
Source:
private CompareResult compareComponentParam( int valueStartPos, int valueLength, @NonNull byte[] inboundValue ) { if (( byteArray[valueStartPos] == '{' && byteArray[valueStartPos + 1] == '}' ) || ( inboundValue.length == 0 )) { return null; } for (int i = 0; i < inboundValue.length; i++) { if (byteArray[valueStartPos + i] == '{') { for (int j = valueLength - 1, k = inboundValue.length - 1; j >= 0; j--, k--) { if (byteArray[valueStartPos + j] == '}') { byte[] placeholderValue = new byte[k - i + 1]; byte[] placeholder = new byte[(valueStartPos + j) - (valueStartPos + i) - 1]; System.arraycopy(inboundValue, i, placeholderValue, 0, placeholderValue.length); System.arraycopy(byteArray, valueStartPos + i + 1, placeholder, 0, placeholder.length); return new CompareResult( new StringBuilder(placeholderValue.length + placeholder.length + 1) .append(new String(placeholder)).append(MATCH_PARAM_DIVIDER_CHAR) .append(new String(placeholderValue)).toString(), false); } if (byteArray[valueStartPos + j] != inboundValue[k]) { return null; } } } if (byteArray[valueStartPos + i] != inboundValue[i]) { return null; } } return new CompareResult("", false); }

Target:
private CompareResult compareComponentParam( int valueStartPos, int valueLength, @NonNull byte[] inboundValue ) { if (( byteArray[valueStartPos] == '{' && byteArray[valueStartPos + 1] == '}' ) || ( inboundValue.length == 0 )) { return null; } for (int i = 0; i < inboundValue.length; i++) { if (byteArray[valueStartPos + i] == '{') { for (int j = valueLength - 1, k = inboundValue.length - 1; j >= 0; j--, k--) { if (byteArray[valueStartPos + j] == '}') { byte[] placeholderValue = new byte[k - i + 1]; byte[] placeholder = new byte[(valueStartPos + j) - (valueStartPos + i) - 1]; System.arraycopy(inboundValue, i, placeholderValue, 0, placeholderValue.length); System.arraycopy(byteArray, valueStartPos + i + 1, placeholder, 0, placeholder.length); return new CompareResult( new String(placeholder) + MATCH_PARAM_DIVIDER_CHAR + new String(placeholderValue), false); } if (byteArray[valueStartPos + j] != inboundValue[k]) { return null; } } } if (byteArray[valueStartPos + i] != inboundValue[i]) { return null; } } return new CompareResult("", false); }
Source:
public void handleResponse(StunMessageEvent evt) { TransactionID transactionID = getTransactionID(); logger.log(Level.FINE, "handleResponse tid " + transactionID); if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE)) { cancel(); } responseCollector.processResponse( new StunResponseEvent( stackCallback, evt.getRawMessage(), (Response) evt.getMessage(), request, transactionID)); }

Target:
public void handleResponse(StunMessageEvent evt) { TransactionID transactionID = getTransactionID(); logger.fine("handleResponse tid " + transactionID); if(!Boolean.getBoolean(StackProperties.KEEP_CRANS_AFTER_A_RESPONSE)) { cancel(); } responseCollector.processResponse( new StunResponseEvent( stackCallback, evt.getRawMessage(), (Response) evt.getMessage(), request, transactionID)); }
Source:
protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { if (req.getQueryString() == null || req.getQueryString().isEmpty()) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); if (deniedActions.contains(params.get("a"))) { rsp.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if (params.get("a").equals(PROJECT_LIST_ACTION)) { rsp.sendRedirect(req.getContextPath() + "/#" + PageLinks.ADMIN_PROJECTS + "?filter=" + params.get("pf") + "/"); return; } String name = params.get("p"); if (name == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (name.endsWith(".git")) { name = name.substring(0, name.length() - 4); } final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible() && !project.isOwner()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { if (userProvider.get().isIdentifiedUser()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { rsp.sendRedirect(getLoginRedirectUrl(req)); } return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { CacheHeaders.setNotCacheable(rsp); exec(req, rsp, project); } finally { repo.close(); } }

Target:
protected void service(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException { if (req.getQueryString() == null || req.getQueryString().isEmpty()) { rsp.sendRedirect(req.getContextPath() + "/"); return; } final Map<String, String> params = getParameters(req); if (deniedActions.contains(params.get("a"))) { rsp.sendError(HttpServletResponse.SC_FORBIDDEN); return; } if (params.get("a").equals(PROJECT_LIST_ACTION)) { rsp.sendRedirect(req.getContextPath() + "/#" + PageLinks.ADMIN_PROJECTS + "?filter=" + Url.encode(params.get("pf") + "/")); return; } String name = params.get("p"); if (name == null) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (name.endsWith(".git")) { name = name.substring(0, name.length() - 4); } final Project.NameKey nameKey = new Project.NameKey(name); final ProjectControl project; try { project = projectControl.validateFor(nameKey); if (!project.allRefsAreVisible() && !project.isOwner()) { throw new NoSuchProjectException(nameKey); } } catch (NoSuchProjectException e) { if (userProvider.get().isIdentifiedUser()) { rsp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { rsp.sendRedirect(getLoginRedirectUrl(req)); } return; } final Repository repo; try { repo = repoManager.openRepository(nameKey); } catch (RepositoryNotFoundException e) { getServletContext().log("Cannot open repository", e); rsp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } try { CacheHeaders.setNotCacheable(rsp); exec(req, rsp, project); } finally { repo.close(); } }
Source:
public Receive createReceive() { return receiveBuilder() .match(Tick.class, message -> { _periodicMetrics.recordCounter("JobExecutorActor-ticks", 1); final JobRepository<T> repo = _jobRef.getRepository(_injector); final Optional<Job<T>> job = _jobRef.get(_injector); if (!job.isPresent()) { LOGGER.warn() .setMessage("no such job") .addData("jobRef", _jobRef) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final UUID id = _jobRef.getJobId(); final Organization org = _jobRef.getOrganization(); final Optional<Instant> lastRun = repo.getLastRun(id, org); final Optional<Instant> nextRun = job.get().getSchedule().nextRun(lastRun); if (!nextRun.isPresent()) { LOGGER.info() .setMessage("job has no more scheduled runs") .addData("jobRef", _jobRef) .addData("schedule", job.get().getSchedule()) .addData("lastRun", lastRun) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final Instant now = _clock.instant(); timers().startSingleTimer("TICK", Tick.INSTANCE, timeUntilNextTick(now, nextRun.get())); if (nextRun.get().isBefore(now)) { execute(repo, org, job.get(), nextRun.get()); } }) .build(); }

Target:
public Receive createReceive() { return receiveBuilder() .match(Tick.class, message -> { _periodicMetrics.recordCounter("job-executor-actor-ticks", 1); final JobRepository<T> repo = _jobRef.getRepository(_injector); final Optional<Job<T>> job = _jobRef.get(_injector); if (!job.isPresent()) { LOGGER.warn() .setMessage("no such job") .addData("jobRef", _jobRef) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } final UUID id = _jobRef.getJobId(); final Organization org = _jobRef.getOrganization(); final Optional<Instant> lastRun = repo.getLastRun(id, org); final Optional<Instant> nextRun = job.get().getSchedule().nextRun(lastRun); if (!nextRun.isPresent()) { LOGGER.info() .setMessage("job has no more scheduled runs") .addData("jobRef", _jobRef) .addData("schedule", job.get().getSchedule()) .addData("lastRun", lastRun) .log(); getSelf().tell(PoisonPill.getInstance(), getSelf()); return; } if (!_clock.instant().isBefore(nextRun.get())) { executeAndScheduleNextTick(repo, org, job.get(), nextRun.get()); } else { scheduleNextTick(nextRun.get()); } }) .build(); }
Source:
public void testKeepsSorting() { preferencesService.getPreferences().getGameListSorting().setAll(FXCollections.observableArrayList( new Pair<>("hostColumn", SortType.DESCENDING) )); instance.initializeGameTable(FXCollections.observableArrayList( GameBuilder.create().defaultValues().get(), GameBuilder.create().defaultValues().state(GameStatus.CLOSED).get() )); assertThat(instance.gamesTable.getSortOrder(), hasSize(1)); assertThat(instance.gamesTable.getSortOrder().get(0).getId(), is("hostColumn")); assertThat(instance.gamesTable.getSortOrder().get(0).getSortType(), is(SortType.DESCENDING)); }

Target:
public void testKeepsSorting() { preferencesService.getPreferences().getGameListSorting().setAll(new Pair<>("hostColumn", SortType.DESCENDING)); instance.initializeGameTable(FXCollections.observableArrayList( GameBuilder.create().defaultValues().get(), GameBuilder.create().defaultValues().state(GameStatus.CLOSED).get() )); assertThat(instance.gamesTable.getSortOrder(), hasSize(1)); assertThat(instance.gamesTable.getSortOrder().get(0).getId(), is("hostColumn")); assertThat(instance.gamesTable.getSortOrder().get(0).getSortType(), is(SortType.DESCENDING)); }
Source:
public void start(ComponentContext context) { super.start(context); ClusterService clusterService = Framework.getService(ClusterService.class); if (clusterService != null && clusterService.isEnabled()) { String nodeId = clusterService.getNodeId(); invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); started = true; }

Target:
public void start(ComponentContext context) { super.start(context); ClusterService clusterService = Framework.getService(ClusterService.class); if (clusterService.isEnabled()) { String nodeId = clusterService.getNodeId(); invalidator = new CachePubSubInvalidator(); invalidator.initialize(CACHE_INVAL_PUBSUB_TOPIC, nodeId); log.info("Registered cache invalidator for node: {}", nodeId); } else { log.info("Not registering a cache invalidator because clustering is not enabled"); } Collection<CacheDescriptor> descriptors = getDescriptors(XP_CACHES); descriptors.forEach(this::startCacheDescriptor); started = true; }
Source:
private String toString(String separator, boolean braces) { if (size == 0) return braces ? "{}" : ""; StringBuilder buffer = new StringBuilder(32); if (braces) buffer.append('{'); K[] keyTable = this.keyTable; V[] valueTable = this.valueTable; int i = keyTable.length; for(int j = i; j > 0; j--) { K key = keyTable[j]; if (key != null) { buffer.append(separator); buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); } } if (braces) buffer.append('}'); return buffer.toString(); }

Target:
private String toString(String separator, boolean braces) { if (size == 0) return braces ? "{}" : ""; StringBuilder buffer = new StringBuilder(32); if (braces) buffer.append('{'); int i = keyTable.length; while (i-- > 0) { K key = keyTable[i]; if (key == null) continue; buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); break; } while (i-- > 0) { K key = keyTable[i]; if (key == null) continue; buffer.append(separator); buffer.append(key); buffer.append('='); buffer.append(valueTable[i]); } if (braces) buffer.append('}'); return buffer.toString(); }
Source:
private void zoom(@NonNull TimeGraphEntry entry, ITmfStateSystem ss, @NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState, @NonNull IProgressMonitor monitor) { List<ITimeEvent> eventList = getEventList(entry, ss, fullStates, prevFullState, monitor); if (eventList != null) { for (ITimeEvent event : eventList) { if (monitor.isCanceled()) { return; } applyResults(() -> { entry.addZoomedEvent(event); }); } } for (ITimeGraphEntry child : entry.getChildren()) { if (monitor.isCanceled()) { return; } if (child instanceof TimeGraphEntry) { zoom((TimeGraphEntry) child, ss, fullStates, prevFullState, monitor); } } }

Target:
private void zoom(@NonNull TimeGraphEntry entry, ITmfStateSystem ss, @NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState, @NonNull IProgressMonitor monitor) { List<ITimeEvent> eventList = getEventList(entry, ss, fullStates, prevFullState, monitor); if (eventList != null) { applyResults(() -> { for (ITimeEvent event : eventList) { if (monitor.isCanceled()) { return; } entry.addZoomedEvent(event); } }); } for (ITimeGraphEntry child : entry.getChildren()) { if (monitor.isCanceled()) { return; } if (child instanceof TimeGraphEntry) { zoom((TimeGraphEntry) child, ss, fullStates, prevFullState, monitor); } } }
Source:
public static long wait(int wait, Callable<Void> callable) throws ExecutionException, WaitTimeoutException { long now = System.currentTimeMillis(); if (wait > 0) { try { FutureTask<Void> task = new FutureTask<>(callable); task.run(); task.get(wait, TimeUnit.SECONDS); } catch (@SuppressWarnings("unused") InterruptedException e) { Thread.currentThread().interrupt(); } catch (@SuppressWarnings("unused") TimeoutException e) { throw new WaitTimeoutException("timed out waiting for execution to complete", delta(now)); } } return delta(now); }

Target:
public static long wait(int wait, Callable<Void> callable) throws ExecutionException, WaitTimeoutException { long now = System.currentTimeMillis(); if (wait > 0) { try { FutureTask<Void> task = new FutureTask<>(callable); task.run(); task.get(wait, TimeUnit.SECONDS); } catch (@SuppressWarnings("unused") InterruptedException e) { Thread.currentThread().interrupt(); } catch (@SuppressWarnings("unused") TimeoutException e) { throw new WaitTimeoutException("timed out waiting for execution to complete: " + e, delta(now)); } } return delta(now); }
Source:
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (UncheckedExecutionException ue) { to.setPublicUri(from.getUrl()); } catch (CacheLoader.InvalidCacheLoadException e) { } if (to.getContentMetadata() != null && to.getContentMetadata().getContentType() != null && to.getContentMetadata().getContentType().equals("application/directory")) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } to.setSize(from.getContentMetadata().getContentLength()); AccessTier tier = from.getTier(); to.setTier((tier != null ? tier : AccessTier.HOT).toTier()); return to; }

Target:
public MutableBlobMetadata apply(BlobProperties from) { if (from == null) return null; MutableBlobMetadata to = new MutableBlobMetadataImpl(); HttpUtils.copy(from.getContentMetadata(), to.getContentMetadata()); to.setUserMetadata(from.getMetadata()); to.setETag(from.getETag()); to.setLastModified(from.getLastModified()); to.setName(from.getName()); to.setContainer(from.getContainer()); to.setUri(from.getUrl()); if (from.getContainer() != null) try { PublicAccess containerAcl = containerAcls.getUnchecked(from.getContainer()); if (containerAcl != PublicAccess.PRIVATE) to.setPublicUri(from.getUrl()); } catch (Exception ex) { InsufficientAccessRightsException iare = Throwables2.getFirstThrowableOfType(ex, InsufficientAccessRightsException.class); if (iare == null) throw ex; } if (to.getContentMetadata() != null && to.getContentMetadata().getContentType() != null && to.getContentMetadata().getContentType().equals("application/directory")) { to.setType(StorageType.FOLDER); } else { to.setType(StorageType.BLOB); } to.setSize(from.getContentMetadata().getContentLength()); AccessTier tier = from.getTier(); to.setTier((tier != null ? tier : AccessTier.HOT).toTier()); return to; }
Source:
public void run() { logger.info("running: " + testID); try { String experimentID = testModelDAO.getRunningExperiment(testID); if (experimentID != null) { experimentManagerService.abortBenchFlowExperiment(experimentID); } } catch (BenchFlowTestIDDoesNotExistException e) { } }

Target:
public void run() { logger.info("running: " + testID); try { String experimentID = testModelDAO.getRunningExperiment(testID); if (experimentID != null) { experimentManagerService.abortBenchFlowExperiment(experimentID); } } catch (BenchFlowTestIDDoesNotExistException e) { e.printStackTrace(); } }
Source:
public boolean equals(final Object o) { if (o == null) { return false; } if (o == this) { return true; } if (this.getClass() != o.getClass()) { return false; } final SnmpV3User that = (SnmpV3User)o; return Objects.equals(getAuthPassPhrase(), that.getAuthPassPhrase()) && Objects.equals(getAuthProtocol(), that.getAuthProtocol()) && Objects.equals(getEngineId(), that.getEngineId()) && Objects.equals(getPrivPassPhrase(), that.getPrivPassPhrase()) && Objects.equals(getPrivProtocol(), that.getPrivProtocol()); }

Target:
public boolean equals(final Object o) { if (o == null) { return false; } if (o == this) { return true; } if (o instanceof SnmpV3User) { final SnmpV3User that = (SnmpV3User)o; return Objects.equals(getAuthPassPhrase(), that.getAuthPassPhrase()) && Objects.equals(getAuthProtocol(), that.getAuthProtocol()) && Objects.equals(getEngineId(), that.getEngineId()) && Objects.equals(getPrivPassPhrase(), that.getPrivPassPhrase()) && Objects.equals(getPrivProtocol(), that.getPrivProtocol()); } else { return false; } }
Source:
public void setup(OperatorContext context) { LOG.debug("APPLICATION PATH FROM PYTHON OPERATOR" + (String)context.getValue(DAGContext.APPLICATION_PATH)); this.pythonWorkerContext.setup(); this.pythonWorkerProxy = new PythonWorkerProxy<>(this.serializedFunction); int port = NetworkUtils.findAvaliablePort(); this.server = new GatewayServer(this.pythonWorkerProxy, port); this.py4jListener = new PythonGenericOperator.PythonGatewayServerListenser(this.server, this.pythonWorkerContext); this.server.addListener(this.py4jListener); this.server.start(true); int pythonServerStartAttempts = 5; while (!this.py4jListener.isPythonServerStarted() && !this.pythonWorkerProxy.isFunctionEnabled() && pythonServerStartAttempts > 0) { try { Thread.sleep(5000L); LOG.debug("Waiting for Python Worker Registration"); --pythonServerStartAttempts; } catch (InterruptedException var9) { var9.printStackTrace(); } } if (this.pythonWorkerProxy.isWorkerRegistered()) { this.pythonWorkerProxy.setFunction(this.operationType.getType()); } if (!this.py4jListener.isPythonServerStarted()) { LOG.error("Python server could not be started"); } }

Target:
public void setup(OperatorContext context) { LOG.debug("Application path from Python Operator: ", (String)context.getValue(DAGContext.APPLICATION_PATH)); server.setup(); }
Source:
public void createNewComponent () { Engine engine = new Engine(); ComponentD componentD = engine.createComponent(ComponentD.class); assertNotEquals(componentD, null); }

Target:
public void createNewComponent () { Engine engine = new Engine(); ComponentD componentD = engine.createComponent(ComponentD.class); assertNotNull(componentD); }
Source:
public static String version(Class<?> weldClass) { String version = null; String timestamp = null; InputStream in = weldClass.getResourceAsStream(BUILD_PROPERTIES_FILE); try { if (in != null) { try { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } finally { in.close(); } } } catch (IOException e) { } if (version == null) { Package pkg = weldClass.getPackage(); if (pkg == null) { throw new IllegalArgumentException("Package can not be null"); } version = pkg.getSpecificationVersion(); timestamp = pkg.getImplementationVersion(); } return version(version, timestamp); }

Target:
public static String version(Class<?> weldClass) { String version = null; String timestamp = null; try (InputStream in = weldClass.getResourceAsStream(BUILD_PROPERTIES_FILE)) { if (in != null) { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } } catch (IOException e) { } if (version == null) { Package pkg = weldClass.getPackage(); if (pkg == null) { throw new IllegalArgumentException("Package can not be null"); } version = pkg.getSpecificationVersion(); timestamp = pkg.getImplementationVersion(); } return version(version, timestamp); }
Source:
private Runnable createValidatableRunnable(CheckType checkType, IJobManager manager) { return () -> { try { long runningExpensiveJobs = Arrays.asList(manager.find(CheckType.EXPENSIVE.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningNormalJobs = Arrays.asList(manager.find(CheckType.NORMAL.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningFastJobs = Arrays.asList(manager.find(CheckType.FAST.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long allRunningJobs = runningExpensiveJobs + runningFastJobs + runningNormalJobs; assertTrue(allRunningJobs <= VALIDATION_THREAD_COUNT); if (CheckType.EXPENSIVE == checkType) { assertTrue(runningExpensiveJobs == MAXIMUM_AMOUNT_OF_RUNNING_EXPENSIVE_JOBS); } if (CheckType.NORMAL == checkType) { assertTrue(runningNormalJobs <= MAXIMUM_AMOUNT_OF_RUNNING_NORMAL_JOBS); } Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } }; }

Target:
private Runnable createValidatableRunnable(CheckType checkType, IJobManager manager) { long runTime = checkType == CheckType.EXPENSIVE ? EXPENSIVE_JOB_RUNTIME : CheckType.NORMAL == checkType ? NORMAL_JOB_RUNTIME : FAST_JOB_RUNTIME; return () -> { try { long runningExpensiveJobs = Arrays.asList(manager.find(CheckType.EXPENSIVE.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningNormalJobs = Arrays.asList(manager.find(CheckType.NORMAL.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long runningFastJobs = Arrays.asList(manager.find(CheckType.FAST.getName())).stream().filter(job -> job.getState() == Job.RUNNING).count(); long allRunningJobs = runningExpensiveJobs + runningFastJobs + runningNormalJobs; assertTrue(allRunningJobs <= VALIDATION_THREAD_COUNT); System.out.println( String.format( "Number of expensive ones are [%d], number of normal ones [%d], number of fast ones [%d]", runningExpensiveJobs, runningNormalJobs, runningFastJobs) ); if (CheckType.EXPENSIVE == checkType) { assertTrue(runningExpensiveJobs <= MAXIMUM_AMOUNT_OF_RUNNING_EXPENSIVE_JOBS); } if (CheckType.NORMAL == checkType) { assertTrue(runningNormalJobs <= MAXIMUM_AMOUNT_OF_RUNNING_NORMAL_JOBS); } Thread.sleep(runTime); } catch (InterruptedException e) { throw new RuntimeException(e); } }; }
Source:
static Stream<Set<Integer>> generatePartitions(int totalNodes) { checkArgument(totalNodes >= 2, "totalNodes must be greater than or equal to 2"); Set<Integer> numbers = IntStream.range(0, totalNodes) .boxed() .collect(toImmutableSet()); return Sets.powerSet(numbers).stream() .filter(subSet -> subSet.contains(0)) .filter(subSet -> subSet.size() < numbers.size()); }

Target:
static Set<Set<Integer>> generatePartitions(int totalNodes) { checkArgument(totalNodes > 1, "totalNodes must be greater than 1"); Set<Integer> numbers = IntStream.range(0, totalNodes) .boxed() .collect(toImmutableSet()); return powerSet(numbers).stream() .filter(subSet -> subSet.contains(0)) .filter(subSet -> subSet.size() < numbers.size()) .collect(toImmutableSet()); }