auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private boolean updateGroupDescription(PerunSession sess, Group groupWithOldDescription, CandidateGroup groupWithNewDescription) throws InternalErrorException { if(groupWithOldDescription.getDescription() != null) { if(!groupWithOldDescription.getDescription().equals(groupWithNewDescription.asGroup().getDescription())){ groupWithOldDescription.setDescription(groupWithNewDescription.asGroup().getDescription()); groupsManagerImpl.updateGroup(sess, groupWithOldDescription); return true; } } else if(groupWithNewDescription.asGroup().getDescription() != null){ groupWithOldDescription.setDescription(groupWithNewDescription.asGroup().getDescription()); groupsManagerImpl.updateGroup(sess, groupWithOldDescription); return true; } return false; }

Target:
private boolean updateGroupDescription(PerunSession sess, Group groupWithOldDescription, CandidateGroup groupWithNewDescription) throws InternalErrorException { if(groupWithOldDescription.getDescription() != null) { if(!groupWithOldDescription.getDescription().equals(groupWithNewDescription.asGroup().getDescription())){ groupWithOldDescription.setDescription(groupWithNewDescription.asGroup().getDescription()); groupsManagerImpl.updateGroup(sess, groupWithOldDescription); getPerunBl().getAuditer().log(sess, new GroupUpdated(groupWithOldDescription)); return true; } } else if(groupWithNewDescription.asGroup().getDescription() != null){ groupWithOldDescription.setDescription(groupWithNewDescription.asGroup().getDescription()); groupsManagerImpl.updateGroup(sess, groupWithOldDescription); getPerunBl().getAuditer().log(sess, new GroupUpdated(groupWithOldDescription)); return true; } return false; }
Source:
public boolean process(final ZigBeeApi zigbeeApi, final String[] args) { final List<ZigBeeNode> nodes = zigbeeApi.getNodes(); for (int i = 0; i < nodes.size(); i++) { final ZigBeeNode node = nodes.get(i); print("IEEE Address : " + node.getIeeeAddress()); print("Network Address : " + String.format("%04X", node.getNetworkAddress())); ZigBeeNodeDescriptor nodeDescriptor = node.getNodeDescriptor(); if(nodeDescriptor != null) { print("Node Descriptor : Logical Type " + nodeDescriptor.getLogicalType()); print(" : Manufacturer Code " + String.format("%04X", nodeDescriptor.getManufacturerCode())); print(" : Max Buffer Size " + nodeDescriptor.getMaximumBufferSize()); print(" : Max Transfer Size " + nodeDescriptor.getMaximumTransferSize()); } ZigBeeNodePowerDescriptor powerDescriptor = node.getPowerDescriptor(); if(powerDescriptor != null) { print("Power Descriptor : Power Mode " + powerDescriptor.getPowerMode()); print(" : Power Source " + powerDescriptor.getPowerSource()); print(" : Power Level " + powerDescriptor.getPowerLevel()); print(" : Power Available " + powerDescriptor.getPowerSourcesAvailable()); } print("-"); } return true; }

Target:
public boolean process(final ZigBeeApi zigbeeApi, final String[] args) { final List<ZigBeeNode> nodes = zigbeeApi.getNodes(); for (int i = 0; i < nodes.size(); i++) { final ZigBeeNode node = nodes.get(i); print("IEEE Address : " + node.getIeeeAddress()); print("Network Address : #" + node.getNetworkAddress()); ZigBeeNodeDescriptor nodeDescriptor = node.getNodeDescriptor(); if(nodeDescriptor != null) { print("Node Descriptor : Logical Type " + nodeDescriptor.getLogicalType()); print(" : Manufacturer Code " + String.format("%04X", nodeDescriptor.getManufacturerCode())); print(" : Max Buffer Size " + nodeDescriptor.getMaximumBufferSize()); print(" : Max Transfer Size " + nodeDescriptor.getMaximumTransferSize()); print(" : MAC Capabilities " + nodeDescriptor.getMacCapabilities()); print(" : Server Mask " + nodeDescriptor.getServerMask()); } ZigBeeNodePowerDescriptor powerDescriptor = node.getPowerDescriptor(); if(powerDescriptor != null) { print("Power Descriptor : Power Mode " + powerDescriptor.getPowerMode()); print(" : Power Source " + powerDescriptor.getPowerSource()); print(" : Power Level " + powerDescriptor.getPowerLevel()); print(" : Power Available " + powerDescriptor.getPowerSourcesAvailable()); } print("-"); } return true; }
Source:
public boolean hasPatchPermission(Authentication authentication, Serializable targetId, String targetType, Patch patch) { if (!hasPermission(authentication, targetId, targetType, "WRITE")) { return false; } List<Operation> operations = patch.getOperations(); for (Operation op: operations) { if (op.getPath().contentEquals(EPersonOperationFactory.OPERATION_PASSWORD_CHANGE)) { return true; } } return false; }

Target:
public boolean hasPatchPermission(Authentication authentication, Serializable targetId, String targetType, Patch patch) { if (!hasPermission(authentication, targetId, targetType, "WRITE")) { return false; } List<Operation> operations = patch.getOperations(); for (Operation op: operations) { if (!op.getPath().contentEquals(EPersonOperationFactory.OPERATION_PASSWORD_CHANGE)) { return false; } } return true; }
Source:
public void configureLogback( ServletContext servletContext, File logDirFallback ) throws IOException { log.debug("Reconfiguring Logback!"); File logDir = FileSystemManager.getWriteableDirectoryWithFailovers(servletContext.getInitParameter(LOG_DIR_INIT_PARAM), logDirFallback.getAbsolutePath()); if(logDir != null) { log.debug("Resetting logback context."); URL configFile = servletContext.getResource("/WEB-INF/context-logback.xml"); log.debug("Configuring logback with file, {}", configFile); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); try { JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.stop(); context.reset(); context.putProperty("logDir", logDir.getCanonicalPath()); configurator.doConfigure(configFile); } catch (JoranException je) { je.printStackTrace(); } finally { context.start(); log.debug("Done resetting logback."); } StatusPrinter.printInCaseOfErrorsOrWarnings(context); } }

Target:
public void configureLogback( ServletContext servletContext, File logDirFallback ) throws FileNotFoundException, MalformedURLException, IOException { log.debug("Reconfiguring Logback!"); File logDir = FileSystemManager.getWritableDirectoryWithFailovers(servletContext.getInitParameter(LOG_DIR_INIT_PARAM), logDirFallback.getAbsolutePath()); if(logDir != null) { log.debug("Resetting logback context."); URL configFile = servletContext.getResource("/WEB-INF/context-logback.xml"); log.debug("Configuring logback with file, {}", configFile); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); try { JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.stop(); context.reset(); context.putProperty("logDir", logDir.getCanonicalPath()); configurator.doConfigure(configFile); } catch (JoranException je) { } finally { context.start(); log.debug("Done resetting logback."); } StatusPrinter.printInCaseOfErrorsOrWarnings(context); } }
Source:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); loadData(); String base64EncodedPublicKey = "cONSTRUCT_YOUR_KEY_AND_PLACE_IT_HERE"; String samsungGroupId = "PLACE_HERE_SAMSUNG_GROUP_ID"; String tstoreAppId = "PLACE_HERE_TSTORE_APP_ID"; String YANDEX_PUBLIC_KEY = "PLACE_HERE_YANDEX_KEY"; if (base64EncodedPublicKey.contains("CONSTRUCT_YOUR")) { throw new RuntimeException("Please put your app's public key in MainActivity.java. See README."); } if (getPackageName().startsWith("com.example")) { throw new RuntimeException("Please change the sample's package name! See README."); } Log.d(TAG, "Creating IAB helper."); Map<String, String> storeKeys = new HashMap<String, String>(); storeKeys.put(OpenIabHelper.NAME_GOOGLE, base64EncodedPublicKey); storeKeys.put(OpenIabHelper.NAME_SAMSUNG, samsungGroupId); storeKeys.put(OpenIabHelper.NAME_TSTORE, tstoreAppId); storeKeys.put("YandexPublicKey", YANDEX_PUBLIC_KEY); mHelper = new OpenIabHelper(this, storeKeys); Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { complain("Problem setting up in-app billing: " + result); return; } Log.d(TAG, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); }

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); loadData(); String base64EncodedPublicKey = "CONSTRUCT_YOUR_KEY_AND_PLACE_IT_HERE"; String samsungGroupId = "PLACE_HERE_SAMSUNG_GROUP_ID"; String tstoreAppId = "PLACE_HERE_TSTORE_APP_ID"; String YANDEX_PUBLIC_KEY = "PLACE_HERE_YANDEX_KEY"; if (base64EncodedPublicKey.contains("CONSTRUCT_YOUR")) { throw new RuntimeException("Please put your app's public key in MainActivity.java. See README."); } if (getPackageName().startsWith("com.example")) { throw new RuntimeException("Please change the sample's package name! See README."); } Log.d(TAG, "Creating IAB helper."); Map<String, String> storeKeys = new HashMap<String, String>(); storeKeys.put(OpenIabHelper.NAME_GOOGLE, base64EncodedPublicKey); storeKeys.put(OpenIabHelper.NAME_SAMSUNG, samsungGroupId); storeKeys.put(OpenIabHelper.NAME_TSTORE, tstoreAppId); storeKeys.put("YandexPublicKey", YANDEX_PUBLIC_KEY); mHelper = new OpenIabHelper(this, storeKeys); Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { complain("Problem setting up in-app billing: " + result); return; } Log.d(TAG, "Setup successful. Querying inventory."); mHelper.queryInventoryAsync(mGotInventoryListener); } }); }
Source:
private void validateTypeCombination(OMElement sourceEle, OMElement targetEle) { int sourceType = -1; int targetType = -1; OMAttribute sourceTypeAttr = sourceEle.getAttribute(ATT_TYPE); if (sourceTypeAttr != null && sourceTypeAttr.getAttributeValue() != null) { sourceType = convertTypeToInit(sourceTypeAttr.getAttributeValue()); if (sourceType < 0) { logger.info("Un-expected source type"); } } OMAttribute targetTypeAttr = targetEle.getAttribute(ATT_TYPE); if (targetTypeAttr != null && targetTypeAttr.getAttributeValue() != null) { targetType = convertTypeToInit(targetTypeAttr.getAttributeValue()); if (targetType < 0) { logger.info("Un-expected target type"); } if (targetType == 1) { throw new SynapseException("Envelope not support for target attribute"); } } if ((sourceType == 1 && targetType == 0) || (sourceType == 1 && targetType == 2) || (sourceType == 2 && targetType == 2)) { throw new SynapseException("Wrong combination of source and target type"); } }

Target:
private void validateTypeCombination(OMElement sourceEle, OMElement targetEle) { int sourceType = -1; int targetType = -1; OMAttribute sourceTypeAttr = sourceEle.getAttribute(ATT_TYPE); if (sourceTypeAttr != null && sourceTypeAttr.getAttributeValue() != null) { sourceType = convertTypeToInt(sourceTypeAttr.getAttributeValue()); if (sourceType < 0) { logger.info("Un-expected source type"); } } OMAttribute targetTypeAttr = targetEle.getAttribute(ATT_TYPE); if (targetTypeAttr != null && targetTypeAttr.getAttributeValue() != null) { targetType = convertTypeToInt(targetTypeAttr.getAttributeValue()); if (targetType < 0) { logger.info("Un-expected target type"); } if (targetType == 1) { throw new SynapseException("Envelope not support for target attribute"); } if (targetType == 4) { throw new SynapseException("Inline not support for target attribute"); } } if ((sourceType == 1 && targetType == 0) || (sourceType == 1 && targetType == 2) || (sourceType == 2 && targetType == 2)) { throw new SynapseException("Wrong combination of source and target type"); } }
Source:
protected EvaluationSampleSummaryRecord createRecord(final DataLine dataLine) { final String sample = dataLine.get(EvaluationSampleSummaryWriter.SAMPLE_NAME_COLUMN_NAME); final EvaluationSampleSummaryRecord result = new EvaluationSampleSummaryRecord(sample); for (final EvaluationClass clazz : EvaluationClass.values()) { result.set(clazz, dataLine.getInt(clazz.acronym)); } return result; }

Target:
protected EvaluationSampleSummaryRecord createRecord(final DataLine dataLine) { final String sample = dataLine.get(EvaluationSampleSummaryWriter.SAMPLE_NAME_COLUMN_NAME); final EvaluationSampleSummaryRecord result = new EvaluationSampleSummaryRecord(sample); for (final EvaluationClass evaluationClass : EvaluationClass.values()) { result.set(evaluationClass, dataLine.getInt(evaluationClass.acronym)); } return result; }
Source:
public boolean include(RevWalk walker, RevCommit cmit) throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException { boolean first = cmit.has(firstParent); boolean later = cmit.has(laterParent); boolean include = first || (!first && !later); for (int i = 0; i < cmit.getParentCount(); i++) { RevCommit p = cmit.getParent(i); if (i == 0 && include) { p.add(firstParent); } else { p.add(laterParent); } } return include; }

Target:
public boolean include(RevWalk walker, RevCommit cmit) throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException { boolean include = cmit.has(start) || cmit.has(firstParent); for (int i = 0; i < cmit.getParentCount(); i++) { RevCommit p = cmit.getParent(i); if (i == 0 && include) { p.add(firstParent); } } return include; }
Source:
public void checkAttributeValue(PerunSessionImpl perunSession, String key, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { if(attribute.getValue() == null) return; if(!(attribute.getValue() instanceof String)) { throw new WrongAttributeValueException(attribute, key, "value must be of type String"); } String value = attribute.valueAsString(); if(!value.contains("{link}")){ throw new WrongAttributeValueException(attribute, key, "value doesn't contain contain tag {link}"); } if(!value.contains("{displayName}")){ throw new WrongAttributeValueException(attribute, key, "value doesn't contain contain tag {displayName}"); } if(!value.contains("{namespace}")){ throw new WrongAttributeValueException(attribute, key, "value doesn't contain contain tag {namespace}"); } if(!value.contains("{validity}")){ throw new WrongAttributeValueException(attribute, key, "value doesn't contain contain tag {validity}"); } }

Target:
public void checkAttributeValue(PerunSessionImpl perunSession, String key, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { if (attribute.getValue() == null) return; if (!(attribute.getValue() instanceof String)) { throw new WrongAttributeValueException(attribute, key, "value must be of type String"); } String value = attribute.valueAsString(); if (!value.contains("{link}")) { throw new WrongAttributeValueException(attribute, key, "value doesn't contain contain tag {link}"); } }
Source:
private void createVmCheckpoint() { VmBackup vmBackup = getParameters().getVmBackup(); final VmCheckpoint vmCheckpoint = new VmCheckpoint(); vmCheckpoint.setId(vmBackup.getToCheckpointId()); vmCheckpoint.setParentId(vmBackup.getFromCheckpointId()); vmCheckpoint.setVmId(vmBackup.getVmId()); vmCheckpoint.setCreationDate(new Date()); final List<VmCheckpoint> checkpoints = vmCheckpointDao.getAllForVm(getVmId()); if (!checkpoints.isEmpty()) { vmCheckpoint.setParentId(checkpoints.get(checkpoints.size() - 1).getId()); } TransactionSupport.executeInNewTransaction(() -> { vmCheckpointDao.save(vmCheckpoint); getParameters().getVmBackup().getDisks().forEach( disk -> vmCheckpointDao.addDiskToCheckpoint(vmCheckpoint.getId(), disk.getId())); return null; }); persistCommandIfNeeded(); }

Target:
private void createVmCheckpoint() { VmBackup vmBackup = getParameters().getVmBackup(); final VmCheckpoint vmCheckpoint = new VmCheckpoint(); vmCheckpoint.setId(vmBackup.getToCheckpointId()); vmCheckpoint.setParentId(vmBackup.getFromCheckpointId()); vmCheckpoint.setVmId(vmBackup.getVmId()); vmCheckpoint.setCreationDate(new Date()); final List<VmCheckpoint> checkpoints = vmCheckpointDao.getAllForVm(getVmId()); if (!checkpoints.isEmpty()) { vmCheckpoint.setParentId(checkpoints.get(checkpoints.size() - 1).getId()); } TransactionSupport.executeInNewTransaction(() -> { vmCheckpointDao.save(vmCheckpoint); vmBackup.getDisks().forEach( disk -> vmCheckpointDao.addDiskToCheckpoint(vmCheckpoint.getId(), disk.getId())); return null; }); persistCommandIfNeeded(); }
Source:
public void deleteMetadata(String metadataName) { Metadata aux= null; for (int i=0; i < metadatas.size(); i++) { if (metadatas.get(i).getKey().equals(metadataName)) { aux = metadatas.get(i); } } metadatas.remove(aux); }

Target:
public void deleteMetadata(String metadataName) throws EntityNotFoundException { metadatas.remove(getMetadata(metadataName)); }
Source:
public void testCreate() { final EClassSelectionStrategy strategy = provider.create(); assertNotNull(strategy); final Collection<EClass> collectEClasses = strategy.collectEClasses(null, null, null); final Collection<EClass> allFromRegistry = collectAllFromRegistry(); assertEquals(allFromRegistry.size(), collectEClasses.size()); for (final EClass eClass : allFromRegistry) { assertTrue(collectEClasses.contains(eClass)); } }

Target:
public void testCreate() { final EClassSelectionStrategy strategy = provider.create(); assertNotNull(strategy); final Collection<EClass> collectEClasses = strategy.collectEClasses(null, DataTemplatePackage.eINSTANCE.getTemplate_Instance(), null); final Collection<EClass> allFromRegistry = collectAllFromRegistry(); assertEquals(allFromRegistry.size(), collectEClasses.size()); for (final EClass eClass : allFromRegistry) { assertTrue(collectEClasses.contains(eClass)); } }
Source:
protected final Fix getSuggestedFix(AnnotationTree annotationTree) { List<String> values = new ArrayList<>(); for (ExpressionTree argumentTree : annotationTree.getArguments()) { AssignmentTree assignmentTree = (AssignmentTree) argumentTree; if (assignmentTree.getVariable().toString().equals("value")) { ExpressionTree expressionTree = assignmentTree.getExpression(); switch (expressionTree.getKind()) { case STRING_LITERAL: values.add(((String) ((JCTree.JCLiteral) expressionTree).value)); break; case NEW_ARRAY: NewArrayTree newArrayTree = (NewArrayTree) expressionTree; for (ExpressionTree elementTree : newArrayTree.getInitializers()) { values.add((String) ((JCTree.JCLiteral) elementTree).value); } break; default: throw new AssertionError("Unknown kind: " + expressionTree.getKind()); } processSuppressWarningsValues(values); } else { throw new AssertionError("SuppressWarnings has an element other than value="); } } if (values.isEmpty()) { return SuggestedFix.delete(annotationTree); } else if (values.size() == 1) { return SuggestedFix.replace(annotationTree, "@SuppressWarnings(\"" + values.get(0) + "\")"); } else { StringBuilder sb = new StringBuilder("@SuppressWarnings({\"" + values.get(0) + "\""); for (int i = 1; i < values.size(); i++) { sb.append(", "); sb.append('"').append(values.get(i)).append('"'); } sb.append("})"); return SuggestedFix.replace(annotationTree, sb.toString()); } }

Target:
protected final Fix getSuggestedFix(AnnotationTree annotationTree) { List<String> values = new ArrayList<>(); for (ExpressionTree argumentTree : annotationTree.getArguments()) { AssignmentTree assignmentTree = (AssignmentTree) argumentTree; if (assignmentTree.getVariable().toString().equals("value")) { ExpressionTree expressionTree = assignmentTree.getExpression(); switch (expressionTree.getKind()) { case STRING_LITERAL: values.add(((String) ((JCTree.JCLiteral) expressionTree).value)); break; case NEW_ARRAY: NewArrayTree newArrayTree = (NewArrayTree) expressionTree; for (ExpressionTree elementTree : newArrayTree.getInitializers()) { values.add((String) ((JCTree.JCLiteral) elementTree).value); } break; default: throw new AssertionError("Unknown kind: " + expressionTree.getKind()); } processSuppressWarningsValues(values); } else { throw new AssertionError("SuppressWarnings has an element other than value="); } } if (values.isEmpty()) { return SuggestedFix.delete(annotationTree); } else if (values.size() == 1) { return SuggestedFix.replace(annotationTree, "@SuppressWarnings(\"" + values.get(0) + "\")"); } else { return SuggestedFix.replace( annotationTree, "@SuppressWarnings({\"" + Joiner.on("\", \"").join(values) + "\"})"); } }
Source:
public ClusterDrawable(List<SequenceNode> clustered) { this.clustered = clustered; c = new Circle(CLUSTER_SIZE, Color.BLUE); c.setOnMouseClicked(e -> System.out.println(clustered)); Text t = new Text(Integer.toString(clustered.size())); t.setStyle("-fx-font-size: 2pt"); getChildren().add(c); getChildren().add(t); }

Target:
public ClusterDrawable(List<SequenceNode> clustered) { this.clustered = clustered; shape = new Circle(CLUSTER_SIZE, Color.BLUE); shape.setOnMouseClicked(e -> System.out.println(clustered)); Text label = new Text(Integer.toString(clustered.size())); label.setStyle("-fx-font-size: 2pt"); getChildren().add(shape); getChildren().add(label); }
Source:
public static InitialMessage parse( Long protocolVersion, DataInputStream din ) throws InitialMessageException, IOException { Long sid; if (protocolVersion != PROTOCOL_VERSION) { throw new InitialMessageException("Got unrecognized protocol version %s", protocolVersion); } sid = din.readLong(); int remaining = din.readInt(); if (remaining <= 0 || remaining > maxBuffer) { throw new InitialMessageException("Unreasonable buffer length: %s", remaining); } byte[] b = new byte[remaining]; int numRead = din.read(b); if (numRead != remaining) { throw new InitialMessageException( "Read only %s bytes out of %s sent by server %s", numRead, remaining, sid); } String addr = new String(b); String[] hostPort; try { hostPort = ConfigUtils.getHostAndPort(addr); } catch (ConfigException e) { throw new InitialMessageException("Badly formed address: %s", addr); } if (hostPort.length != 2) { throw new InitialMessageException("Badly formed address: %s", addr); } int port; try { port = Integer.parseInt(hostPort[1]); } catch (NumberFormatException e) { throw new InitialMessageException("Bad port number: %s", hostPort[1]); } catch (ArrayIndexOutOfBoundsException e) { throw new InitialMessageException("No port number in: %s", addr); } return new InitialMessage(sid, new InetSocketAddress(hostPort[0], port)); }

Target:
public static InitialMessage parse(Long protocolVersion, DataInputStream din) throws InitialMessageException, IOException { Long sid; if (protocolVersion != PROTOCOL_VERSION) { throw new InitialMessageException("Got unrecognized protocol version %s", protocolVersion); } sid = din.readLong(); int remaining = din.readInt(); if (remaining <= 0 || remaining > maxBuffer) { throw new InitialMessageException("Unreasonable buffer length: %s", remaining); } byte[] b = new byte[remaining]; int num_read = din.read(b); if (num_read != remaining) { throw new InitialMessageException("Read only %s bytes out of %s sent by server %s", num_read, remaining, sid); } String addr = new String(b); String[] host_port; try { host_port = ConfigUtils.getHostAndPort(addr); } catch (ConfigException e) { throw new InitialMessageException("Badly formed address: %s", addr); } if (host_port.length != 2) { throw new InitialMessageException("Badly formed address: %s", addr); } int port; try { port = Integer.parseInt(host_port[1]); } catch (NumberFormatException e) { throw new InitialMessageException("Bad port number: %s", host_port[1]); } catch (ArrayIndexOutOfBoundsException e) { throw new InitialMessageException("No port number in: %s", addr); } return new InitialMessage(sid, new InetSocketAddress(host_port[0], port)); }
Source:
public void test_overnightIndexRateForward_badDatesNotSorted() { LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.EMPTY_SERIES; MulticurveProviderInterface mock = Mockito.mock(MulticurveProviderInterface.class); ImmutablePricingEnvironment test = ImmutablePricingEnvironment.builder() .valuationDate(VAL_DATE) .multicurve(mock) .timeSeries(ImmutableMap.of(USD_FED_FUND, ts)) .dayCount(ACT_ACT_ISDA) .build(); assertThrows( () -> test.overnightIndexRatePeriod(USD_FED_FUND, NEXT_DATE, VAL_DATE), IllegalArgumentException.class); }

Target:
public void test_overnightIndexRateForward_badDatesNotSorted() { LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.EMPTY_SERIES; MulticurveProviderInterface mock = Mockito.mock(MulticurveProviderInterface.class); ImmutablePricingEnvironment test = ImmutablePricingEnvironment.builder() .valuationDate(VAL_DATE) .multicurve(mock) .timeSeries(ImmutableMap.of(USD_FED_FUND, ts)) .dayCount(ACT_ACT_ISDA) .build(); assertThrowsIllegalArg(() -> test.overnightIndexRatePeriod(USD_FED_FUND, NEXT_DATE, VAL_DATE)); }
Source:
public void testProps() throws Exception { Context context = new Context(); context.put("kafka.producer.some-parameter", "1"); context.put("kafka.consumer.another-parameter", "1"); context.put("offsets.topic.replication.factor", "1"); context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl()); context.put(TOPIC_CONFIG, topic); final KafkaChannel channel = new KafkaChannel(); Configurables.configure(channel, context); Properties consumerProps = channel.getConsumerProps(); Properties producerProps = channel.getProducerProps(); Assert.assertEquals(producerProps.getProperty("some-parameter"), "1"); Assert.assertEquals(consumerProps.getProperty("another-parameter"), "1"); }

Target:
public void testProps() throws Exception { Context context = new Context(); context.put("kafka.producer.some-parameter", "1"); context.put("kafka.consumer.another-parameter", "1"); context.put(BOOTSTRAP_SERVERS_CONFIG, testUtil.getKafkaServerUrl()); context.put(TOPIC_CONFIG, topic); final KafkaChannel channel = new KafkaChannel(); Configurables.configure(channel, context); Properties consumerProps = channel.getConsumerProps(); Properties producerProps = channel.getProducerProps(); Assert.assertEquals(producerProps.getProperty("some-parameter"), "1"); Assert.assertEquals(consumerProps.getProperty("another-parameter"), "1"); }
Source:
private Job(final JobId id, final Builder.Parameters p) { this.id = checkNotNull(id, "id"); this.image = checkNotNull(p.image, "image"); this.command = ImmutableList.copyOf(checkNotNull(p.command, "command")); this.env = ImmutableMap.copyOf(checkNotNull(p.env, "env")); this.ports = ImmutableMap.copyOf(checkNotNull(p.ports, "ports")); this.registration = ImmutableMap.copyOf(checkNotNull(p.registration, "registration")); this.volumes = ImmutableMap.copyOf(checkNotNull(p.volumes, "volumes")); this.registrationDomain = checkNotNull(p.registrationDomain); }

Target:
private Job(final JobId id, final Builder.Parameters p) { this.id = checkNotNull(id, "id"); this.image = checkNotNull(p.image, "image"); this.command = ImmutableList.copyOf(checkNotNull(p.command, "command")); this.env = ImmutableMap.copyOf(checkNotNull(p.env, "env")); this.ports = ImmutableMap.copyOf(checkNotNull(p.ports, "ports")); this.registration = ImmutableMap.copyOf(checkNotNull(p.registration, "registration")); this.volumes = ImmutableMap.copyOf(checkNotNull(p.volumes, "volumes")); this.expires = p.expires; this.registrationDomain = Optional.fromNullable(p.registrationDomain) .or(EMPTY_REGISTRATION_DOMAIN); }
Source:
public void login_use_fallback_server() { LdapContainer ldapContainer = ldap.get(); GlobalSecurityConfig securityConfig = new GlobalSecurityConfig(jenkins); securityConfig.configure(); LdapSecurityRealm realm = securityConfig.useRealm(LdapSecurityRealm.class); int freePort = this.findAvailablePort(); LdapDetails ldapDetails = new LdapDetails("", 0, ldapContainer.getManagerDn(), ldapContainer.getManagerPassword(), ldapContainer.getRootDn()); ldapDetails.setHostWithPort(ldapContainer.getHost()+":" + freePort + " " + ldapContainer.getHost() + ":" + ldapContainer.getPort()); realm.configure(ldapDetails); securityConfig.save(); Login login = jenkins.login(); login.doLogin("jenkins", "root"); assertThat(jenkins, hasLoggedInUser("jenkins")); }

Target:
public void login_use_fallback_server() { LdapContainer ldapContainer = ldap.get(); GlobalSecurityConfig securityConfig = new GlobalSecurityConfig(jenkins); securityConfig.configure(); LdapSecurityRealm realm = securityConfig.useRealm(LdapSecurityRealm.class); int freePort = this.findAvailablePort(); LdapDetails ldapDetails = new LdapDetails("", 0, ldapContainer.getManagerDn(), ldapContainer.getManagerPassword(), ldapContainer.getRootDn()); ldapDetails.setHostWithPort("localhost:" + freePort + ' ' + ldapContainer.getHost() + ':' + ldapContainer.getPort()); realm.configure(ldapDetails); securityConfig.save(); Login login = jenkins.login(); login.doLogin("jenkins", "root"); assertThat(jenkins, hasLoggedInUser("jenkins")); }
Source:
public void setUp() throws Exception { Project project = new Project(InstrumentationRegistry.getTargetContext(), "testProject"); filePath = project.getDefaultScene().getDirectory() + "/" + IMAGE_DIRECTORY_NAME + "/collision_donut.png"; Sprite sprite = new SingleSprite("testSprite"); project.getDefaultScene().addSprite(sprite); ProjectManager.getInstance().setProject(project); ProjectManager.getInstance().setCurrentSprite(sprite); XstreamSerializer.getInstance().saveProject(project); File imageFile = ResourceImporter.createImageFileFromResourcesInDirectory( InstrumentationRegistry.getContext().getResources(), org.catrobat.catroid.test.R.raw.collision_donut, new File(project.getDefaultScene().getDirectory(), IMAGE_DIRECTORY_NAME), "collision_donut.png", 1); lookData = new LookData("test", imageFile); sprite.getLookList().add(lookData); }

Target:
public void setUp() throws Exception { Project project = new Project(InstrumentationRegistry.getTargetContext(), getClass().getSimpleName()); filePath = project.getDefaultScene().getDirectory() + "/" + IMAGE_DIRECTORY_NAME + "/collision_donut.png"; Sprite sprite = new SingleSprite("testSprite"); project.getDefaultScene().addSprite(sprite); ProjectManager.getInstance().setCurrentProject(project); ProjectManager.getInstance().setCurrentSprite(sprite); XstreamSerializer.getInstance().saveProject(project); File imageFile = ResourceImporter.createImageFileFromResourcesInDirectory( InstrumentationRegistry.getContext().getResources(), org.catrobat.catroid.test.R.raw.collision_donut, new File(project.getDefaultScene().getDirectory(), IMAGE_DIRECTORY_NAME), "collision_donut.png", 1); lookData = new LookData("test", imageFile); sprite.getLookList().add(lookData); }
Source:
public String serialize() { graphType.isTypeCompatible(graph); switch (graphType) { case ELK: ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.createResource(URI.createFileURI("dummy.elkg")); if (resource instanceof ElkGraphResource) { resource.getContents().add((ElkNode) graph); try { StringWriter stringWriter = new StringWriter(); ((ElkGraphResource) resource).save(stringWriter, Collections.emptyMap()); return stringWriter.toString(); } catch (Exception e) { } } return "Unexpected problem serializing ELK Graph."; default: return graph.toString(); } }

Target:
public String serialize() { switch (graphType) { case ELK: ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.createResource(URI.createFileURI("dummy.elkg")); if (resource instanceof ElkGraphResource) { resource.getContents().add((ElkNode) graph); try { StringWriter stringWriter = new StringWriter(); ((ElkGraphResource) resource).save(stringWriter, Collections.emptyMap()); return stringWriter.toString(); } catch (Exception e) { } } return "Unexpected problem serializing ELK Graph."; default: return graph.toString(); } }
Source:
private void setupPipeline(SocketChannel channel, RouteMatcher router) { final ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("decoder", new HttpRequestDecoder() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable thr) throws Exception { try { if (ctx.channel().isWritable()) { log.debug("request decoder error " + thr.getCause().toString() + " on channel " + ctx.channel().toString()); ctx.channel().write( new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)) .addListener(ChannelFutureListener.CLOSE); } else { log.debug("channel " + ctx.channel().toString() + " is no longer writeable, not sending 400 response back to client"); } } catch (Exception ex) { log.debug("Can't write to channel " + ctx.channel().toString(), ex); } } }); pipeline.addLast("chunkaggregator", new HttpObjectAggregator(Constants.MAX_CONTENT_LENGTH)); pipeline.addLast("handler", new QueryStringDecoderAndRouter(router)); }

Target:
private void setupPipeline(SocketChannel channel, RouteMatcher router) { final ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("decoder", new HttpRequestDecoder() { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable thr) throws Exception { try { if (ctx.channel().isWritable()) { log.debug("request decoder error " + thr.getCause().toString() + " on channel " + ctx.channel().toString()); ctx.channel().write( new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.BAD_REQUEST)) .addListener(ChannelFutureListener.CLOSE); } else { log.debug("channel " + ctx.channel().toString() + " is no longer writeable, not sending 400 response back to client"); } } catch (Exception ex) { log.debug("Can't write to channel " + ctx.channel().toString(), ex); } } }); pipeline.addLast("chunkaggregator", new HttpObjectAggregator(httpMaxContentLength)); pipeline.addLast("handler", new QueryStringDecoderAndRouter(router)); }
Source:
public void onMediaUploaded(MediaStore.OnMediaUploaded event) { if (isFinishing()) return; if (event.media == null) { AppLog.w(AppLog.T.MEDIA, "Media event not recognized: " + event.media); return; } if (event.isError()) { onUploadError(event.media, event.error); } else if (event.canceled) { onUploadCanceled(event.media); } else if (event.completed) { onUploadSuccess(event.media); } else { AppLog.w(AppLog.T.MEDIA, "EDITPOSTACTIVITY: " + event.media.getId() + " - " + event.progress); onUploadProgress(event.media, event.progress); } }

Target:
public void onMediaUploaded(MediaStore.OnMediaUploaded event) { if (isFinishing()) return; if (event.media == null) { AppLog.w(AppLog.T.MEDIA, "Media event not recognized: " + event.media); return; } if (event.isError()) { onUploadError(event.media, event.error); } else if (event.canceled) { onUploadCanceled(event.media); } else if (event.completed) { onUploadSuccess(event.media); } else { onUploadProgress(event.media, event.progress); } }
Source:
private boolean filterInvalid(Position position) { if (filterInvalid) { return !position.getValid() || position.getLatitude() > 90 || position.getLongitude() > 180 || position.getLatitude() < -90 || position.getLongitude() < -180; } return false; }

Target:
private boolean filterInvalid(Position position) { return filterInvalid && (!position.getValid() || position.getLatitude() > 90 || position.getLongitude() > 180 || position.getLatitude() < -90 || position.getLongitude() < -180); }
Source:
synchronized public void addPartition(String partitionIdStr) { if (partitionIdMap.containsKey(partitionIdStr)) { assignedPartitionIds.add(partitionIdMap.get(partitionIdStr)); logger.info("Added partition to current VCR: ", partitionIdStr); } else { logger.trace("Partition not in clusterMap on add.", partitionIdStr); metrics.partitionIdNotInClusterMapOnAdd.inc(); } }

Target:
public void addPartition(String partitionIdStr) { PartitionId partitionId = partitionIdMap.get(partitionIdStr); if (partitionId != null) { if (assignedPartitionIds.add(partitionId)) { for (VirtualReplicatorClusterListener listener : listeners) { listener.onPartitionAdded(partitionId); } logger.info("Partition is added to current VCR: {}", partitionIdStr, vcrInstanceName); } else { logger.info("Partition exists on current VCR: {}", partitionIdStr, vcrInstanceName); } } else { logger.error("Partition not in clusterMap on add.", partitionIdStr); metrics.partitionIdNotInClusterMapOnAdd.inc(); } }
Source:
public void testFlush() { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); final SettableApiFuture<Void> future2 = SettableApiFuture.create(); when(callable.futureCall(rowMutation)).thenReturn(future).thenReturn(future2); ApiFuture<Void> result1 = bulkMutationClient.add(rowMutation); ApiFuture<Void> result2 = bulkMutationClient.add(rowMutation); Assert.assertFalse(result1.isDone()); Assert.assertFalse(result2.isDone()); scheduler.schedule(new Runnable() { @Override public void run() { future.set(null); future2.set(null); } }, 50, TimeUnit.MILLISECONDS); bulkMutationClient.flush(); Assert.assertTrue(result1.isDone()); Assert.assertTrue(result2.isDone()); verify(callable, times(2)).futureCall(rowMutation); }

Target:
public void testFlush() throws Exception { final SettableApiFuture<Void> future2 = SettableApiFuture.create(); when(callable.futureCall(rowMutation)).thenReturn(future).thenReturn(future2); ApiFuture<Void> result1 = bulkMutationClient.add(rowMutation); ApiFuture<Void> result2 = bulkMutationClient.add(rowMutation); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); try { executor.schedule(new Runnable() { @Override public void run() { future.set(null); future2.set(null); } }, 50, TimeUnit.MILLISECONDS); bulkMutationClient.flush(); assertTrue(result1.isDone()); assertTrue(result2.isDone()); } finally { executor.shutdown(); executor.awaitTermination(100, TimeUnit.MILLISECONDS); } verify(callable, times(2)).futureCall(rowMutation); }
Source:
public MeterResponseData dequeue(final String correlationUid, final Class<?> expectedClassType) throws FunctionalException { try { final MeterResponseData meterResponseData = this.meterResponseDataRepository .findSingleResultByCorrelationUid(correlationUid); if (meterResponseData == null) { throw new FunctionalException(FunctionalExceptionType.UNKNOWN_CORRELATION_UID, ComponentType.WS_SMART_METERING); } if (!expectedClassType.isInstance(meterResponseData.getMessageData())) { LOGGER.warn("Incorrect type of response data: for correlation UID: {}", meterResponseData.getClass() .getName(), meterResponseData.getCorrelationUid()); return null; } this.remove(meterResponseData); return meterResponseData; } catch (final FunctionalException e) { if (e.getExceptionType() == FunctionalExceptionType.UNKNOWN_CORRELATION_UID) { LOGGER.warn("No response data for correlation UID {}", correlationUid); } throw e; } }

Target:
public MeterResponseData dequeue(final String correlationUid, final Class<?> expectedClassType) throws FunctionalException { final MeterResponseData meterResponseData = this.meterResponseDataRepository .findSingleResultByCorrelationUid(correlationUid); if (meterResponseData == null) { LOGGER.warn("No response data for correlation UID {}", correlationUid); throw new FunctionalException(FunctionalExceptionType.UNKNOWN_CORRELATION_UID, ComponentType.WS_SMART_METERING); } if (!expectedClassType.isInstance(meterResponseData.getMessageData())) { final String warningResultClassType = meterResponseData.getMessageData() == null ? "NULL" : meterResponseData.getMessageData().getClass().getName(); LOGGER.warn("Incorrect type of response data: for correlation UID: {}", warningResultClassType, meterResponseData.getCorrelationUid()); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_SMART_METERING); } this.remove(meterResponseData); return meterResponseData; }
Source:
void subscribeNext() { if (requested > 0) { Object o = queue.poll(); if (nl.isCompleted(o)) { child.onCompleted(); } else if (o != null) { Observable<? extends T> obs = nl.getValue(o); currentSubscriber = new ConcatInnerSubscriber<T>(this, child); currentSubscriber.requestMore(requested); current.set(currentSubscriber); obs.unsafeSubscribe(currentSubscriber); } } else { Object o = queue.peek(); if (nl.isCompleted(o)) { child.onCompleted(); } } }

Target:
void subscribeNext() { if (requested > 0) { Object o = queue.poll(); if (nl.isCompleted(o)) { child.onCompleted(); } else if (o != null) { Observable<? extends T> obs = nl.getValue(o); currentSubscriber = new ConcatInnerSubscriber<T>(this, child, arbiter); current.set(currentSubscriber); obs.unsafeSubscribe(currentSubscriber); } } else { Object o = queue.peek(); if (nl.isCompleted(o)) { child.onCompleted(); } } }
Source:
public Deploy toServerGroups(String... serverGroups) { if (this.serverGroups == null && serverGroups != null) { this.serverGroups = new ArrayList<String>(); } if (serverGroups != null) { this.serverGroups.addAll(Arrays.asList(serverGroups)); } return build(); }

Target:
public Builder toServerGroups(String... serverGroups) { if (this.serverGroups == null && serverGroups != null) { this.serverGroups = new ArrayList<String>(); } if (serverGroups != null) { this.serverGroups.addAll(Arrays.asList(serverGroups)); } return this; }
Source:
public Instance putAll(final Map<String, String> values) { for (final Map.Entry<String, String> entry : values.entrySet()) { put(entry.getKey(), entry.getValue()); } return this; }

Target:
public Instance putAll(final Map<String, String> values) { final Map<String, String> currentValues = ThreadContext.getContext(); ThreadContext.putAll(values); for (final String key : values.keySet()) { if (!originalValues.containsKey(key)) { originalValues.put(key, currentValues.get(key)); } } return this; }
Source:
public Mono<ServiceMessage> requestOne( ServiceMessage request, Type responseType, Address address) { return Mono.defer( () -> { requireNonNull(address, "requestOne address parameter is required and must not be null"); requireNonNull( transport, "transport is required did you forget to provide transport?"); return transport .create(address) .requestResponse(request, responseType) .map(this::throwIfError); }); }

Target:
public Mono<ServiceMessage> requestOne( ServiceMessage request, Type responseType, Address address) { return Mono.defer( () -> { requireNonNull(address, "requestOne address parameter is required and must not be null"); requireNonNull(transport, "transport is required and must not be null"); return transport .create(address) .requestResponse(request, responseType) .map(this::throwIfError); }); }
Source:
private PluginInfo savePluginInfo(PluginInfo pluginInfo) { validate(pluginInfo); PluginInfo oldPluginInfo; try { oldPluginInfo = findById(pluginInfo.getId()); } catch (NotFoundException e) { oldPluginInfo = null; } PluginInfoDelta delta = new PluginInfoDelta(pluginInfo, oldPluginInfo); delta.addedReleases.forEach( release -> postEvent(PluginEventType.PUBLISHED, pluginInfo, release)); String newVersion = Optional.ofNullable(delta.newPreferredRelease) .map(PluginInfo.Release::getVersion) .orElse(null); String oldVersion = Optional.ofNullable(delta.oldPreferredRelease) .map(PluginInfo.Release::getVersion) .orElse(null); if ((newVersion == null && oldVersion != null || (newVersion != null && !newVersion.equals(oldVersion)))) { postEvent(PluginEventType.PREFERRED_VERSION_UPDATED, pluginInfo, delta.newPreferredRelease); } if (oldPluginInfo == null) { repository.create(pluginInfo.getId(), pluginInfo); } else { repository.update(pluginInfo.getId(), pluginInfo); } return pluginInfo; }

Target:
private PluginInfo savePluginInfo(PluginInfo pluginInfo) { validate(pluginInfo); PluginInfo oldPluginInfo; try { oldPluginInfo = findById(pluginInfo.getId()); } catch (NotFoundException e) { oldPluginInfo = null; } if (oldPluginInfo == null) { repository.create(pluginInfo.getId(), pluginInfo); } else { repository.update(pluginInfo.getId(), pluginInfo); } PluginInfoDelta delta = new PluginInfoDelta(pluginInfo, oldPluginInfo); delta.addedReleases.forEach( release -> postEvent(PluginEventType.PUBLISHED, pluginInfo, release)); String newVersion = Optional.ofNullable(delta.newPreferredRelease) .map(PluginInfo.Release::getVersion) .orElse(null); String oldVersion = Optional.ofNullable(delta.oldPreferredRelease) .map(PluginInfo.Release::getVersion) .orElse(null); if ((newVersion == null && oldVersion != null || (newVersion != null && !newVersion.equals(oldVersion)))) { postEvent(PluginEventType.PREFERRED_VERSION_UPDATED, pluginInfo, delta.newPreferredRelease); } return pluginInfo; }
Source:
public void transform(StructuredRecord structuredRecord, Emitter<KeyValue<Text, Text>> emitter) throws Exception { Type schemaType = new TypeToken<Schema>() { }.getType(); if (flag) { batchConfig.verifySolrConfiguration(); flag = false; } batchConfig.validateKeyField(structuredRecord.getSchema()); batchConfig.validateInputFieldsDataType(structuredRecord.getSchema()); if (structuredRecord.get(batchConfig.getKeyField()) == null) { return; } emitter.emit(new KeyValue<Text, Text>(new Text(GSON.toJson(structuredRecord.getSchema(), schemaType)), new Text(StructuredRecordStringConverter.toJsonString(structuredRecord)))); }

Target:
public void transform(StructuredRecord structuredRecord, Emitter<KeyValue<Text, Text>> emitter) throws Exception { batchConfig.validateKeyField(structuredRecord.getSchema()); batchConfig.validateInputFieldsDataType(structuredRecord.getSchema()); if (structuredRecord.get(batchConfig.getKeyField()) == null) { return; } emitter.emit(new KeyValue<Text, Text>(new Text(GSON.toJson(structuredRecord.getSchema(), SCHEMA_TYPE)), new Text(StructuredRecordStringConverter.toJsonString(structuredRecord)))); }
Source:
protected void initDebug() { Boolean debugParam = getInitParameter("debug", Boolean.class); setDebug((debugParam == null) ? false : debugParam); }

Target:
protected void initDebug() { setDebug(Optional.ofNullable(getInitParameter("debug", Boolean.class)).orElse(false)); }
Source:
public CompletionStage<Void> deleteBatchFromAllNonTxStores(Iterable<Object> keys, Predicate<? super StoreConfiguration> predicate, long flags) { Flowable<NonBlockingStore.SegmentedPublisher<Object>> flowable = Flowable.fromIterable(keys) .groupBy(keyPartitioner::getSegment) .map(SegmentPublisherWrapper::new); return Completable.using( this::acquireReadLock, ignore -> { checkStoreAvailability(); if (trace) { log.trace("Deleting batch of entries from stores"); } return Flowable.fromIterable(stores.entrySet()) .filter(entry -> !entry.getValue().characteristics.contains(Characteristic.READ_ONLY) && predicate.test(entry.getValue().config)) .flatMapCompletable(entry -> Completable.fromCompletionStage( entry.getKey().bulkDelete(segmentCount, flowable))); }, this::releaseReadLock ).toCompletionStage(null); }

Target:
public CompletionStage<Void> deleteBatchFromAllNonTxStores(Iterable<Object> keys, Predicate<? super StoreConfiguration> predicate, long flags) { Flowable<NonBlockingStore.SegmentedPublisher<Object>> flowable = Flowable.fromIterable(keys) .groupBy(keyPartitioner::getSegment) .map(SegmentPublisherWrapper::new); return Completable.using( this::acquireReadLock, ignore -> { checkStoreAvailability(); if (trace) { log.trace("Deleting batch of entries from stores"); } return Flowable.fromIterable(stores) .filter(storeStatus -> shouldWrite(storeStatus, predicate)) .flatMapCompletable(storeStatus -> Completable.fromCompletionStage( storeStatus.store.bulkDelete(segmentCount, flowable))); }, this::releaseReadLock ).toCompletionStage(null); }
Source:
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) { String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation()); String name = group.getName(); String id = Iterables.get(client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, name), 0).getId(); client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, id, ipPermission); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); }

Target:
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) { String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation()); String name = group.getName(); String id = groupNameToId.apply(new RegionAndName(region, name).slashEncode()); client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, id, ipPermission); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); }