auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); ((GridData) this.getText().getLayoutData()).heightHint = 100; createMessageArea(composite); if (labelsInfo != null) { createMiddleRadioSection(composite); } Point size = parent.getParent().computeSize(650, SWT.DEFAULT); parent.getShell().setMinimumSize(size); return parent; }

Target:
protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); ((GridData) this.getText().getLayoutData()).heightHint = 100; ((GridData) this.getText().getLayoutData()).grabExcessVerticalSpace = true; ((GridData) this.getText().getLayoutData()).verticalAlignment = SWT.FILL; createMessageArea(composite); if (labelsInfo != null) { createMiddleRadioSection(composite); } parent.getShell().addControlListener(new ControlListener() { @Override public void controlResized(ControlEvent e) { Point size = parent.getShell().computeSize(WIDTH, SWT.DEFAULT); parent.getShell().setMinimumSize(size); parent.getShell().setSize(size); if (hasDrafts(fRevisionInfo)) { scrolledDraftArea.layout(); } parent.getShell().removeControlListener(this); } @Override public void controlMoved(ControlEvent e) { } }); return parent; }
Source:
private void addInformationPanelAboutDisable() { if (_descriptor instanceof Allowable && !((Allowable) _descriptor).isAllowed()) { final ImageIcon icon = imageManager.getImageIcon(IconUtils.STATUS_INFO, IconUtils.ICON_SIZE_TASK_PANE); DCPanel panel = new DCPanel(); DCHtmlBox dcHtmlBox = new DCHtmlBox( "<p>This service is not currently available for your DataCloud account.</p>" + "<p> Please contact 'support@datacleaner.org' to obtain access.</p>"); panel.add(dcHtmlBox); addTaskPane(icon, "Component is disabled", panel, true); } }

Target:
private void addInformationPanelAboutDisable() { if (_descriptor instanceof Allowable && !((Allowable) _descriptor).isAllowed()) { final ImageIcon icon = imageManager.getImageIcon(IconUtils.STATUS_INFO, IconUtils.ICON_SIZE_TASK_PANE); DCPanel panel = new DCPanel(); DCHtmlBox dcHtmlBox = new DCHtmlBox( "<p>This service is not currently available for your DataCloud account.</p>" + "<p> More information on your " + "<a href='" + RemoteDescriptorProvider.DATACLEANER_BASE_URL + "/userprofile" + "'>DataCleaner profile</a>" + ".</p>"); panel.add(dcHtmlBox); addTaskPane(icon, "Component is disabled", panel, true); } }
Source:
public void start() { if (properties == null) { return; } ExecutorService executorService = Executors.newFixedThreadPool(properties.getSubscriptions().size()); List<PubsubSubscriber> subscribers = new ArrayList<>(); properties .getSubscriptions() .forEach( (AmazonPubsubProperties.AmazonPubsubSubscription subscription) -> { log.info("Bootstrapping SQS for SNS topic: {}", subscription.getTopicARN()); ARN queueArn = new ARN(subscription.getQueueARN()); ARN topicArn = new ARN(subscription.getTopicARN()); SQSSubscriber worker = new SQSSubscriber( subscription, pubsubMessageHandlerFactory.create(subscription), AmazonSNSClientBuilder.standard() .withCredentials(awsCredentialsProvider) .withClientConfiguration(new ClientConfiguration()) .withRegion(topicArn.getRegion()) .build(), AmazonSQSClientBuilder.standard() .withCredentials(awsCredentialsProvider) .withClientConfiguration(new ClientConfiguration()) .withRegion(queueArn.getRegion()) .build(), enabled::get, registry); try { executorService.submit(worker); subscribers.add(worker); log.debug( "Created worker for subscription: {}", worker.getWorkerName(), subscription.getName()); } catch (RejectedExecutionException e) { log.error("Could not start {}", worker.getWorkerName(), e); } }); pubsubSubscribers.putAll(subscribers); }

Target:
public void start() { Preconditions.checkNotNull( properties, "Can't initialize SQSSubscriberProvider with null properties"); ExecutorService executorService = Executors.newFixedThreadPool(properties.getSubscriptions().size()); List<PubsubSubscriber> subscribers = new ArrayList<>(); properties .getSubscriptions() .forEach( (AmazonPubsubProperties.AmazonPubsubSubscription subscription) -> { log.info("Bootstrapping SQS for SNS topic: {}", subscription.getTopicARN()); ARN queueArn = new ARN(subscription.getQueueARN()); ARN topicArn = new ARN(subscription.getTopicARN()); SQSSubscriber worker = new SQSSubscriber( subscription, pubsubMessageHandlerFactory.create(subscription), messageAcknowledger, AmazonSNSClientBuilder.standard() .withCredentials(awsCredentialsProvider) .withClientConfiguration(new ClientConfiguration()) .withRegion(topicArn.getRegion()) .build(), AmazonSQSClientBuilder.standard() .withCredentials(awsCredentialsProvider) .withClientConfiguration(new ClientConfiguration()) .withRegion(queueArn.getRegion()) .build(), PubSubUtils.getEnabledSupplier(dynamicConfig, subscription, eurekaStatus), registry); try { executorService.submit(worker); subscribers.add(worker); log.debug( "Created worker for subscription: {}", worker.getWorkerName(), subscription.getName()); } catch (RejectedExecutionException e) { log.error("Could not start {}", worker.getWorkerName(), e); } }); pubsubSubscribers.putAll(subscribers); }
Source:
public void shouldNotifyEventWhenUpdateAnnotation() { Annotation annotation = createAnnotation(annotatedDocumentModel); try (CapturingEventListener listener = new CapturingEventListener(COMMENT_UPDATED)) { annotation.setText("I update the annotation"); annotationService.updateAnnotation(session, annotation.getId(), annotation); DocumentModel annotationDocumentModel = session.getDocument(new IdRef(annotation.getId())); DocumentModel annotationParentDocumentModel = session.getDocument( new IdRef((String) annotationDocumentModel.getPropertyValue(COMMENT_PARENT_ID))); transactionalFeature.nextTransaction(); Event expectedEvent = listener.streamCapturedEvents() .findFirst() .orElseThrow(() -> new AssertionError("Event wasn't fired")); checkDocumentEventContext(expectedEvent, annotationDocumentModel, annotationParentDocumentModel, annotatedDocumentModel); } }

Target:
public void shouldNotifyEventWhenUpdateAnnotation() { Annotation annotation = createAnnotation(annotatedDocumentModel); try (CapturingEventListener listener = new CapturingEventListener(COMMENT_UPDATED)) { annotation.setText("I update the annotation"); annotationService.updateAnnotation(session, annotation.getId(), annotation); transactionalFeature.nextTransaction(); DocumentModel annotationDocumentModel = session.getDocument(new IdRef(annotation.getId())); DocumentModel annotationParentDocumentModel = session.getDocument( new IdRef((String) annotationDocumentModel.getPropertyValue(COMMENT_PARENT_ID))); Event expectedEvent = listener.streamCapturedEvents() .findFirst() .orElseThrow(() -> new AssertionError("Event wasn't fired")); checkDocumentEventContext(expectedEvent, annotationDocumentModel, annotationParentDocumentModel, annotatedDocumentModel); } }
Source:
private void setSenderCopyMessage(ActivityCommentMessage senderCopyMessage) { if (this.senderCopyMessageList == null) { this.senderCopyMessageList = Arrays.asList(senderCopyMessage); } else { this.senderCopyMessageList.set(0, senderCopyMessage); } }

Target:
private void setSenderCopyMessage(ActivityCommentMessage senderCopyMessage) { this.senderCopyMessageHolder = setToHolder(this.senderCopyMessageHolder, senderCopyMessage); }
Source:
public InputStream readFrom(long offset) throws IOException { final GetObjectRequest request = new GetObjectRequest(object.getBucket(), object.getPath()); request.setRange(offset); try { final S3Object s3Object = s3Client.getObject(request); if (s3Object == null) { throw new ISE( "Failed to get an s3 object for bucket[%s], key[%s], and start[%d]", object.getBucket(), object.getPath(), offset ); } return s3Object.getObjectContent(); } catch (AmazonS3Exception e) { throw new IOException(e); } }

Target:
protected InputStream readFrom(long offset) throws IOException { final GetObjectRequest request = new GetObjectRequest(object.getBucket(), object.getPath()); request.setRange(offset); try { final S3Object s3Object = s3Client.getObject(request); if (s3Object == null) { throw new ISE( "Failed to get an s3 object for bucket[%s], key[%s], and start[%d]", object.getBucket(), object.getPath(), offset ); } return s3Object.getObjectContent(); } catch (AmazonS3Exception e) { throw new IOException(e); } }
Source:
private WebElement getInviteInstructorLink(int instrNum) { String id = "instrRemindLink" + instrNum; return browser.driver.findElement(By.id(id)); }

Target:
private WebElement getInviteInstructorLink(int instrNum) { return browser.driver.findElement(By.id("instrRemindLink" + instrNum)); }
Source:
public Map<String, List<String>> getRoutingData() throws InvalidRoutingDataException { Map<String, List<String>> routingData = new HashMap<>(); List<String> children; try { children = _zkClient.getChildren(MetadataStoreRoutingConstants.ROUTING_DATA_PATH); } catch (ZkNoNodeException e) { throw new InvalidRoutingDataException( "Routing data directory ZNode " + MetadataStoreRoutingConstants.ROUTING_DATA_PATH + " does not exist. Routing ZooKeeper address: " + _zkAddress); } for (String child : children) { ZNRecord record = _zkClient.readData(MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + child); List<String> shardingKeys = record.getListField(MetadataStoreRoutingConstants.ZNRECORD_LIST_FIELD_KEY); if (shardingKeys != null && !shardingKeys.isEmpty()) { routingData.put(child, shardingKeys); } } return routingData; }

Target:
public Map<String, List<String>> getRoutingData() throws InvalidRoutingDataException { Map<String, List<String>> routingData = new HashMap<>(); List<String> allRealmAddresses; try { allRealmAddresses = _zkClient.getChildren(MetadataStoreRoutingConstants.ROUTING_DATA_PATH); } catch (ZkNoNodeException e) { throw new InvalidRoutingDataException( "Routing data directory ZNode " + MetadataStoreRoutingConstants.ROUTING_DATA_PATH + " does not exist. Routing ZooKeeper address: " + _zkAddress); } for (String realmAddress : allRealmAddresses) { ZNRecord record = _zkClient.readData(MetadataStoreRoutingConstants.ROUTING_DATA_PATH + "/" + realmAddress); List<String> shardingKeys = record.getListField(MetadataStoreRoutingConstants.ZNRECORD_LIST_FIELD_KEY); if (shardingKeys != null) { routingData.put(realmAddress, shardingKeys); } } return routingData; }
Source:
private void processProbe() { verify(probe != null); PagesSpatialIndex pagesSpatialIndex = getDone(pagesSpatialIndexFuture); DriverYieldSignal yieldSignal = operatorContext.getDriverContext().getYieldSignal(); while (probePosition < probe.getPositionCount()) { if (joinPositions == null) { joinPositions = pagesSpatialIndex.findJoinPositions(probePosition, probe, probeGeometryChannel); localUserMemoryContext.setBytes(sizeOf(joinPositions)); nextJoinPositionIndex = 0; matchFound = false; if (yieldSignal.isSet()) { return; } } while (nextJoinPositionIndex < joinPositions.length) { if (pageBuilder.isFull()) { return; } int joinPosition = joinPositions[nextJoinPositionIndex]; if (pagesSpatialIndex.isJoinPositionEligible(joinPosition, probePosition, probe)) { pageBuilder.declarePosition(); appendProbe(); pagesSpatialIndex.appendTo(joinPosition, pageBuilder, probeOutputChannels.size()); matchFound = true; } nextJoinPositionIndex++; if (yieldSignal.isSet()) { return; } } if (!matchFound && joinType == LEFT) { if (pageBuilder.isFull()) { return; } pageBuilder.declarePosition(); appendProbe(); for (int i = 0; i < pagesSpatialIndexFactory.getOutputTypes().size(); i++) { pageBuilder.getBlockBuilder(probeOutputChannels.size() + i).appendNull(); } } joinPositions = null; localUserMemoryContext.setBytes(0); probePosition++; } this.probe = null; this.probePosition = 0; }

Target:
private void processProbe() { verify(probe != null); PagesSpatialIndex pagesSpatialIndex = getDone(pagesSpatialIndexFuture); DriverYieldSignal yieldSignal = operatorContext.getDriverContext().getYieldSignal(); while (probePosition < probe.getPositionCount()) { if (joinPositions == null) { joinPositions = pagesSpatialIndex.findJoinPositions(probePosition, probe, probeGeometryChannel); localUserMemoryContext.setBytes(sizeOf(joinPositions)); nextJoinPositionIndex = 0; matchFound = false; if (yieldSignal.isSet()) { return; } } while (nextJoinPositionIndex < joinPositions.length) { if (pageBuilder.isFull()) { return; } int joinPosition = joinPositions[nextJoinPositionIndex]; if (pagesSpatialIndex.isJoinPositionEligible(joinPosition, probePosition, probe)) { pageBuilder.declarePosition(); appendProbe(); pagesSpatialIndex.appendTo(joinPosition, pageBuilder, probeOutputChannels.size()); matchFound = true; } nextJoinPositionIndex++; if (yieldSignal.isSet()) { return; } } if (!matchFound && joinType == LEFT) { if (pageBuilder.isFull()) { return; } pageBuilder.declarePosition(); appendProbe(); int buildColumnCount = pagesSpatialIndexFactory.getOutputTypes().size(); for (int i = 0; i < buildColumnCount; i++) { pageBuilder.getBlockBuilder(probeOutputChannels.size() + i).appendNull(); } } joinPositions = null; localUserMemoryContext.setBytes(0); probePosition++; } this.probe = null; this.probePosition = 0; }
Source:
protected void executeCommand() { Guid volumeId = getGlusterVolumeId(); GlusterVolumeSnapshotSchedule fetchedSchedule = getGlusterVolumeSnapshotScheduleDao().getByVolumeId(volumeId); String jobId = fetchedSchedule.getJobId(); getDbSchedulUtil().deleteJob(jobId); GlusterVolumeSnapshotSchedule schedule = getSchedule(); if (schedule.getRecurrence() != null) { Time originalExecutionTime = schedule.getExecutionTime(); try { String newJobId = scheduleJob(); if (newJobId != null) { setSucceeded(true); schedule.setJobId(newJobId); schedule.setExecutionTime(originalExecutionTime); getGlusterVolumeSnapshotScheduleDao().updateScheduleByVolumeId(volumeId, schedule); } else { setSucceeded(false); } } catch (Exception ex) { setSucceeded(false); handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESCHEDULE_FAILED, ex.getMessage()); } } else { getGlusterVolumeSnapshotScheduleDao().removeByVolumeId(volumeId); setSucceeded(true); } }

Target:
protected void executeCommand() { Guid volumeId = getGlusterVolumeId(); GlusterVolumeSnapshotSchedule fetchedSchedule = getGlusterVolumeSnapshotScheduleDao().getByVolumeId(volumeId); String jobId = fetchedSchedule.getJobId(); getDbSchedulUtil().deleteJob(jobId); GlusterVolumeSnapshotSchedule schedule = getSchedule(); if (schedule.getRecurrence() != null) { Time originalExecutionTime = schedule.getExecutionTime(); try { String newJobId = scheduleJob(); setSucceeded(true); schedule.setJobId(newJobId); schedule.setExecutionTime(originalExecutionTime); getGlusterVolumeSnapshotScheduleDao().updateScheduleByVolumeId(volumeId, schedule); } catch (Exception ex) { setSucceeded(false); handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESCHEDULE_FAILED, ex.getMessage()); } } else { getGlusterVolumeSnapshotScheduleDao().removeByVolumeId(volumeId); setSucceeded(true); } }
Source:
private void addItemCollectionOnTarget(Collection<T> items, T target, String targetItemNotFoundErrorMessage, SerializableBiFunction<Integer, Boolean, Integer> insertItemsIndexProvider) { Objects.requireNonNull(items, NULL_COLLECTION_ERROR_MESSAGE); if (items.isEmpty()) { return; } final ListDataProvider<T> dataProvider = getDataProvider(); final Collection<T> backendItems = dataProvider.getItems(); if (!(backendItems instanceof List)) { throw new IllegalArgumentException( String.format(COLLECTION_TYPE_ERROR_MESSAGE_PATTERN, backendItems.getClass().getSimpleName())); } if (!contains(target)) { throw new IllegalArgumentException(targetItemNotFoundErrorMessage); } final List<T> itemList = (List<T>) backendItems; final AtomicBoolean containsTargetItem = new AtomicBoolean(false); items.forEach(item -> { if (equals(target, item)) { containsTargetItem.set(true); } else { removeItemIfPresent(item, dataProvider); } }); int targetItemIndex = itemList.indexOf(target); if (containsTargetItem.get()) { itemList.remove(targetItemIndex); } final int indexToInsertItems = insertItemsIndexProvider .apply(targetItemIndex, containsTargetItem.get()); itemList.addAll(indexToInsertItems, items); dataProvider.refreshAll(); }

Target:
private void addItemCollectionOnTarget(Collection<T> items, T target, String targetItemNotFoundErrorMessage, SerializableBiFunction<Integer, Boolean, Integer> insertItemsIndexProvider) { Objects.requireNonNull(items, NULL_COLLECTION_ERROR_MESSAGE); if (items.isEmpty()) { return; } final ListDataProvider<T> dataProvider = getDataProvider(); final Collection<T> backendItems = dataProvider.getItems(); if (!(backendItems instanceof List)) { throw new IllegalArgumentException( String.format(COLLECTION_TYPE_ERROR_MESSAGE_PATTERN, backendItems.getClass().getSimpleName())); } if (!contains(target)) { throw new IllegalArgumentException(targetItemNotFoundErrorMessage); } final List<T> itemList = (List<T>) backendItems; final AtomicBoolean containsTargetItem = new AtomicBoolean(false); items.forEach(item -> { if (equals(target, item)) { containsTargetItem.set(true); } else { removeItemIfPresent(item, dataProvider); } }); int targetItemIndex = getItemIndex(target, itemList.stream()); if (containsTargetItem.get()) { itemList.remove(targetItemIndex); } final int indexToInsertItems = insertItemsIndexProvider .apply(targetItemIndex, containsTargetItem.get()); itemList.addAll(indexToInsertItems, items); dataProvider.refreshAll(); }
Source:
public String toString() { return "ArrayTimeRangeCondition: size=" + fTimeArray.length + ", min=" + min() + ", max =" + max(); }

Target:
public String toString() { return "ArrayTimeRangeCondition[" + fTimeArray.length + "](" + min() + '\u2025' + max() + ')'; }
Source:
public Page<ModuleMetadata> findAllByContainerId(Pageable pageable, String containerId) { Assert.hasLength(containerId, "containerId is required"); return pagingUtility.getPagedData(pageable, findAllByContainerId(containerId)); }

Target:
public Page<ModuleMetadata> findAllByContainerId(Pageable pageable, String containerId) { Assert.hasText(containerId, "containerId is required"); return pagingUtility.getPagedData(pageable, findAllByContainerId(containerId)); }
Source:
private boolean shouldBeLoggedThroughPopup(Throwable exception) { boolean value = false; value = exception instanceof LockedInstanceException || exception instanceof SecurityException; if (value) { value = exception.getMessage() != null && exception.getMessage() != StringUtil.EMPTY_STRING; } return value; }

Target:
private boolean shouldBeLoggedThroughPopup(Throwable exception) { boolean shouldBeLogged = false; shouldBeLogged = exception instanceof LockedInstanceException || exception instanceof SecurityException; if (shouldBeLogged) { String message = getErrorMessage(exception); shouldBeLogged = message != null && !message.isEmpty(); } return shouldBeLogged; }
Source:
public static FileSystem create(FileSystemContext context) { if (LOG.isDebugEnabled() && !CONF_LOGGED.getAndSet(true)) { AlluxioConfiguration conf = context.getClusterConf(); List<PropertyKey> keys = new ArrayList<>(conf.keySet()); keys.sort(Comparator.comparing(PropertyKey::getName)); for (PropertyKey key : keys) { String value = conf.getOrDefault(key, null); Source source = conf.getSource(key); LOG.debug("{}={} ({})", key.getName(), value, source); } } Class fsClass = context.getClusterConf().getClass(PropertyKey.USER_FILESYSTEM_CLASS); Class[] ctorArgClasses = new Class[] {FileSystemContext.class}; Object[] ctorArgs = new Object[] {context}; FileSystem fs = (FileSystem) CommonUtils.createNewClassInstance(fsClass, ctorArgClasses, ctorArgs); boolean dataCache = context.getClusterConf().getBoolean(PropertyKey.USER_LOCAL_CACHE_ENABLED); boolean metadataCache = context.getClusterConf().getBoolean(PropertyKey.USER_METADATA_CACHE_ENABLED); if (dataCache) { return metadataCache ? new MetadataCachingLocalCacheFileSystem(fs, context) : new LocalCacheFileSystem(fs); } else { return metadataCache ? new MetadataCachingBaseFileSystem(fs, context) : fs; } }

Target:
public static FileSystem create(FileSystemContext context) { AlluxioConfiguration conf = context.getClusterConf(); if (LOG.isDebugEnabled() && !CONF_LOGGED.getAndSet(true)) { List<PropertyKey> keys = new ArrayList<>(conf.keySet()); keys.sort(Comparator.comparing(PropertyKey::getName)); for (PropertyKey key : keys) { String value = conf.getOrDefault(key, null); Source source = conf.getSource(key); LOG.debug("{}={} ({})", key.getName(), value, source); } } FileSystem fs = conf.getBoolean(PropertyKey.USER_METADATA_CACHE_ENABLED) ? new MetadataCachingBaseFileSystem(context) : new BaseFileSystem(context); if (conf.getBoolean(PropertyKey.USER_CLIENT_CACHE_ENABLED)) { return new LocalCacheFileSystem(fs, conf); } return fs; }
Source:
private static void run(String[] args) throws Exception { if (args.length < 2 || args.length > 4) { throw new ToolsException( " usage: java com.sforce.ws.tools.wsdlc -nc <wsdl-file> <jar-file> <dest-dir>"); } boolean compile = true; String destJarFilename = null; String wsdlUrl = null; String destDir = null; for (String arg : args) { if (arg.equals("-nc")) { compile = false; } else if (wsdlUrl == null) { wsdlUrl = arg; } else if (destJarFilename == null) { destJarFilename = arg; } else if (destDir == null) { destDir = arg; } else { throw new ToolsException(" usage: java com.sforce.ws.tools.wsdlc -nc <wsdl-file> <jar-file> <dest-dir>"); } } String packagePrefix = System.getProperty(PACKAGE_PREFIX); boolean standAlone = Boolean.parseBoolean(System.getProperty(STANDALONE_JAR, "false")); boolean javaTime = Boolean.parseBoolean(System.getProperty(wsdlc.JAVA_TIME, "false")); STGroupDir stGroupDir = new STGroupDir(TEMPLATE_DIR, '$', '$'); run(wsdlUrl, destJarFilename, packagePrefix, javaTime, standAlone, stGroupDir, destDir, compile); }

Target:
static void run(String[] args) throws Exception { if (args.length < 2 || args.length > 4) { throw new ToolsException( " usage: java com.sforce.ws.tools.wsdlc -nc <wsdl-file> <jar-file> <dest-dir>"); } boolean compile = true; String destJarFilename = null; String wsdlUrl = null; String destDir = null; for (String arg : args) { if (arg.equals("-nc")) { compile = false; } else if (wsdlUrl == null) { wsdlUrl = arg; } else if (destJarFilename == null) { destJarFilename = arg; } else if (destDir == null) { destDir = arg; } else { throw new ToolsException(" usage: java com.sforce.ws.tools.wsdlc -nc <wsdl-file> <jar-file> <dest-dir>"); } } String packagePrefix = System.getProperty(PACKAGE_PREFIX); boolean standAlone = Boolean.parseBoolean(System.getProperty(STANDALONE_JAR, "false")); boolean javaTime = Boolean.parseBoolean(System.getProperty(wsdlc.JAVA_TIME, "false")); STGroupDir stGroupDir = new STGroupDir(TEMPLATE_DIR, '$', '$'); run(wsdlUrl, destJarFilename, packagePrefix, javaTime, standAlone, stGroupDir, destDir, compile); }
Source:
CloudBlobStore(PartitionId partitionId, CloudConfig cloudConfig, CloudDestination cloudDestination) { this.partitionId = Objects.requireNonNull(partitionId, "partitionId is required"); this.cloudConfig = Objects.requireNonNull(cloudConfig, "cloudConfig is required"); this.cloudDestination = Objects.requireNonNull(cloudDestination, "cloudDestination is required"); minTtlMillis = cloudConfig.vcrMinTtlDays * TimeUnit.DAYS.toMillis(1); }

Target:
CloudBlobStore(PartitionId partitionId, CloudConfig cloudConfig, CloudDestination cloudDestination) { this.partitionId = Objects.requireNonNull(partitionId, "partitionId is required"); this.cloudConfig = Objects.requireNonNull(cloudConfig, "cloudConfig is required"); this.cloudDestination = Objects.requireNonNull(cloudDestination, "cloudDestination is required"); minTtlMillis = TimeUnit.DAYS.toMillis(cloudConfig.vcrMinTtlDays); }
Source:
public Path(String path) { int index = path.indexOf('?'); int semi = path.indexOf(';'); if ((semi != -1)) { if (index != -1) { path = path.substring(0, semi) + path.substring(index, path.length()); } else { path = path.substring(0, semi); } } if (index == -1) { _requestURI = path; _queryString = null; } else { _requestURI = path.substring(0, index); _queryString = path.substring(index + 1); } index = _requestURI.lastIndexOf('.'); if ((index == -1) || (index < _requestURI.lastIndexOf('/'))) { _extension = null; } else { _extension = _requestURI.substring(index + 1); } }

Target:
public Path(String path) { int index = path.indexOf('?'); int semi = path.indexOf(';'); if (semi != -1) { if (index > semi) { path = path.substring(0, semi) + path.substring(index, path.length()); } else if (index == -1) { path = path.substring(0, semi); } } if (index == -1) { _requestURI = path; _queryString = null; } else { _requestURI = path.substring(0, index); _queryString = path.substring(index + 1); } index = _requestURI.lastIndexOf('.'); if ((index == -1) || (index < _requestURI.lastIndexOf('/'))) { _extension = null; } else { _extension = _requestURI.substring(index + 1); } }
Source:
private FBO getFbo() { if (defaultDynamicFBO == null) return frameBuffersManager.get(fboName); return defaultDynamicFBO.getFbo(); }

Target:
private FBO getFbo() { return defaultDynamicFBO != null ? defaultDynamicFBO.getFbo() : frameBuffersManager.get(fboName); }
Source:
public void testTypedefSyntheticMembers_415495() { final String[] expected= { "" }; assertCompletionResults(fCursorOffset, expected, REPLACEMENT); }

Target:
public void testTypedefSyntheticMembers_415495() throws Exception { final String[] expected= {}; assertCompletionResults(fCursorOffset, expected, REPLACEMENT); }
Source:
public void testFindTaskEventsForNotExistingTask() { try { taskClient.findTaskEvents(CONTAINER_ID, -9999l, 0, 10); fail("KieServicesException should be thrown complaining about task not found."); } catch (KieServicesException e) { KieServerAssert.assertResultContainsString(e.getMessage(), "No task found with id"); } }

Target:
public void testFindTaskEventsForNotExistingTask() { try { taskClient.findTaskEvents(CONTAINER_ID, -9999l, 0, 10); fail("KieServicesException should be thrown complaining about task not found."); } catch (KieServicesException e) { KieServerAssert.assertResultContainsString(e.getMessage(), "No task found with id"); if(configuration.isRest()) { KieServicesHttpException httpEx = (KieServicesHttpException) e; assertEquals("Exception has wrong HTTP Response code.", Integer.valueOf(404), httpEx.getHttpCode()); } } }
Source:
public void mergeProjectsInvalidSameNameTests() { openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); onView(withText(R.string.merge)).perform(click()); onRecyclerView().atPosition(0) .performCheckItem(); onRecyclerView().atPosition(1) .performCheckItem(); onView(withId(R.id.confirm)).perform(click()); onView(allOf(withText(""), isDisplayed(), instanceOf(EditText.class))) .perform(replaceText(inValidName)); closeSoftKeyboard(); onView(Matchers.allOf(withId(android.R.id.button1), withText(R.string.ok))) .check(matches(Matchers.allOf(isDisplayed(), not(isEnabled())))); }

Target:
public void mergeProjectsInvalidSameNameTests() { openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext()); onView(withText(R.string.merge)).perform(click()); onRecyclerView().atPosition(0) .performCheckItem(); onRecyclerView().atPosition(1) .performCheckItem(); onView(withId(R.id.confirm)).perform(click()); onView(allOf(withText(""), isDisplayed(), instanceOf(EditText.class))) .perform(replaceText(INVALIDNAME)); closeSoftKeyboard(); onView(allOf(withId(android.R.id.button1), withText(R.string.ok))) .check(matches(Matchers.allOf(isDisplayed(), not(isEnabled())))); }
Source:
private List<? extends DiscoverySelector> createDiscoverySelectors(CommandLineOptions options) { if (options.isScanClasspath()) { Preconditions.condition(!options.hasExplicitSelectors(), "Scanning the classpath and using explicit selectors at the same time is not supported"); return createClasspathRootSelectors(options); } if (options.isScanModulepath()) { Preconditions.condition(!options.hasExplicitSelectors(), "Scanning the module-path and using explicit selectors at the same time is not supported"); return Collections.singletonList(DiscoverySelectors.selectModule("ALL-MODULES")); } return createExplicitDiscoverySelectors(options); }

Target:
private List<? extends DiscoverySelector> createDiscoverySelectors(CommandLineOptions options) { if (options.isScanClasspath()) { Preconditions.condition(!options.hasExplicitSelectors(), "Scanning the classpath and using explicit selectors at the same time is not supported"); return createClasspathRootSelectors(options); } if (options.isScanModulepath()) { Preconditions.condition(!options.hasExplicitSelectors(), "Scanning the module-path and using explicit selectors at the same time is not supported"); return Collections.singletonList(DiscoverySelectors.selectModule(ModuleUtils.ALL_MODULES)); } return createExplicitDiscoverySelectors(options); }
Source:
private List<AwsServiceEndpointView> createInterfaceServiceEndpointsIfNeeded(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { if (USE_SERVICE_ENDPOINT.equals(networkCreationRequest.getEndpointType()) && CollectionUtils.isNotEmpty(interfaceServices)) { List<AwsServiceEndpointView> interfaceServiceEndpoints = createInterfaceServiceEndpoints(networkCreationRequest, subnets); LOGGER.debug("The following interface service endpoints will be created in the new vpc: {}", interfaceServiceEndpoints); return interfaceServiceEndpoints; } else { LOGGER.debug("No interface service endpoints will be created in the new vpc. serviceEndpointCreation: {}, interfaceServices: {}", networkCreationRequest.getEndpointType(), interfaceServices); return List.of(); } }

Target:
private List<AwsServiceEndpointView> createInterfaceServiceEndpointsIfNeeded(NetworkCreationRequest networkCreationRequest, List<SubnetRequest> subnets) { if (USE_SERVICE_ENDPOINT == networkCreationRequest.getEndpointType() && CollectionUtils.isNotEmpty(interfaceServices)) { List<AwsServiceEndpointView> interfaceServiceEndpoints = createInterfaceServiceEndpoints(networkCreationRequest, subnets); LOGGER.debug("The following interface service endpoints will be created in the new vpc: {}", interfaceServiceEndpoints); return interfaceServiceEndpoints; } else { LOGGER.debug("No interface service endpoints will be created in the new vpc. serviceEndpointCreation: {}, interfaceServices: {}", networkCreationRequest.getEndpointType(), interfaceServices); return List.of(); } }
Source:
public void testGetPartitionsSample() { HivePartition p1 = partition("p1=string1/p2=1234"); HivePartition p2 = partition("p1=string2/p2=2345"); HivePartition p3 = partition("p1=string3/p2=3456"); HivePartition p4 = partition("p1=string4/p2=4567"); HivePartition p5 = partition("p1=string5/p2=5678"); assertEquals(getPartitionsSample(ImmutableList.of(p1), 1), ImmutableList.of(p1)); assertEquals(getPartitionsSample(ImmutableList.of(p1), 2), ImmutableList.of(p1)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2), 2), ImmutableList.of(p1, p2)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3), 2), ImmutableList.of(p1, p3)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 1), getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 1)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 3), getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 3)); assertThat(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 3)).contains(p1, p4); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4, p5), 3).size(), 3); assertThat(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4, p5), 3)).contains(p1, p4, p5); }

Target:
public void testGetPartitionsSample() { HivePartition p1 = partition("p1=string1/p2=1234"); HivePartition p2 = partition("p1=string2/p2=2345"); HivePartition p3 = partition("p1=string3/p2=3456"); HivePartition p4 = partition("p1=string4/p2=4567"); HivePartition p5 = partition("p1=string5/p2=5678"); assertEquals(getPartitionsSample(ImmutableList.of(p1), 1), ImmutableList.of(p1)); assertEquals(getPartitionsSample(ImmutableList.of(p1), 2), ImmutableList.of(p1)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2), 2), ImmutableList.of(p1, p2)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3), 2), ImmutableList.of(p1, p3)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 1), getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 1)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 3), getPartitionsSample(ImmutableList.of(p1, p2, p3, p4), 3)); assertEquals(getPartitionsSample(ImmutableList.of(p1, p2, p3, p4, p5), 3), ImmutableList.of(p1, p5, p4)); }
Source:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateConditionalEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTopEvent.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, NON_CANCELLING, ""); }

Target:
public void testUnmarshallTopLevelEmptyEventProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateConditionalEvent emptyTopEvent = getCatchingIntermediateNodeById(diagram, EMPTY_TOP_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_NO_OUTGOING_EDGE); assertGeneralSet(emptyTopEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertConditionalEventExecutionSet(emptyTopEvent.getExecutionSet(), CONDITION_EXPRESSION_SCRIPT_DEFAULT_VALUE, CONDITION_EXPRESSION_LANGUAGE, CONDITION_ERPRESSION_TYPE, NON_CANCELLING, EMPTY_VALUE); }
Source:
public void removeChannel(WriteOnlyClient client) { Iterator<PhysicalNode> iterator = physicalNodes.iterator(); while (iterator.hasNext()) { if (iterator.next().getClient() == client) { iterator.remove(); break; } } }

Target:
public void removeChannel(WriteOnlyClient client) { physicalNodes.removeIf(node -> (node.getClient().equals(client))); }
Source:
public void contains() throws IOException { Assert.assertFalse(this.client.getConfig().getMap().containsKey(this.testKey)); this.client.getConfig().put(this.testKey, this.testKeyValue); Assert.assertTrue(this.client.getConfig().getMap().containsKey(this.testKey)); }

Target:
public void contains() throws IOException { assertThat(this.client.getConfig().getMap().keySet(), not(Matchers.contains(this.testKey))); this.client.getConfig().put(this.testKey, this.testKeyValue); assertThat(this.client.getConfig().getMap().keySet(), not(Matchers.contains(this.testKey))); }
Source:
private void reportLeak() { if (isLeakReportingEnabled()) { clearRefQueue(); return; } for (;;) { @SuppressWarnings("unchecked") DefaultResourceLeak ref = (DefaultResourceLeak) refQueue.poll(); if (ref == null) { break; } if (!ref.dispose()) { continue; } String records = ref.toString(); if (reportedLeaks.putIfAbsent(records, Boolean.TRUE) == null) { if (records.isEmpty()) { reportUntracedLeak(resourceType); } else { reportTracedLeak(resourceType, records); } } } }

Target:
private void reportLeak() { if (!isLeakReportingEnabled()) { clearRefQueue(); return; } for (;;) { @SuppressWarnings("unchecked") DefaultResourceLeak ref = (DefaultResourceLeak) refQueue.poll(); if (ref == null) { break; } if (!ref.dispose()) { continue; } String records = ref.toString(); if (reportedLeaks.putIfAbsent(records, Boolean.TRUE) == null) { if (records.isEmpty()) { reportUntracedLeak(resourceType); } else { reportTracedLeak(resourceType, records); } } } }
Source:
public Request checkUpgradeSession(Request request) throws IOException, KeeperException { if ((request.type != OpCode.create && request.type != OpCode.create2 && request.type != OpCode.multi) || !upgradeableSessionTracker.isLocalSession(request.sessionId)) { return null; } if (OpCode.multi == request.type) { MultiTransactionRecord multiTransactionRecord = new MultiTransactionRecord(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, multiTransactionRecord); request.request.rewind(); boolean containsEphemeralCreate = false; for (Op op : multiTransactionRecord) { if (op.getType() == OpCode.create || op.getType() == OpCode.create2) { CreateRequest createRequest = (CreateRequest)op.toRequestRecord(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags()); if (createMode.isEphemeral()) { containsEphemeralCreate = true; } } } if (!containsEphemeralCreate) { return null; } } else { CreateRequest createRequest = new CreateRequest(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, createRequest); request.request.rewind(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags()); if (!createMode.isEphemeral()) { return null; } } if (!self.isLocalSessionsUpgradingEnabled()) { throw new KeeperException.EphemeralOnLocalSessionException(); } return makeUpgradeRequest(request.sessionId); }

Target:
public Request checkUpgradeSession(Request request) throws IOException, KeeperException { if ((request.type != OpCode.create && request.type != OpCode.create2 && request.type != OpCode.multi) || !upgradeableSessionTracker.isLocalSession(request.sessionId)) { return null; } if (OpCode.multi == request.type) { MultiTransactionRecord multiTransactionRecord = new MultiTransactionRecord(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, multiTransactionRecord); request.request.rewind(); boolean containsEphemeralCreate = false; for (Op op : multiTransactionRecord) { if (op.getType() == OpCode.create || op.getType() == OpCode.create2) { CreateRequest createRequest = (CreateRequest)op.toRequestRecord(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags()); if (createMode.isEphemeral()) { containsEphemeralCreate = true; break; } } } if (!containsEphemeralCreate) { return null; } } else { CreateRequest createRequest = new CreateRequest(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, createRequest); request.request.rewind(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags()); if (!createMode.isEphemeral()) { return null; } } if (!self.isLocalSessionsUpgradingEnabled()) { throw new KeeperException.EphemeralOnLocalSessionException(); } return makeUpgradeRequest(request.sessionId); }
Source:
public List<EmploymentSummary> getEmploymentSummaryList(String userOrcid) { List<OrgAffiliationRelationEntity> employmentEntities = orgAffiliationRelationDao.getByUserAndType(userOrcid, AffiliationType.EMPLOYMENT); return jpaJaxbEmploymentAdapter.toEmploymentSummary(employmentEntities); }

Target:
public List<EmploymentSummary> getEmploymentSummaryList(String userOrcid) { List<OrgAffiliationRelationEntity> employmentEntities = orgAffiliationRelationDao.getEmploymentSummaries(userOrcid, getLastModified(userOrcid)); return jpaJaxbEmploymentAdapter.toEmploymentSummary(employmentEntities); }
Source:
void moveToFinally() throws CommandLineException { if(finallyList == null) { finallyList = new ArrayList<>(); } switch(state) { case IN_TRY: state = IN_FINALLY; break; case IN_CATCH: state = IN_FINALLY; break; case IN_FINALLY: throw new CommandLineException("Already in finally"); default: throw new IllegalStateException("Unexpected block id: " + state); } }

Target:
void moveToFinally() throws CommandLineException { switch(state) { case IN_TRY: case IN_CATCH: finallyList = new ArrayList<>(); state = IN_FINALLY; break; case IN_FINALLY: throw new CommandLineException("Already in finally"); default: throw new IllegalStateException("Unexpected block id: " + state); } }
Source:
public byte[][] split(byte[] input) { int len = input.length + (256 - input.length % 256); int nFragments = len / Fragment.MAX_LENGTH; if (len % Fragment.MAX_LENGTH > 0) nFragments++; byte[][] split = new byte[nFragments][]; for(int i= 0; i< nFragments; ++i) { int start = Fragment.MAX_LENGTH * i; int end = Math.min(input.length, start + Fragment.MAX_LENGTH); int length = end - start; byte[] b = new byte[length]; System.arraycopy(input, start, b, 0, length); split[i] = b; } return split; }

Target:
public byte[][] split(byte[] input) { int padding = 0; int mod = input.length % 256; if (mod != 0 || input.length == 0) padding = 256 - mod; int len = input.length + padding; int nFragments = len / Fragment.MAX_LENGTH; if (len % Fragment.MAX_LENGTH > 0) nFragments++; byte[][] split = new byte[nFragments][]; for(int i= 0; i< nFragments; ++i) { int start = Fragment.MAX_LENGTH * i; int end = Math.min(input.length, start + Fragment.MAX_LENGTH); int length = end - start; byte[] b = new byte[length]; System.arraycopy(input, start, b, 0, length); split[i] = b; } return split; }
Source:
public void updateImagePath(List<Process> processes) { for (Process proz : processes) { try { FileformatInterface myRdf = serviceManager.getProcessService().readMetadataFile(proz); MetadataTypeInterface mdt = UghHelper.getMetadataType(proz, "pathimagefiles"); List<? extends MetadataInterface> allImagePaths = myRdf.getDigitalDocument().getPhysicalDocStruct() .getAllMetadataByType(mdt); if (allImagePaths.size() > 0) { for (MetadataInterface md : allImagePaths) { myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadata().remove(md); } } MetadataInterface newmd = UghImplementation.INSTANCE.createMetadata(mdt); if (SystemUtils.IS_OS_WINDOWS) { newmd.setStringValue("file:/" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } else { newmd.setStringValue("file://" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } myRdf.getDigitalDocument().getPhysicalDocStruct().addMetadata(newmd); serviceManager.getFileService().writeMetadataFile(myRdf, proz); Helper.setMeldung("kitodoScriptfield", "ImagePath updated: ", proz.getTitle()); } catch (org.kitodo.api.ugh.exceptions.DocStructHasNoTypeException | UghHelperException | MetadataTypeNotAllowedException e) { Helper.setFehlerMeldung(e.getMessage()); } catch (Exception e) { Helper.setFehlerMeldung("kitodoScriptfield", "Error while updating imagepath", e); } } Helper.setMeldung("kitodoScriptfield", "", "updateImagePath finished"); }

Target:
public void updateImagePath(List<Process> processes) { for (Process proz : processes) { try { FileformatInterface myRdf = serviceManager.getProcessService().readMetadataFile(proz); MetadataTypeInterface mdt = UghHelper.getMetadataType(proz, "pathimagefiles"); List<? extends MetadataInterface> allImagePaths = myRdf.getDigitalDocument().getPhysicalDocStruct() .getAllMetadataByType(mdt); if (allImagePaths.size() > 0) { for (MetadataInterface md : allImagePaths) { myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadata().remove(md); } } MetadataInterface newmd = UghImplementation.INSTANCE.createMetadata(mdt); if (SystemUtils.IS_OS_WINDOWS) { newmd.setStringValue("file:/" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } else { newmd.setStringValue("file://" + serviceManager.getFileService().getImagesDirectory(proz) + proz.getTitle() + DIRECTORY_SUFFIX); } myRdf.getDigitalDocument().getPhysicalDocStruct().addMetadata(newmd); serviceManager.getFileService().writeMetadataFile(myRdf, proz); Helper.setMeldung("kitodoScriptfield", "ImagePath updated: ", proz.getTitle()); } catch (DocStructHasNoTypeException | UghHelperException | MetadataTypeNotAllowedException e) { Helper.setFehlerMeldung(e.getMessage()); } catch (Exception e) { Helper.setFehlerMeldung("kitodoScriptfield", "Error while updating imagepath", e); } } Helper.setMeldung("kitodoScriptfield", "", "updateImagePath finished"); }
Source:
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c.locking().isolationLevel(IsolationLevel.READ_COMMITTED); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false); multimapCache = EmbeddedMultimapCacheManagerFactory.get("test", cm, c.build()); return cm; }

Target:
protected EmbeddedCacheManager createCacheManager() throws Exception { ConfigurationBuilder c = getDefaultStandaloneCacheConfig(true); c.locking().isolationLevel(IsolationLevel.READ_COMMITTED); EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(false); MultimapCacheManager multimapCacheManager = EmbeddedMultimapCacheManagerFactory.from(cm); multimapCacheManager.defineConfiguration("test", c.build()); multimapCache = multimapCacheManager.get("test"); return cm; }
Source:
public void startLog() { (new RangerLoadBegin(sourceDbName, targetDbName, estimatedNumPolicies)).log(LogTag.RANGER_LOAD_START); }

Target:
public void startLog() { new RangerLoadBegin(sourceDbName, targetDbName, estimatedNumPolicies).log(LogTag.RANGER_LOAD_START); }
Source:
public User getUser(String username) { User user = authentication.getUser(username); return user; }

Target:
public User getUser(String username) { return authentication.getUser(username); }
Source:
public void getNettyServerFactoryWithBadInputTest() throws Exception { Properties properties = new Properties(); VerifiableProperties verifiableProperties = new VerifiableProperties(properties); MetricRegistry metricRegistry = new MetricRegistry(); RestRequestHandler restRequestHandler = new MockRestRequestResponseHandler(); PublicAccessLogger publicAccessLogger = new PublicAccessLogger(new String[]{}, new String[]{}); RestServerState restServerState = new RestServerState("/healthCheck"); SSLFactory sslFactory = new MockSSLFactory(verifiableProperties); for (int i = 0; i < 5; i++) { try { new NettyServerFactory(i == 0 ? verifiableProperties : null, i == 1 ? metricRegistry : null, i == 2 ? restRequestHandler : null, i == 3 ? publicAccessLogger : null, i == 4 ? restServerState : null, sslFactory); fail("Instantiation should have failed because argument " + i + " was null"); } catch (IllegalArgumentException e) { } } properties.setProperty("netty.server.ssl.port", "abcd"); try { new NettyServerFactory(verifiableProperties, metricRegistry, restRequestHandler, publicAccessLogger, restServerState, sslFactory); fail("NettyServerFactory instantiation should have failed because of bad port number value"); } catch (NumberFormatException e) { } }

Target:
public void getNettyServerFactoryWithBadInputTest() { Properties properties = new Properties(); properties.setProperty("netty.server.enable.ssl", "true"); VerifiableProperties verifiableProperties = new VerifiableProperties(properties); MetricRegistry metricRegistry = new MetricRegistry(); doConstructionFailureTest(null, metricRegistry, REST_REQUEST_HANDLER, PUBLIC_ACCESS_LOGGER, REST_SERVER_STATE, SSL_FACTORY); doConstructionFailureTest(verifiableProperties, null, REST_REQUEST_HANDLER, PUBLIC_ACCESS_LOGGER, REST_SERVER_STATE, SSL_FACTORY); doConstructionFailureTest(verifiableProperties, metricRegistry, null, PUBLIC_ACCESS_LOGGER, REST_SERVER_STATE, SSL_FACTORY); doConstructionFailureTest(verifiableProperties, metricRegistry, REST_REQUEST_HANDLER, null, REST_SERVER_STATE, SSL_FACTORY); doConstructionFailureTest(verifiableProperties, metricRegistry, REST_REQUEST_HANDLER, PUBLIC_ACCESS_LOGGER, null, SSL_FACTORY); doConstructionFailureTest(verifiableProperties, metricRegistry, REST_REQUEST_HANDLER, PUBLIC_ACCESS_LOGGER, REST_SERVER_STATE, null); }
Source:
public JsonNode toJson() { ArrayNode arr = getFactory().arrayNode(); arr.add(getFactory().numberNode(from)).add(getFactory().numberNode(to)); return ((ObjectNode) super.toJson()).set("range", arr); }

Target:
public JsonNode toJson() { ArrayNode arr = getFactory().arrayNode(); if (from == null) { arr.add(getFactory().nullNode()); if (to == null) { arr.add(getFactory().nullNode()); } else { arr.add(getFactory().numberNode(to)); } } else if (from != null) { arr.add(getFactory().numberNode(from)); if (to == null) { arr.add(getFactory().nullNode()); } else { arr.add(getFactory().numberNode(to)); } } return ((ObjectNode) super.toJson()).set("range", arr); }