auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testCall() { String revision_id = null, change_id = null; try { GitAccess gAccess = new GitAccess(); Git git = gAccess.getGitProject(); gAccess.addFile("EGerritTestReviewFile.java", "Hello reviewers community !"); gAccess.pushFile(); change_id = gAccess.getChangeId(); revision_id = gAccess.getCommitId(); } catch (Exception e1) { e1.printStackTrace(); } ListDraftsCommand command = fGerrit.listDraftsComments(change_id, revision_id); Map<String, ArrayList<CommentInfo>> result = null; try { result = command.call(); } catch (EGerritException | ClientProtocolException e) { fail(e.getMessage()); } <START> assert (result.size() == 1); <END> }</code><technical_language>size ==1, insert drafts</technical_language>

Target:
public void testCall() { String revision_id = null, change_id = null; try { GitAccess gAccess = new GitAccess(); Git git = gAccess.getGitProject(); gAccess.addFile("EGerritTestReviewFile.java", "Hello reviewers community !"); gAccess.pushFile(); change_id = gAccess.getChangeId(); revision_id = gAccess.getCommitId(); } catch (Exception e1) { fail(e1.getMessage()); } CreateDraftCommand command = fGerrit.createDraftComments(change_id, revision_id); CommentInfo commentInfo = new CommentInfo(); commentInfo.setLine(2); commentInfo.setMessage("This is a test comment"); commentInfo.setPath("EGerritTestReviewFile.java"); command.setCommentInfo(commentInfo); CommentInfo result = null; try { result = command.call(); } catch (EGerritException e) { fail(e.getMessage()); } catch (ClientProtocolException e) { fail(e.getMessage()); } ListDraftsCommand command2 = fGerrit.listDraftsComments(change_id, revision_id); Map<String, ArrayList<CommentInfo>> result2 = null; try { result2 = command2.call(); } catch (EGerritException | ClientProtocolException e) { fail(e.getMessage()); } assert (result2.size() == 1); }
Source:
<code><START> private HashSet<NetworkComponent> getNetworkComponents(VirtualGuest virtualGuest) { <END> if(virtualGuest.getVirtualGuestNetworkComponents() == null) return null; return Sets.newHashSet(Iterables.transform(virtualGuest.getVirtualGuestNetworkComponents(), new Function<VirtualGuestNetworkComponent, NetworkComponent>() { @Override public NetworkComponent apply(VirtualGuestNetworkComponent input) { return new NetworkComponent(input.getSpeed()); } })); }</code><technical_language>if is a private method, return Set interface instead of a concrete implementation</technical_language>

Target:
private Set<NetworkComponent> getNetworkComponents(VirtualGuest virtualGuest) { if (virtualGuest.getVirtualGuestNetworkComponents() == null) { return null; } ImmutableSet.Builder networkComponents = ImmutableSet.builder(); for (VirtualGuestNetworkComponent networkComponent : virtualGuest.getVirtualGuestNetworkComponents()) { networkComponents.add(new NetworkComponent(networkComponent.getSpeed())); } return networkComponents.build(); }
Source:
<code>private void createTableIfNotExists(String tableName, String zkQuorum, int zkClientPort) throws IOException { Configuration conf = HBaseConfiguration.create(); <START> <LINK_0> <END> conf.setClassLoader(HBaseConfiguration.class.getClassLoader()); conf.set(HConstants.ZOOKEEPER_QUORUM, zkQuorum); conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort); conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zkParentNode); HBaseAdmin hBaseAdmin = new HBaseAdmin(conf); if (!hBaseAdmin.tableExists(tableName)) { HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); tableDescriptor.addFamily(new HColumnDescriptor(family)); hBaseAdmin.createTable(tableDescriptor); } }</code><technical_language>is this URL link for</technical_language>

Target:
private void createTableIfNotExists(String tableName, String zkQuorum, int zkClientPort) throws IOException { Configuration conf = HBaseConfiguration.create(); conf.setClassLoader(HBaseConfiguration.class.getClassLoader()); conf.set(HConstants.ZOOKEEPER_QUORUM, zkQuorum); conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClientPort); conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zkParentNode); HBaseAdmin hBaseAdmin = new HBaseAdmin(conf); if (!hBaseAdmin.tableExists(tableName)) { HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); tableDescriptor.addFamily(new HColumnDescriptor(family)); hBaseAdmin.createTable(tableDescriptor); } }
Source:
<code>public void runInPodWithRestartWithMultipleContainerCalls() throws Exception { story.addStep(new Statement() { @Override public void evaluate() throws Throwable { configureCloud(); story.j.jenkins.addNode(new DumbSlave("slave", "dummy", tmp.newFolder("remoteFS").getPath(), "1", Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList())); WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runInPodWithRestartWithMultipleContainerCalls.groovy") , true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); SemaphoreStep.waitForStart("wait/1", b); SemaphoreStep.success("wait/1", false); <START> Thread.sleep(10000); <END> } }); story.addStep(new Statement() { @SuppressWarnings("SleepWhileInLoop") @Override public void evaluate() throws Throwable { WorkflowRun b = story.j.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1); story.j.assertLogContains("finished the test!", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b))); } }); }</code><technical_language>Flaky. Perhaps: java r.waitForMessage("+ sleep 5", b);</technical_language>

Target:
public void runInPodWithRestartWithMultipleContainerCalls() throws Exception { story.then(r -> { configureCloud(); r.jenkins.addNode(new DumbSlave("slave", "dummy", tmp.newFolder("remoteFS").getPath(), "1", Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList())); WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); p.setDefinition(new CpsFlowDefinition(loadPipelineScript("runInPodWithRestartWithMultipleContainerCalls.groovy") , true)); WorkflowRun b = p.scheduleBuild2(0).waitForStart(); r.waitForMessage("+ sleep 5", b); }); story.then(r -> { WorkflowRun b = r.jenkins.getItemByFullName("p", WorkflowJob.class).getBuildByNumber(1); r.assertLogContains("finished the test!", r.assertBuildStatusSuccess(r.waitForCompletion(b))); }); }
Source:
<code>public void testOperationCanceledExceptionAreHandled() { try { SafeRunner.run(() -> { throw new OperationCanceledException(); }); } catch (OperationCanceledException e) { fail("OperationCanceledException unexpectedly <START> catched.", <END> e); } }</code><technical_language>catch is irregular. is "caught". (several times more in this file)</technical_language>

Target:
public void testOperationCanceledExceptionAreHandled() { try { SafeRunner.run(() -> { throw new OperationCanceledException(); }); } catch (OperationCanceledException e) { fail("OperationCanceledException unexpectedly caught.", e); } }
Source:
<code>private void addNewElement(int hashPosition, Block block, int position) { elementType.appendTo(block, position, elementBlock); if (elementBlock.getSizeInBytes() > FOUR_MEGABYTES) { <START> throw new PrestoException(EXCEEDED_FUNCTION_MEMORY_LIMIT, String.format("the argument of %s exceeds of %s", functionName, MAX_FUNCTION_MEMORY)); <END> } blockPositionByHash.set(hashPosition, elementBlock.getPositionCount() - 1); if (elementBlock.getPositionCount() >= maxFill) { rehash(); } }</code><technical_language>generally statically import String.format</technical_language>

Target:
private void addNewElement(int hashPosition, Block block, int position) { elementType.appendTo(block, position, elementBlock); if (elementBlock.getSizeInBytes() > FOUR_MEGABYTES) { throw new PrestoException( EXCEEDED_FUNCTION_MEMORY_LIMIT, format("The input to %s is too large. More than %s of memory is needed to hold the intermediate hash set.\n", functionName, MAX_FUNCTION_MEMORY)); } blockPositionByHash.set(hashPosition, elementBlock.getPositionCount() - 1); if (elementBlock.getPositionCount() >= maxFill) { rehash(); } }
Source:
<code>public void removeBackupReminder(long masterKeyId) { String reminders = mSharedPreferences.getString(Pref.BACKUP_REMINDERS,null); if (reminders != null) { List<String> masterKeyIds = new ArrayList<>(Arrays.asList(reminders.split(","))); <START> masterKeyIds.remove(masterKeyId+""); <END> reminders = TextUtils.join(",", masterKeyIds); SharedPreferences.Editor editor = mSharedPreferences.edit(); if (reminders == "") editor.remove(Pref.BACKUP_REMINDERS); else editor.putString(Pref.BACKUP_REMINDERS, reminders); editor.apply(); } }</code><technical_language>please Long.toString, this javascript ;)</technical_language>

Target:
public void removeBackupReminder(long masterKeyId) { String reminders = mSharedPreferences.getString(Pref.BACKUP_REMINDERS, null); if (reminders != null) { List<String> masterKeyIds = new ArrayList<>(Arrays.asList(reminders.split(","))); masterKeyIds.remove(Long.toString(masterKeyId)); reminders = TextUtils.join(",", masterKeyIds); SharedPreferences.Editor editor = mSharedPreferences.edit(); if (reminders.equals("")) { editor.remove(Pref.BACKUP_REMINDERS); } else { editor.putString(Pref.BACKUP_REMINDERS, reminders); } editor.apply(); } }
Source:
<code>static StatsSnapshot convertStoreUsageToContainerStatsSnapshot(Map<String, Map<String, Long>> utilizationMap) { Map<String, StatsSnapshot> containerValidSizeMap = new HashMap<>(); long totalSize = 0; for (Map.Entry<String, Map<String, Long>> accountEntry : utilizationMap.entrySet()) { for (Map.Entry<String, Long> containerEntry : accountEntry.getValue().entrySet()) { totalSize += containerEntry.getValue(); <START> containerValidSizeMap.put(accountEntry.getKey() + "_" + containerEntry.getKey(), <END> new StatsSnapshot(containerEntry.getValue(), null)); } } return new StatsSnapshot(totalSize, containerValidSizeMap); }</code><technical_language>i declare separator ("\_") a variable in a common place. I "\_\_" "\_\_\_" (two underscores) separator in case account name underscores</technical_language>

Target:
static StatsSnapshot convertStoreUsageToContainerStatsSnapshot(Map<String, Map<String, Long>> utilizationMap) { Map<String, StatsSnapshot> containerValidSizeMap = new HashMap<>(); long totalSize = 0; for (Map.Entry<String, Map<String, Long>> accountEntry : utilizationMap.entrySet()) { for (Map.Entry<String, Long> containerEntry : accountEntry.getValue().entrySet()) { totalSize += containerEntry.getValue(); containerValidSizeMap.put(accountEntry.getKey() + Utils.ACCOUNT_CONTAINER_SEPARATOR + containerEntry.getKey(), new StatsSnapshot(containerEntry.getValue(), null)); } } return new StatsSnapshot(totalSize, containerValidSizeMap); }
Source:
<code>public Wrapper startCache(Classification classification, Properties properties) throws Exception { ServiceContainer target = currentServiceContainer(); String container = properties.getProperty(CONTAINER); String cacheType = properties.getProperty(CACHE_TYPE); ServiceName containerServiceName = ServiceName.parse(InfinispanRequirement.CONTAINER.resolve(container)); String name = properties.getProperty(NAME, UUID.randomUUID().toString()); ServiceBuilder<?> builder = target.addService(ServiceName.JBOSS.append(DEFAULT_CACHE_CONTAINER, name)); Supplier<EmbeddedCacheManager> manager = builder.requires(containerServiceName); if (CACHE_PRIVATE.equals(cacheType)) { String[] caches = properties.getProperty(CACHES).split("\\s+"); for (String cache : caches) { ServiceName dependencyName = ServiceName.parse(InfinispanCacheRequirement.CONFIGURATION.resolve(container, cache)); builder.requires(dependencyName); } } <START> final UninterruptibleCountDownLatch latch = new UninterruptibleCountDownLatch(1); <END> builder.addListener(new LifecycleListener() { @Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { if (event == LifecycleEvent.UP) { latch.countDown(); controller.removeListener(this); } } }); ServiceController<?> controller = builder.install(); latch.awaitUninterruptibly(); return new CacheWrapper(manager.get(), controller); }</code><technical_language>Is a reason for ignoring interrupts here? more propagate InterruptedException caller</technical_language>

Target:
public Wrapper startCache(Classification classification, Properties properties) throws Exception { ServiceContainer target = currentServiceContainer(); String container = properties.getProperty(CONTAINER); String cacheType = properties.getProperty(CACHE_TYPE); ServiceName containerServiceName = ServiceNameFactory.parseServiceName(InfinispanRequirement.CONTAINER.getName()).append(container); String name = properties.getProperty(NAME, UUID.randomUUID().toString()); ServiceBuilder<?> builder = target.addService(ServiceName.JBOSS.append(DEFAULT_CACHE_CONTAINER, name)); Supplier<EmbeddedCacheManager> manager = builder.requires(containerServiceName); if (CACHE_PRIVATE.equals(cacheType)) { String[] caches = properties.getProperty(CACHES).split("\\s+"); for (String cache : caches) { builder.requires(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(container, cache)); } } final CountDownLatch latch = new CountDownLatch(1); builder.addListener(new LifecycleListener() { @Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { if (event == LifecycleEvent.UP) { latch.countDown(); controller.removeListener(this); } } }); ServiceController<?> controller = builder.install(); latch.await(); return new CacheWrapper(manager.get(), controller); }
Source:
<code>public SBIIndexWriter(final OutputStream out, final long granularity) { this.out = out; this.granularity = granularity; try { <START> this.tempOffsetsFile = File.createTempFile("offsets-", ".headerless.sbi"); <END> this.tempOffsetsCodec = new BinaryCodec(new BufferedOutputStream(new FileOutputStream(tempOffsetsFile))); } catch (IOException e) { throw new RuntimeIOException(e); } }</code><technical_language>nice Path File in new code possible. E.g. Files.createTempFile() Files.newOutputStream() below</technical_language>

Target:
public SBIIndexWriter(final OutputStream out, final long granularity) { this.out = out; this.granularity = granularity; try { this.tempOffsetsFile = Files.createTempFile("offsets-", ".headerless.sbi"); this.tempOffsetsCodec = new BinaryCodec(new BufferedOutputStream(Files.newOutputStream(tempOffsetsFile))); } catch (IOException e) { throw new RuntimeIOException(e); } }
Source:
<code><START> public synchronized Connection handleActiveConnection(ChannelHandlerContext ctx, Connection.Direction direction) { <END> Channel channel = ctx.channel(); Connection conn; conn = add(channel, direction); if (conn.direction == Connection.Direction.OUT) { InitRequest initRequest = new InitRequest(0, InitMessage.DEFAULT_VERSION, new HashMap<String, String>() { } ); initRequest.setHostPort(this.manager.getHostPort()); initRequest.setProcessName("java-process"); ChannelFuture f = ctx.writeAndFlush(initRequest); f.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } return conn; }</code><technical_language>is this class inheriting ChannelHandler ? I passing ChannelHandlerContext Netty</technical_language>

Target:
public Connection handleActiveConnection(ChannelHandlerContext ctx, Connection.Direction direction) { Channel channel = ctx.channel(); Connection conn = add(channel, direction); if (conn.direction == Connection.Direction.OUT) { InitRequest initRequest = new InitRequest(0, InitMessage.DEFAULT_VERSION, new HashMap<String, String>() { } ); initRequest.setHostPort(this.manager.getHostPort()); initRequest.setProcessName("java-process"); ChannelFuture f = ctx.writeAndFlush(initRequest); f.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } return conn; }
Source:
<code>protected void executeCommand() { updateQuotaCache(); copyUnchangedStoragePoolProperties(getStoragePool(), oldStoragePool); getStoragePoolDao().updatePartial(getStoragePool()); updateStoragePoolFormatType(); <START> <END> moveMacsFromOldMacPoolToNewOne(); setSucceeded(true); }</code><technical_language>a reply TODO in line #126- code ("moveMacsFromOldMacPoolToNewOne();") moved line 92. in transaction "getStoragePoolDao().updatePartial(getStoragePool());". Line 91 includes update of dc mac pool. in case of a failure (crashing of engine for example) mac pool update moving macs new pool, dc in inconsistent state needs reverted</technical_language>

Target:
protected void executeCommand() { updateQuotaCache(); copyUnchangedStoragePoolProperties(getStoragePool(), oldStoragePool); TransactionSupport.executeInScope(TransactionScopeOption.RequiresNew, () -> { getStoragePoolDao().updatePartial(getStoragePool()); moveMacsFromOldMacPoolToNewOne(); return null; }); updateStoragePoolFormatType(); setSucceeded(true); }
Source:
<code>public String toString() { <START> this.requireDelegate(); <END> return this.delegate.toString(); }</code><technical_language>this. methods...only members</technical_language>

Target:
public String toString() { return getDelegate().toString(); }
Source:
<code>private void verifyOutput(StoreCopier.Message output, StoreCopier.Message expected) throws IOException { <START> assertTrue("MessageInfos not equal, Output: " + output.getMessageInfo() + " Expected: " + expected.getMessageInfo(), <END> output.getMessageInfo().equals(expected.getMessageInfo())); assertInputStreamEqual(output.getStream(), expected.getStream()); }</code><technical_language>assertEquals()? print args if equal</technical_language>

Target:
private void verifyOutput(StoreCopier.Message output, StoreCopier.Message expected) throws IOException { if (expected == null) { assertNull("output should be null", output); } else { assertEquals("MessageInfos not equal", expected.getMessageInfo(), output.getMessageInfo()); TestUtils.assertInputStreamEqual(output.getStream(), expected.getStream(), (int) expected.getMessageInfo().getSize(), true); } }
Source:
<code>public String toString() { <START> return "ParameterizedMetricKey{key=" + key.name() + ", version=" + options + '}'; <END> }</code><technical_language>adjust string: version= -> options=</technical_language>

Target:
public String toString() { return "ParameterizedMetricKey{key=" + key.name() + ", options=" + options + '}'; }
Source:
<code>public void setup(com.datatorrent.api.Context.OperatorContext context) { try { JAXBContext ctx = JAXBContext.newInstance(getClazz()); unmarshaller = ctx.createUnmarshaller(); if (schemaXSDFile != null) { <START> Path filePath = new Path(schemaXSDFile); <END> Configuration configuration = new Configuration(); FileSystem fs = FileSystem.newInstance(filePath.toUri(), configuration); FSDataInputStream inputStream = fs.open(filePath); SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new StreamSource(inputStream)); unmarshaller.setSchema(schema); validator = schema.newValidator(); } } catch (SAXException e) { DTThrowable.wrapIfChecked(e); } catch (JAXBException e) { DTThrowable.wrapIfChecked(e); } catch (IOException e) { DTThrowable.wrapIfChecked(e); } }</code><technical_language>reading file part put a utility class method uri return contents of file stream / string . others reuse code</technical_language>

Target:
public void setup(com.datatorrent.api.Context.OperatorContext context) { try { JAXBContext ctx = JAXBContext.newInstance(getClazz()); unmarshaller = ctx.createUnmarshaller(); if (schemaXSDFile != null) { Path filePath = new Path(schemaXSDFile); Configuration configuration = new Configuration(); FileSystem fs = FileSystem.newInstance(filePath.toUri(), configuration); FSDataInputStream inputStream = fs.open(filePath); SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = factory.newSchema(new StreamSource(inputStream)); unmarshaller.setSchema(schema); validator = schema.newValidator(); fs.close(); } } catch (SAXException e) { DTThrowable.wrapIfChecked(e); } catch (JAXBException e) { DTThrowable.wrapIfChecked(e); } catch (IOException e) { DTThrowable.wrapIfChecked(e); } }
Source:
<code>private ITypedElement getElement(Repository repository, IFileRevision reviewFileRevision) { if (repository != null) { org.eclipse.team.core.history.IFileRevision repoFileRevision = ReviewUtils.getIFileRevision(repository, reviewFileRevision); InputStream repoFileContents = null; try { repoFileContents = repoFileRevision.getStorage(null).getContents(); } catch (CoreException e) { } if (repoFileRevision != null && repoFileContents != null) { <START> return new FileRevisionTypedElement(repoFileRevision, reviewFileRevision.getPath()); <END> } } return new ByteArrayInput(ReviewUtils.getContent(reviewFileRevision), reviewFileRevision.getPath()); }</code><technical_language>this line live in try block above</technical_language>

Target:
private ITypedElement getElement(Repository repository, IFileRevision reviewFileRevision) { if (repository != null) { org.eclipse.team.core.history.IFileRevision repoFileRevision = ReviewUtils.getFileRevision(repository, reviewFileRevision); InputStream repoFileContents = null; try { repoFileContents = repoFileRevision.getStorage(null).getContents(); } catch (CoreException e) { } if (repoFileRevision != null && repoFileContents != null) { return new FileRevisionTypedElement(repoFileRevision, reviewFileRevision.getPath()); } } return new ByteArrayInput(ReviewUtils.getContent(reviewFileRevision), reviewFileRevision.getPath()); }
Source:
<code>public void equalsAndHashCodeEvenWithDifferentFileMode() throws Exception { final Path file = createTempFile("somepath"); final MountableFile mountableFile1 = MountableFile.forHostPath(file.toString(), 365); final MountableFile mountableFile2 = MountableFile.forHostPath(file.toString(), 356); <START> assertEquals("should not be equal", mountableFile1, mountableFile2); <END> assertEquals("should not have same hash code", mountableFile1.hashCode(), mountableFile2.hashCode()); }</code><technical_language>message is misleading</technical_language>

Target:
public void equalsAndHashCodeEvenWithDifferentFileMode() throws Exception { final Path file = createTempFile("somepath"); final MountableFile mountableFile1 = MountableFile.forHostPath(file.toString(), 365); final MountableFile mountableFile2 = MountableFile.forHostPath(file.toString(), 356); assertEquals("should be equal", mountableFile1, mountableFile2); assertEquals("should have same hash code", mountableFile1.hashCode(), mountableFile2.hashCode()); }
Source:
<code>private Integer getCategoryIdByTitle(long accountId, @NonNull String categoryTitle) { validateAccountId(accountId); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query( table_category, new String[]{key_category_id}, key_category_title + " = ? AND " + key_category_account_id + " = ? ", new String[]{categoryTitle, String.valueOf(accountId)}, <START> key_category_id, <END> null, key_category_id); int id = -1; if (cursor.moveToNext()) { id = cursor.getInt(0); } else { id = (int) addCategory(categoryTitle, accountId); if (id == -1) { Log.e(TAG, String.format("Error occurs when creating category: %s", categoryTitle)); } } cursor.close(); return id; }</code><technical_language>group key_category_id? this null</technical_language>

Target:
private Integer getCategoryIdByTitle(long accountId, @NonNull String categoryTitle) { validateAccountId(accountId); SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.query( table_category, new String[]{key_category_id}, key_category_title + " = ? AND " + key_category_account_id + " = ? ", new String[]{categoryTitle, String.valueOf(accountId)}, null, null, null); int id = -1; if (cursor.moveToNext()) { id = cursor.getInt(0); } else { id = (int) addCategory(accountId, categoryTitle); if (id == -1) { Log.e(TAG, String.format("Error occurs when creating category: %s", categoryTitle)); } } cursor.close(); return id; }
Source:
<code>public void perform( List<Pair<VmDynamic, VdsmVm>> monitoredVms, long fetchTime, VdsManager vdsManager, boolean updateStatistics) { if (monitoredVms.isEmpty()) { return; } List<VmAnalyzer> vmAnalyzers = Collections.emptyList(); try { vmAnalyzers = analyzeVms(monitoredVms, fetchTime, vdsManager, updateStatistics); addUnmanagedVms(vmAnalyzers, vdsManager.getVdsId()); flush(vmAnalyzers); <START> postFlush(vmAnalyzers, <END> vdsManager); vdsManager.vmsMonitoringInitFinished(); } catch (RuntimeException ex) { log.error("Failed during vms monitoring on host error is: {}", vdsManager.getVdsName(), ex); log.error("Exception:", ex); } finally { unlockVms(vmAnalyzers); } }</code><technical_language>pass fetchTime VmJobsMonitoring instead of adding VmAnalyzer, right</technical_language>

Target:
public void perform( List<Pair<VmDynamic, VdsmVm>> monitoredVms, long fetchTime, VdsManager vdsManager, boolean updateStatistics) { if (monitoredVms.isEmpty()) { return; } List<VmAnalyzer> vmAnalyzers = Collections.emptyList(); try { vmAnalyzers = analyzeVms(monitoredVms, fetchTime, vdsManager, updateStatistics); addUnmanagedVms(vmAnalyzers, vdsManager.getVdsId()); flush(vmAnalyzers); postFlush(vmAnalyzers, vdsManager, fetchTime); vdsManager.vmsMonitoringInitFinished(); } catch (RuntimeException ex) { log.error("Failed during vms monitoring on host error is: {}", vdsManager.getVdsName(), ex); log.error("Exception:", ex); } finally { unlockVms(vmAnalyzers); } }
Source:
<code>private void initTragetDomains() { templateDisks = diskDao.getAllForVm(getParameters().getVmStaticData().getVmtGuid()); targetDomains = new HashMap<>(); for (Disk disk: templateDisks) { for (Guid id: ((DiskImage)disk).getStorageIds()) { StorageDomain domain = domainDao.get(id); if (!targetDomains.keySet().contains(domain)) { <START> targetDomains.put(domain, domain.getAvailableDiskSizeInBytes()); <END> } } } }</code><technical_language>hmmm, correct if wrong I is a case this is correct: - 2 storage domains, A B - a template 2 disks, X Y - disk X domain A disk Y domain B - lets domain A is 10x bigger domain B putting disks more empty space storage B - this algorithm put disks storage A template disk Y storage B think</technical_language>

Target:
private void initTragetDomains() { templateDisksList = diskDao.getAllForVm(getParameters().getVmStaticData().getVmtGuid()); targetDomainsSize = new HashMap<>(); diskToProfileMap = new HashMap<>(); for (Disk disk: templateDisksList) { diskToProfileMap.put(disk.getId(), ((DiskImage)disk).getDiskProfileIds()); for (Guid id: ((DiskImage)disk).getStorageIds()) { StorageDomain domain = domainDao.get(id); if (!targetDomainsSize.keySet().contains(domain)) { targetDomainsSize.put(domain, domain.getAvailableDiskSizeInBytes()); } } } }
Source:
<code><START> public HttpResponse delete(String identifier) { <END> return deleteWithResponse(uri("/workbooks/%s", identifier)).executeWithResponse(); }</code><technical_language>ActionResponse</technical_language>

Target:
public ActionResponse delete(String identifier) { return deleteWithResponse(uri("/workbooks/%s", identifier)).execute(); }
Source:
<code>public static void main(String[] args) { if (args.length < 4) { System.out.println("Please specify your access key, number, country code and billing interval months, eg: ExamplePurchaseNumber test_accesskey 3197010240563 NL 1"); return; } final MessageBirdService wsr = new MessageBirdServiceImpl(args[0], "<LINK_0>"); final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); try { PurchasedNumberCreatedResponse purchasedNumberCreatedResponse = messageBirdClient.purchaseNumber(args[1], args[2], Integer.parseInt(args[3])); System.out.println(purchasedNumberCreatedResponse); <START> return; <END> } catch (UnauthorizedException | GeneralException exception) { if (exception.getErrors() != null) { System.out.println(exception.getErrors().toString()); } exception.printStackTrace(); } }</code><technical_language>return -- needed</technical_language>

Target:
public static void main(String[] args) { if (args.length < 4) { System.out.println("Please specify your access key, number, country code and billing interval months, eg: ExamplePurchaseNumber test_accesskey 3197010240563 NL 1"); return; } final MessageBirdService wsr = new MessageBirdServiceImpl(args[0], "<LINK_0>"); final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr); try { PurchasedNumberCreatedResponse purchasedNumberCreatedResponse = messageBirdClient.purchaseNumber(args[1], args[2], Integer.parseInt(args[3])); System.out.println(purchasedNumberCreatedResponse); } catch (UnauthorizedException | GeneralException exception) { if (exception.getErrors() != null) { System.out.println(exception.getErrors().toString()); } exception.printStackTrace(); } }
Source:
<code><START> protected ExtensionRegistry getExtensionRegistry() { <END> return extensionRegistry; }</code><technical_language>This method is called package</technical_language>

Target:
ExtensionRegistry getExtensionRegistry() { return extensionRegistry; }
Source:
<code>public void getReserveScopes() { <START> Set<SystemScope> reserved = SystemScopeService.reservedScopes; <END> assertThat(service.getReserved(), equalTo(reserved)); }</code><technical_language>need pull this out a separate variable, reference in test</technical_language>

Target:
public void getReserveScopes() { assertThat(service.getReserved(), equalTo(SystemScopeService.reservedScopes)); }
Source:
<code>public void testDisableLayerServiceResponse() throws Exception { enableWCS(); String layerName = "wcs:BlueMarble"; <START> LayerInfo linfo = getCatalog().getLayerByName(layerName); <END> ResourceInfo ri = linfo.getResource(); ri.setServiceConfiguration(true); ri.setDisabledServices(new ArrayList<>(Arrays.asList("WCS"))); getCatalog().save(ri); getCatalog().save(linfo); Document doc = getAsDOM("wcs?service=WCS&request=getCapabilities"); assertXpathEvaluatesTo( "0", "count( }</code><technical_language>LayerInfo is useful here, able call getCatalog().getCoverageByName() save CoverageInfo</technical_language>

Target:
public void testDisableLayerServiceResponse() throws Exception { enableWCS(); CoverageInfo cinfo = getCatalog().getCoverageByName("wcs:BlueMarble"); cinfo.setServiceConfiguration(true); cinfo.setDisabledServices(new ArrayList<>(Arrays.asList("WCS"))); getCatalog().save(cinfo); Document doc = getAsDOM("wcs?service=WCS&request=getCapabilities"); assertXpathEvaluatesTo( "0", "count( }
Source:
<code>private Runnable getBufferConsumerRunnable() { return new Runnable() { @Override public void run() { while (true) { try { eventsToSend.put(eventBuffer.take()); <START> if (eventsToSend.size() >= bufferSize) { List<TrackerEvent> events = new ArrayList<>(); eventsToSend.drainTo(events); execute(getRequestRunnable(events)); <END> } } catch (InterruptedException ex) { if (isClosing) { return; } } } } }; }</code><technical_language>This block is repeated in flushBuffer. pointing out in case care DRY</technical_language>

Target:
private Runnable getBufferConsumerRunnable() { return new Runnable() { @Override public void run() { while (true) { try { eventsToSend.put(eventBuffer.take()); if (eventsToSend.size() >= bufferSize) { drainBufferAndSend(); } } catch (InterruptedException ex) { if (isClosing) { return; } } } } }; }
Source:
<code>public void resize(final int newMapSize, final double newMapAvgKey) throws IOException { if (newMapSize < 0) { throw new IllegalArgumentException("Cannot resize chronicle map to negative size"); } if (newMapAvgKey < 0) { throw new IllegalArgumentException("Cannot resize chronicle map to map with negative key size"); } Path tempFile = Files.createTempFile("opengrok", "chronicle"); ChronicleMap<BytesRef, Integer> m; try { map.getAll(tempFile.toFile()); String field = map.name(); map.close(); Files.delete(f.toPath()); m = ChronicleMap.of(BytesRef.class, Integer.class) .name(field) .averageKeySize(newMapAvgKey) .entries(newMapSize) .keyReaderAndDataAccess(BytesRefSizedReader.INSTANCE, new BytesRefDataAccess()) .createOrRecoverPersistedTo(f); m.putAll(tempFile.toFile()); } catch (IOException e) { throw e; } finally { Files.delete(tempFile); } <START> map = m; <END> }</code><technical_language>I move this assignment try block. clear this done if exception is thrown</technical_language>

Target:
public void resize(final int newMapSize, final double newMapAvgKey) throws IOException { if (newMapSize < 0) { throw new IllegalArgumentException("Cannot resize chronicle map to negative size"); } if (newMapAvgKey < 0) { throw new IllegalArgumentException("Cannot resize chronicle map to map with negative key size"); } Path tempFile = Files.createTempFile("opengrok", "chronicle"); try { map.getAll(tempFile.toFile()); String field = map.name(); map.close(); Files.delete(chronicleMapFile.toPath()); ChronicleMap<BytesRef, Integer> m = ChronicleMap.of(BytesRef.class, Integer.class) .name(field) .averageKeySize(newMapAvgKey) .entries(newMapSize) .keyReaderAndDataAccess(BytesRefSizedReader.INSTANCE, new BytesRefDataAccess()) .createOrRecoverPersistedTo(chronicleMapFile); m.putAll(tempFile.toFile()); map = m; } finally { Files.delete(tempFile); } }
Source:
<code>public boolean hasRequestType(@NonNull final DocTypeId docTypeId) { <START> return Services.get(IDocTypeDAO.class).getById(docTypeId).getR_RequestType_ID() > 0; <END> }</code><technical_language>extract service a field</technical_language>

Target:
public boolean hasRequestType(@NonNull final DocTypeId docTypeId) { return docTypesRepo.getById(docTypeId).getR_RequestType_ID() > 0; }
Source:
<code>public ExtractionType getExtractionType() { <START> return ExtractionType.ONE_TO_ONE; <END> }</code><technical_language>strictly speaking, this is ONE_TO_ONE e.g. if format string is "just-a-fixed-string"</technical_language>

Target:
public ExtractionType getExtractionType() { return ExtractionType.MANY_TO_ONE; }
Source:
<code>private static void generateTransferSteps(final String namespace, final Collection<EvaluatorSummary> evaluatorSummaries, final PlanImpl.Builder builder) { final PriorityQueue<EvaluatorSummary> senderPriorityQueue = new PriorityQueue<>(evaluatorSummaries.size(), NUM_BLOCKS_TO_MOVE_COMPARATOR); final PriorityQueue<EvaluatorSummary> receiverPriorityQueue = new PriorityQueue<>(evaluatorSummaries.size(), NUM_BLOCKS_TO_MOVE_COMPARATOR); for (final EvaluatorSummary eval : evaluatorSummaries) { if (eval.getNumBlocks() > eval.getNumOptimalBlocks()) { senderPriorityQueue.add(eval); } else if (eval.getNumBlocks() < eval.getNumOptimalBlocks()) { receiverPriorityQueue.add(eval); } } while (!senderPriorityQueue.isEmpty()) { final EvaluatorSummary sender = senderPriorityQueue.poll(); final EvaluatorSummary receiver = receiverPriorityQueue.poll(); final int numToSend = sender.getNumBlocks() - sender.getNumOptimalBlocks(); final int numToReceive = receiver.getNumOptimalBlocks() - receiver.getNumBlocks(); final int numToMove = Math.min(numToSend, numToReceive); if (numToMove == numToSend) { receiver.setNumOptimalBlocks(receiver.getNumOptimalBlocks() - numToMove); receiverPriorityQueue.add(receiver); <START> } else if (numToMove == numToReceive) { <END> sender.setNumOptimalBlocks(sender.getNumOptimalBlocks() + numToMove); senderPriorityQueue.add(sender); } builder.addTransferStep(namespace, new TransferStepImpl(sender.id, receiver.id, new DataInfoImpl(numToMove))); } }</code><technical_language>considering case numToSend == numToReceive for understanding? For now, receiver numToReceive == 0 re-added priority queue this reasoning harder</technical_language>

Target:
private static void generateTransferSteps(final String namespace, final Collection<EvaluatorSummary> evaluatorSummaries, final PlanImpl.Builder builder) { final PriorityQueue<EvaluatorSummary> senderPriorityQueue = new PriorityQueue<>(evaluatorSummaries.size(), NUM_BLOCKS_TO_MOVE_COMPARATOR); final PriorityQueue<EvaluatorSummary> receiverPriorityQueue = new PriorityQueue<>(evaluatorSummaries.size(), NUM_BLOCKS_TO_MOVE_COMPARATOR); for (final EvaluatorSummary eval : evaluatorSummaries) { if (eval.getNumBlocks() > eval.getNumOptimalBlocks()) { senderPriorityQueue.add(eval); } else if (eval.getNumBlocks() < eval.getNumOptimalBlocks()) { receiverPriorityQueue.add(eval); } } while (!senderPriorityQueue.isEmpty()) { final EvaluatorSummary sender = senderPriorityQueue.poll(); final EvaluatorSummary receiver = receiverPriorityQueue.poll(); final int numToSend = sender.getNumBlocks() - sender.getNumOptimalBlocks(); final int numToReceive = receiver.getNumOptimalBlocks() - receiver.getNumBlocks(); final int numToMove = Math.min(numToSend, numToReceive); builder.addTransferStep(namespace, new TransferStepImpl(sender.getId(), receiver.getId(), new DataInfoImpl(numToMove))); if (numToSend == numToReceive) { continue; } else if (numToMove == numToSend) { receiver.setNumBlocks(receiver.getNumBlocks() + numToMove); receiverPriorityQueue.add(receiver); } else { sender.setNumBlocks(sender.getNumBlocks() - numToMove); senderPriorityQueue.add(sender); } } }
Source:
<code>public Map multi(String[] urls, Map options) throws IOException { <START> options.put("urls", urls); <END> return multi(options); }</code><technical_language>check for array size >=1</technical_language>

Target:
public Map multi(String[] urls, Map options) throws IOException { if (options == null) { options = Collections.singletonMap("urls", urls); } else { options.put("urls", urls); } return multi(options); }
Source:
<code>private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } com.esri.core.geometry.Envelope2D extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); <START> return x >= extent.xmin && x < extent.xmax && y >= extent.ymin && y < extent.ymax; <END> }</code><technical_language>Extract this a separate method. Call within</technical_language>

Target:
private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition) { Envelope buildEnvelope = getEnvelope(buildGeometry); Envelope intersection = buildEnvelope.intersection(probeEnvelope); if (intersection.isNull()) { return false; } Rectangle extent = partitions.get(partition); double x = intersection.getMinX(); double y = intersection.getMinY(); return x >= extent.getXMin() && x < extent.getXMax() && y >= extent.getYMin() && y < extent.getYMax(); }
Source:
<code>private void createBoard(List<PanelInfo> panelData, String boardName) { panelControl.closeAllPanels(); FilterPanel panelAdded; <START> for (int i = 0; i < panelData.size(); i++) { <END> panelAdded = panelControl.addPanelAt(i); panelAdded.setPanelName(panelData.get(i).getPanelName()); panelAdded.setFilterByString(panelData.get(i).getPanelFilter()); } panelControl.selectFirstPanel(); triggerBoardSaveEventSequence(boardName); }</code><technical_language>foreach</technical_language>

Target:
private void createBoard(List<PanelInfo> panelData, String boardName) { panelControl.closeAllPanels(); FilterPanel panelAdded; for (PanelInfo panelInfo : panelData) { panelAdded = panelControl.addPanelAt(panelControl.getNumberOfPanels()); panelAdded.setPanelName(panelInfo.getPanelName()); panelAdded.setFilterByString(panelInfo.getPanelFilter()); } panelControl.selectFirstPanel(); triggerBoardSaveEventSequence(boardName); }
Source:
<code>public void addEvent(KeenProject project, String eventCollection, Map<String, Object> event, Map<String, Object> keenProperties, KeenCallback callback) { if (!isActive) { handleLibraryInactive(callback); return; } if (project == null && defaultProject == null) { handleFailure(null, project, eventCollection, event, keenProperties, new IllegalStateException("No project specified, but no default project found")); return; } KeenProject useProject = (project == null ? defaultProject : project); try { if (eventCollection.contains(" ")){ <START> eventCollection = URLEncoder.encode(eventCollection, "UTF-8").replace("+", "%20"); <END> } Map<String, Object> newEvent = validateAndBuildEvent(useProject, eventCollection, event, keenProperties); publish(useProject, eventCollection, newEvent); handleSuccess(callback, project, eventCollection, event, keenProperties); } catch (Exception e) { handleFailure(callback, project, eventCollection, event, keenProperties, e); } }</code><technical_language>a couple issues in this line: 1. AFAICT URLEncoder.encode replace + %2B, .replace("+", "%20") a no-op. 2. Implicitly performing URL encoding *only in case of collection name a space* unintuitive. means if I call this method eventCollection equal %completed submitted Keen %completed if I call method % completed submitted Keen %25%20completed</technical_language>

Target:
public void addEvent(KeenProject project, String eventCollection, Map<String, Object> event, Map<String, Object> keenProperties, KeenCallback callback) { if (!isActive) { handleLibraryInactive(callback); return; } if (project == null && defaultProject == null) { handleFailure(null, project, eventCollection, event, keenProperties, new IllegalStateException("No project specified, but no default project found")); return; } KeenProject useProject = (project == null ? defaultProject : project); try { Map<String, Object> newEvent = validateAndBuildEvent(useProject, eventCollection, event, keenProperties); publish(useProject, eventCollection, newEvent); handleSuccess(callback, project, eventCollection, event, keenProperties); } catch (Exception e) { handleFailure(callback, project, eventCollection, event, keenProperties, e); } }
Source:
<code>public void decompress(ByteBuffer in, int numBytes, ByteBuffer out) { final byte[] bytes = new byte[numBytes]; in.get(bytes); try (final ResourceHolder<byte[]> outputBytesHolder = CompressedPools.getOutputBytes()) { final byte[] outputBytes = outputBytesHolder.get(); <START> final int numDecompressedBytes = lz4Fast.decompress(bytes, 0, outputBytes, 0, outputBytes.length); <END> out.put(outputBytes, 0, numDecompressedBytes); out.flip(); } catch (IOException e) { Throwables.propagate(e); } }</code><technical_language>LZ4FastDecompressor requires size of uncompressed data argument decompress, vs. LZ4SafeDecompressor requires maximum size of output argument, lz4Fast if size of uncompressed data, is case in this method</technical_language>

Target:
public void decompress(ByteBuffer in, int numBytes, ByteBuffer out) { final byte[] bytes = new byte[numBytes]; in.get(bytes); try (final ResourceHolder<byte[]> outputBytesHolder = CompressedPools.getOutputBytes()) { final byte[] outputBytes = outputBytesHolder.get(); final int numDecompressedBytes = lz4Safe.decompress(bytes, outputBytes); out.put(outputBytes, 0, numDecompressedBytes); out.flip(); } catch (IOException e) { log.error(e, "IOException thrown while closing ChunkEncoder."); } }
Source:
<code>private User getUserByEmail(String email) { UserService.Iface client = new ThriftClients().makeUserClient(); User user = null; try { if (!Strings.isNullOrEmpty(email) && client != null) { <START> user = client.getByEmail(email); <END> } } catch (TException e) { user = null; } return user; }</code><technical_language>I prefer returns directly, a matter of preference</technical_language>

Target:
private User getUserByEmail(String email) { UserService.Iface client = new ThriftClients().makeUserClient(); try { if (!Strings.isNullOrEmpty(email) && client != null) { return client.getByEmail(email); } } catch (TException e) { return null; } return null; }
Source:
<code>protected Scan operationScan() { Scan scan; if (getLastReadRow() == null && getStartRow() == null) { scan = new Scan(); } else if (getEndRow() == null) { scan = new Scan(Bytes.toBytes(getLastReadRow() == null ? getStartRow() : getLastReadRow())); } else { scan = new Scan(Bytes.toBytes(getLastReadRow() == null ? getStartRow() : getLastReadRow()), Bytes.toBytes(getEndRow())); } for (HBaseFieldInfo field : tableInfo.getFieldsInfo()) { scan.addColumn(Bytes.toBytes(field.getFamilyName()), Bytes.toBytes(field.getColumnName())); } scan.setAttribute(Scan.HINT_LOOKAHEAD, Bytes.toBytes(getHintScanLookahead())); <START> return scan; <END> }</code><technical_language>reuse scan variable? save connection time for request</technical_language>

Target:
protected Scan operationScan() { if (getLastReadRow() == null && getStartRow() == null) { if (scan == null) { scan = new Scan(); } } else if (getEndRow() == null) { scan.setStartRow(Bytes.toBytes(getLastReadRow() == null ? getStartRow() : getLastReadRow())); } else { scan.setStartRow(Bytes.toBytes(getLastReadRow() == null ? getStartRow() : getLastReadRow())); scan.setStopRow(Bytes.toBytes(getEndRow())); } for (HBaseFieldInfo field : tableInfo.getFieldsInfo()) { scan.addColumn(Bytes.toBytes(field.getFamilyName()), Bytes.toBytes(field.getColumnName())); } scan.setAttribute(Scan.HINT_LOOKAHEAD, Bytes.toBytes(getHintScanLookahead())); return scan; }
Source:
<code>public LStat lstat(FS fs, File file) throws NoSuchFileException, NotDirectoryException { FileMode mode; if (file.isDirectory()) { if (new File(file, Constants.DOT_GIT).isDirectory()) mode = FileMode.GITLINK; else mode = FileMode.TREE; } else if (fs.canExecute(file)) mode = FileMode.EXECUTABLE_FILE; else mode = FileMode.REGULAR_FILE; <START> return new LStat(file.lastModified(), mode, file.length()); <END> }</code><technical_language>this behavior native ENOENT case? file exist: In FSAccessJava returning apparently valid LStat mode REGULAR_FILE, -1 for lastModified file length. In FSAccessNative I throwing NoSuchFileException. Java code needs trap that, it? long sz = file.length(); if (sz < 0) throw new NoSuchFileExeption(file); return new LStat(file.lastModified(), mode, sz);</technical_language>

Target:
public LStat lstat(FS fs, File file) throws NoSuchFileException, NotDirectoryException { FileMode mode; if (file.isDirectory()) { if (new File(file, Constants.DOT_GIT).isDirectory()) mode = FileMode.GITLINK; else mode = FileMode.TREE; } else if (fs.canExecute(file)) mode = FileMode.EXECUTABLE_FILE; else mode = FileMode.REGULAR_FILE; long sz = file.length(); if (sz < 0) throw new NoSuchFileException(file.getAbsolutePath()); return new LStat(file.lastModified(), mode, sz); }
Source:
<code>protected void generateComponent() { testRunSink = (TestRunSink) conf.get(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY); <START> String spoutId = "testRunSinkBolt" + UUID_FOR_COMPONENTS; <END> String spoutClassName = "com.hortonworks.streamline.streams.runtime.storm.testing.TestRunSinkBolt"; List<Object> constructorArgs = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String testRunSourceJson = null; try { testRunSourceJson = mapper.writeValueAsString(testRunSink); } catch (JsonProcessingException e) { log.error("Error creating json config string for TestRunSink", e); } constructorArgs.add(testRunSourceJson); component = createComponent(spoutId, spoutClassName, null, constructorArgs, null); addParallelismToComponent(); }</code><technical_language>Minor. Replace spout bolt applicable</technical_language>

Target:
protected void generateComponent() { testRunSink = (TestRunSink) conf.get(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY); String boltId = "testRunSinkBolt" + UUID_FOR_COMPONENTS; String boltClassName = "com.hortonworks.streamline.streams.runtime.storm.testing.TestRunSinkBolt"; List<Object> constructorArgs = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String testRunSourceJson = null; try { testRunSourceJson = mapper.writeValueAsString(testRunSink); } catch (JsonProcessingException e) { log.error("Error creating json config string for TestRunSink", e); } constructorArgs.add(testRunSourceJson); component = createComponent(boltId, boltClassName, null, constructorArgs, null); addParallelismToComponent(); }