auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void deployAPI(Object serviceImplementation, Dictionary<String, ?> properties) { if (!(serviceImplementation instanceof Microservice)) { <START> throw new UUFException("API class " + serviceImplementation.getClass().getName() + <END> " doesn't implement Microservice interface"); } BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); bundleContext.registerService(Microservice.class, (Microservice) serviceImplementation, properties); }</code><technical_language>change exception message "Cannot deploy REST API {serviceImplementation.getClass().getName()} a micro-service implement {Microservice.class.getName()}"</technical_language>

Target:
public void deployAPI(Object serviceImplementation, Dictionary<String, ?> properties) { if (!(serviceImplementation instanceof Microservice)) { throw new UUFException("Cannot deploy REST API '" + serviceImplementation.getClass().getName() + "' as a micro-service because it does not implement '" + Microservice.class.getName() + "'"); } BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); bundleContext.registerService(Microservice.class, (Microservice) serviceImplementation, properties); }
Source:
<code>public void call(Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { <START> LOG.info("invoking lifecycle action {}", description); <END> method.invoke(obj); }</code><technical_language>info noisy. this debug</technical_language>

Target:
public void call(Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { LOG.debug("invoking lifecycle action {}", description); method.invoke(obj); }
Source:
<code>private void cancelAllUploads() { <START> mQueue.clear(); <END> mCompletedItems.clear(); cancelCurrentUpload(); }</code><technical_language>Please getUploadQueue() instead - mQueue null this in Service code</technical_language>

Target:
private void cancelAllUploads() { mUploadQueue.clear(); cancelCurrentUpload(); }
Source:
<code>private RevObject parseNew(AnyObjectId id, ObjectLoader ldr) throws LargeObjectException, CorruptObjectException, MissingObjectException, IOException { RevObject r; int type = ldr.getType(); switch (type) { case Constants.OBJ_COMMIT: { <START> initializeShallowCommits(); <END> final RevCommit c = createCommit(id); c.parseCanonical(this, getCachedBytes(c, ldr)); r = c; break; } case Constants.OBJ_TREE: { r = new RevTree(id); r.flags |= PARSED; break; } case Constants.OBJ_BLOB: { r = new RevBlob(id); r.flags |= PARSED; break; } case Constants.OBJ_TAG: { final RevTag t = new RevTag(id); t.parseCanonical(this, getCachedBytes(t, ldr)); r = t; break; } default: throw new IllegalArgumentException(MessageFormat.format( JGitText.get().badObjectType, Integer.valueOf(type))); } objects.add(r); return r; }</code><technical_language>This needs rewritten. init created RevCommit, create again. Instead say: RevCommit c; if (initShallow) { c = createCommit(id); } else { initShallow(); c = lookupCommit(id); }</technical_language>

Target:
private RevObject parseNew(AnyObjectId id, ObjectLoader ldr) throws LargeObjectException, CorruptObjectException, MissingObjectException, IOException { RevObject r; int type = ldr.getType(); switch (type) { case Constants.OBJ_COMMIT: { final RevCommit c = createCommit(id); c.parseCanonical(this, getCachedBytes(c, ldr)); r = c; break; } case Constants.OBJ_TREE: { r = new RevTree(id); r.flags |= PARSED; break; } case Constants.OBJ_BLOB: { r = new RevBlob(id); r.flags |= PARSED; break; } case Constants.OBJ_TAG: { final RevTag t = new RevTag(id); t.parseCanonical(this, getCachedBytes(t, ldr)); r = t; break; } default: throw new IllegalArgumentException(MessageFormat.format( JGitText.get().badObjectType, Integer.valueOf(type))); } objects.add(r); return r; }
Source:
<code>private static DegraderTrackerClient createDegraderTrackerClient(URI uri, UriProperties uriProperties, ServiceProperties serviceProperties, String loadBalancerStrategyName, TransportClient transportClient, Clock clock) { DegraderImpl.Config config = null; if (serviceProperties.getLoadBalancerStrategyProperties() != null) { Map<String, Object> loadBalancerStrategyProperties = serviceProperties.getLoadBalancerStrategyProperties(); clock = MapUtil.getWithDefault(loadBalancerStrategyProperties, PropertyKeys.CLOCK, clock, Clock.class); } if (serviceProperties.getDegraderProperties() != null && !serviceProperties.getDegraderProperties().isEmpty()) { config = DegraderConfigFactory.toDegraderConfig(serviceProperties.getDegraderProperties()); <START> config.setLogger(new RateLimitedLogger(LOG, LOG_RATE_MS, clock)); <END> } long trackerClientInterval = getInterval(loadBalancerStrategyName, serviceProperties); Pattern errorStatusPattern = getErrorStatusPattern(loadBalancerStrategyName, serviceProperties); return new DegraderTrackerClient(uri, uriProperties.getPartitionDataMap(uri), transportClient, clock, config, trackerClientInterval, errorStatusPattern, uriProperties.getUriSpecificProperties().get(uri)); }</code><technical_language>Do want rateLimit logging? message 20s hide important info..</technical_language>

Target:
private static DegraderTrackerClient createDegraderTrackerClient(URI uri, UriProperties uriProperties, ServiceProperties serviceProperties, String loadBalancerStrategyName, TransportClient transportClient, Clock clock) { DegraderImpl.Config config = null; if (serviceProperties.getLoadBalancerStrategyProperties() != null) { Map<String, Object> loadBalancerStrategyProperties = serviceProperties.getLoadBalancerStrategyProperties(); clock = MapUtil.getWithDefault(loadBalancerStrategyProperties, PropertyKeys.CLOCK, clock, Clock.class); } if (serviceProperties.getDegraderProperties() != null && !serviceProperties.getDegraderProperties().isEmpty()) { config = DegraderConfigFactory.toDegraderConfig(serviceProperties.getDegraderProperties()); config.setLogger(new RateLimitedLogger(LOG, LOG_RATE_MS, clock)); } long trackerClientInterval = getInterval(loadBalancerStrategyName, serviceProperties); Pattern errorStatusPattern = getErrorStatusPattern(loadBalancerStrategyName, serviceProperties); return new DegraderTrackerClientImpl(uri, uriProperties.getPartitionDataMap(uri), transportClient, clock, config, trackerClientInterval, errorStatusPattern, uriProperties.getUriSpecificProperties().get(uri)); }
Source:
<code><START> public StreamProcessor(Config config, Map<String, MetricsReporter> customMetricsReporters, TaskFactory taskFactory, <END> ProcessorLifecycleListener processorListener, JobCoordinator jobCoordinator) { Preconditions.checkNotNull(processorListener, "ProcessorListener cannot be null."); this.taskFactory = taskFactory; this.config = config; this.taskShutdownMs = new TaskConfigJava(config).getShutdownMs(); this.processorListener = processorListener; this.customMetricsReporter = customMetricsReporters; this.jobCoordinator = (jobCoordinator != null) ? jobCoordinator : createJobCoordinator(); this.jobCoordinatorListener = createJobCoordinatorListener(); this.jobCoordinator.setListener(jobCoordinatorListener); ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(CONTAINER_THREAD_NAME_FORMAT).setDaemon(true).build(); this.executorService = Executors.newSingleThreadExecutor(threadFactory); this.processorId = this.jobCoordinator.getProcessorId(); }</code><technical_language>Is this for low-level? odd a constructor takes a ProcessorLifecycleListener another takes a factory create listener</technical_language>

Target:
public StreamProcessor(Config config, Map<String, MetricsReporter> customMetricsReporters, TaskFactory taskFactory, ProcessorLifecycleListener processorListener, JobCoordinator jobCoordinator) { this(config, customMetricsReporters, taskFactory, sp -> processorListener, jobCoordinator); }
Source:
<code>public void testListStatusACL() throws IOException, URISyntaxException { String testfilename = "testFileACL"; String childDirectoryName = "testDirectoryACL"; TEST_DIR.mkdirs(); File infile = new File(TEST_DIR, testfilename); final byte[] content = "dingos".getBytes(); try (FileOutputStream fos = new FileOutputStream(infile)) { fos.write(content); } assertEquals((long)content.length, infile.length()); File childDir = new File(TEST_DIR, childDirectoryName); childDir.mkdirs(); Configuration conf = new Configuration(); ConfigUtil.addLink(conf, "/file", infile.toURI()); ConfigUtil.addLink(conf, "/dir", childDir.toURI()); try (FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf)) { assertEquals(ViewFileSystem.class, vfs.getClass()); FileStatus[] statuses = vfs.listStatus(new Path("/")); FileSystem localFs = FileSystem.getLocal(conf); FileStatus fileStat = localFs.getFileStatus(new Path(infile.getPath())); FileStatus dirStat = localFs.getFileStatus(new Path(childDir.getPath())); for (FileStatus status : statuses) { if (status.getPath().getName().equals("file")) { assertEquals(fileStat.getPermission(), status.getPermission()); } else { assertEquals(dirStat.getPermission(), status.getPermission()); } } <START> } <END> }</code><technical_language>change permission target assert changed permissions simply link permissions</technical_language>

Target:
public void testListStatusACL() throws IOException { String testfilename = "testFileACL"; String childDirectoryName = "testDirectoryACL"; TEST_DIR.mkdirs(); File infile = new File(TEST_DIR, testfilename); final byte[] content = "dingos".getBytes(); try (FileOutputStream fos = new FileOutputStream(infile)) { fos.write(content); } assertEquals(content.length, infile.length()); File childDir = new File(TEST_DIR, childDirectoryName); childDir.mkdirs(); Configuration conf = new Configuration(); ConfigUtil.addLink(conf, "/file", infile.toURI()); ConfigUtil.addLink(conf, "/dir", childDir.toURI()); try (FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf)) { assertEquals(ViewFileSystem.class, vfs.getClass()); FileStatus[] statuses = vfs.listStatus(new Path("/")); FileSystem localFs = FileSystem.getLocal(conf); FileStatus fileStat = localFs.getFileStatus(new Path(infile.getPath())); FileStatus dirStat = localFs.getFileStatus(new Path(childDir.getPath())); for (FileStatus status : statuses) { if (status.getPath().getName().equals("file")) { assertEquals(fileStat.getPermission(), status.getPermission()); } else { assertEquals(dirStat.getPermission(), status.getPermission()); } } localFs.setPermission(new Path(infile.getPath()), FsPermission.valueOf("-rwxr--r--")); localFs.setPermission(new Path(childDir.getPath()), FsPermission.valueOf("-r--rwxr--")); statuses = vfs.listStatus(new Path("/")); for (FileStatus status : statuses) { if (status.getPath().getName().equals("file")) { assertEquals(FsPermission.valueOf("-rwxr--r--"), status.getPermission()); } else { assertEquals(FsPermission.valueOf("-r--rwxr--"), status.getPermission()); } } } }
Source:
<code>public static byte[] serializeEntry(KeystorePasswordStore.Entry entry) { byte[] className = entry.getClassName().getBytes(StandardCharsets.UTF_8); <START> ByteBuffer b = ByteBuffer.allocate(8 + className.length + entry.getPayload().length ); <END> b.putInt(entry.getVersion()); b.putInt(className.length); b.put(className); b.put(entry.getPayload()); return b.array(); }</code><technical_language>ByteStringBuilder here</technical_language>

Target:
public static byte[] serializeEntry(KeystorePasswordStore.Entry entry) { byte[] className = entry.getClassName().getBytes(StandardCharsets.UTF_8); ByteStringBuilder b = new ByteStringBuilder(); b.appendBE(entry.getVersion()); b.appendBE(className.length); b.append(className); b.append(entry.getPayload()); return b.toArray(); }
Source:
<code>public void setData( String key, Object value ) { <START> if( RWT.BADGE.equals( key ) && ( style & ( SWT.SEPARATOR | SWT.DROP_DOWN ) ) != 0 ) { <END> return; } else if( RWT.TOOLTIP_MARKUP_ENABLED.equals( key ) && isToolTipMarkupEnabledFor( this ) ) { return; } super.setData( key, value ); }</code><technical_language>I support push items</technical_language>

Target:
public void setData( String key, Object value ) { if( RWT.BADGE.equals( key ) && ( style & SWT.PUSH ) == 0 ) { return; } else if( RWT.TOOLTIP_MARKUP_ENABLED.equals( key ) && isToolTipMarkupEnabledFor( this ) ) { return; } super.setData( key, value ); }
Source:
<code>void checkAvailableResources() { int tries = 0; Throwable lastThrowable = null; while (tries < maxDBTries) { try { if (!RMStorageFactory.hasResources(databaseResourcesThreshold)) { <START> throw new IOException("not enoug resources in the database"); <END> } } catch (StorageException e) { LOG.warn("StorageException in checkAvailableResources (" + tries + "/" + maxDBTries + ").", e); if (e instanceof TransientStorageException) { LOG.debug("transiant exception"); continue; } lastThrowable = e; tries++; try { Thread.sleep(500); } catch (InterruptedException ex) { } } catch (Throwable t) { LOG.error("Runtime exception in checkAvailableResources. ", t); lastThrowable = t; tries++; try { Thread.sleep(500); } catch (InterruptedException ex) { } } } if (tries >= maxDBTries) { terminate(1, lastThrowable); } }</code><technical_language>Typo</technical_language>

Target:
void checkAvailableResources() { int tries = 0; Throwable lastThrowable = null; while (tries < maxDBTries) { try { if (!RMStorageFactory.hasResources(databaseResourcesThreshold)) { throw new IOException("not enough resources in the database"); } } catch (StorageException e) { LOG.warn("StorageException in checkAvailableResources (" + tries + "/" + maxDBTries + ").", e); if (e instanceof TransientStorageException) { LOG.debug("transiant exception"); continue; } lastThrowable = e; tries++; try { Thread.sleep(500); } catch (InterruptedException ex) { } } catch (Throwable t) { LOG.error("Runtime exception in checkAvailableResources. ", t); lastThrowable = t; tries++; try { Thread.sleep(500); } catch (InterruptedException ex) { } } } if (tries >= maxDBTries) { terminate(1, lastThrowable); } }
Source:
<code>private static String stripIndentAndTrailingWhitespaceFromLine(String line, int indent) { final int lastNonWhitespace = lastIndexOfNonWhitespace(line); String returnString = ""; if (lastNonWhitespace > 0) { <START> final int firstNonWhitespace = indexOfNonWhitespace(line); <END> final int incidentalWhitespace = Math.min(indent, firstNonWhitespace); returnString = line.substring(incidentalWhitespace, lastNonWhitespace); } return returnString; }</code><technical_language>else return ""'; compiler threats whitespace-only lines empty: static String str = """ foo"""; System.out.println("'" + str + "'"); (there is 10 spaces in line 2) ' foo'</technical_language>

Target:
private static String stripIndentAndTrailingWhitespaceFromLine(String line, int indent) { final int lastNonWhitespace = lastIndexOfNonWhitespace(line); String returnString = ""; if (lastNonWhitespace > 0) { returnString = line.substring(indent, lastNonWhitespace); } return returnString; }
Source:
<code>public <T> boolean cache(String key, String field, T value) { <START> RedisConnection<byte[], byte[]> redisCommands = null; <END> try { redisCommands = getRedisConnection(); byte[] serializedValues = new JavaSerializer().serializeObject(value); redisCommands.hset(key.getBytes(), field.getBytes(), serializedValues); return true; } catch (Exception e) { logger.error("Exception Occurred while caching a value in redis", e); } finally { closeConnection(redisCommands); } return false; }</code><technical_language>a good habit validate instanceof Serializable throw IllegalArgumentException early</technical_language>

Target:
public <T extends Serializable> boolean cache(String key, String field, T value) { RedisConnection<byte[], byte[]> redisCommands = null; try { redisCommands = getRedisConnection(); byte[] serializedValues = codec.serializeObject(value); return redisCommands.hset(key.getBytes(), field.getBytes(), serializedValues); } finally { closeConnection(redisCommands); } }
Source:
<code>public String getFeedId() { if (code != null && code.length() > 0) { <START> return code.substring(0, code.indexOf(':')); <END> } return route.getId().getAgencyId(); }</code><technical_language>if code is non-empty, a ':' character</technical_language>

Target:
public String getFeedId() { return route.getId().getAgencyId(); }
Source:
<code>public void getTaskDataStateByMultipleThreads() throws Exception { File file = newTaskDataZipFile(); <START> List<Throwable> failures = runThreads(store -> store.getTaskDataState(file)); <END> assertNoFailures(failures); }</code><technical_language>this is testing. a test concurrent reads writes. If reads, fail</technical_language>

Target:
public void getTaskDataStateByMultipleThreads() throws Exception { File file = newTaskDataZipFile(); List<Throwable> failures = runSameByMultipleThreads(store -> store.getTaskDataState(file)); assertNoFailures(failures); }
Source:
<code>private void removeTab(JediTermWidget terminal) { synchronized (myLock) { if (myTabs != null) { <START> synchronized (ProcessCache.class) { <END> myTabs.remove(terminal); } if(mySettingsProvider.jobNameAsTabName()) { ProcessCache.getInstance().removePid(terminal.getTtyConnector().getTtyPid()); if (myTabs != null){ for (int i = 0; i < myTabs.getTabCount(); i++) { final int ind = i; ProcessCache.getInstance().addPid( myTabs.getComponentAt(i).getTtyConnector().getTtyPid(), new ProcessCache.TabNameChanger() { int index = ind; @Override public void changeName(String name) { myTabs.setTitleAt(index, name); } }); } } } } onSessionChanged(); } }</code><technical_language>is purpose of this synchronization</technical_language>

Target:
private void removeTab(JediTermWidget terminal) { synchronized (myLock) { if (myTabs != null) { myTabs.remove(terminal); } onSessionChanged(); } }
Source:
<code>public boolean isNoexcept(boolean inCalledContext) { if (isConstantExpression()) return true; ICPPFunction overload = getOverload(); if (overload != null) { ICPPASTFunctionDeclarator decl = FunctionHelpers.findDeclarator(overload); if (decl.getNoexceptExpression() == null) return false; } <START> return fArgument.isNoexcept(inCalledContext); <END> }</code><technical_language>If fOperator is op_throw, need return true :)</technical_language>

Target:
public boolean isNoexcept(boolean inCalledContext) { if (fOperator == op_throw) return false; ICPPFunction overload = getOverload(); if (overload != null) { return EvalUtil.evaluateNoexceptSpecifier(overload.getType().getNoexceptSpecifier()); } return fArgument.isNoexcept(inCalledContext); }
Source:
<code><START> @VisibleForTesting <END> public void putIdForLanguage(@NonNull String code, int id) { ids.put(code, id); }</code><technical_language>This @VisibleForTesting WikipediaApp requires this method public UserTest requires package privacy</technical_language>

Target:
public void putIdForLanguage(@NonNull String code, int id) { ids.put(code, id); }
Source:
<code>public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) throws CoreException, RefactoringException { LOG.info( "createRenameRefactoring started in " + System.currentTimeMillis() + " ms with " <START> + settings.toString()); <END> IJavaProject javaProject = model.getJavaProject(settings.getProjectPath()); IJavaElement elementToRename; ICompilationUnit cu = null; switch (settings.getType()) { case COMPILATION_UNIT: elementToRename = javaProject.findType(settings.getPath()).getCompilationUnit(); break; case PACKAGE: elementToRename = javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(settings.getPath())); break; case JAVA_ELEMENT: cu = javaProject.findType(settings.getPath()).getCompilationUnit(); elementToRename = getSelectionElement(cu, settings.getOffset()); break; default: elementToRename = null; } if (elementToRename == null) { LOG.error( "createRenameRefactoring fail in " + System.currentTimeMillis() + " ms with RefactoringException: Can't find java element to rename. "); throw new RefactoringException("Can't find java element to rename."); } RenameRefactoringSession renameRefactoring = manager.createRenameRefactoring( elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight()); LOG.info( "createRenameRefactoring finished in " + System.currentTimeMillis() + " ms with " + renameRefactoring.toString()); return renameRefactoring; }</code><technical_language><LINK_0></technical_language>

Target:
public RenameRefactoringSession createRenameRefactoring(CreateRenameRefactoring settings) throws CoreException, RefactoringException { IJavaProject javaProject = model.getJavaProject(settings.getProjectPath()); IJavaElement elementToRename; ICompilationUnit cu = null; switch (settings.getType()) { case COMPILATION_UNIT: elementToRename = javaProject.findType(settings.getPath()).getCompilationUnit(); break; case PACKAGE: elementToRename = javaProject.findPackageFragment(new org.eclipse.core.runtime.Path(settings.getPath())); break; case JAVA_ELEMENT: cu = javaProject.findType(settings.getPath()).getCompilationUnit(); elementToRename = getSelectionElement(cu, settings.getOffset()); break; default: elementToRename = null; } if (elementToRename == null) { throw new RefactoringException("Can't find java element to rename."); } return manager.createRenameRefactoring( elementToRename, cu, settings.getOffset(), settings.isRefactorLightweight()); }
Source:
<code>private void getNestedColsFromExprNodeDesc( ExprNodeDesc desc, String pathToRoot, List<String> paths) { if (desc instanceof ExprNodeColumnDesc) { String f = ((ExprNodeColumnDesc) desc).getColumn(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; paths.add(p); } else if (desc instanceof ExprNodeGenericFuncDesc) { List<ExprNodeDesc> children = desc.getChildren(); if (children == null || children.isEmpty()) { return; } for (ExprNodeDesc c : children) { getNestedColsFromExprNodeDesc(c, pathToRoot, paths); } <START> } else if (desc instanceof ExprNodeConstantDesc) { <END> return; } else if (desc instanceof ExprNodeColumnListDesc) { } else if (desc instanceof ExprNodeFieldDesc) { String f = ((ExprNodeFieldDesc) desc).getFieldName(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; getNestedColsFromExprNodeDesc(((ExprNodeFieldDesc) desc).getDesc(), p, paths); } }</code><technical_language>cases needed. about: if (desc instanceof ExprNodeColumnDesc) { String f = ((ExprNodeColumnDesc) desc).getColumn(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; paths.add(p); } else if (desc instanceof ExprNodeFieldDesc) { String f = ((ExprNodeFieldDesc) desc).getFieldName(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; getNestedColsFromExprNodeDesc(((ExprNodeFieldDesc) desc).getDesc(), p, paths); } else { List<ExprNodeDesc> children = desc.getChildren(); if (children == null) { return; } for (ExprNodeDesc c : children) { getNestedColsFromExprNodeDesc(c, pathToRoot, paths); } }</technical_language>

Target:
private void getNestedColsFromExprNodeDesc( ExprNodeDesc desc, String pathToRoot, List<String> paths) { if (desc instanceof ExprNodeColumnDesc) { String f = ((ExprNodeColumnDesc) desc).getColumn(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; paths.add(p); } else if (desc instanceof ExprNodeFieldDesc) { String f = ((ExprNodeFieldDesc) desc).getFieldName(); String p = pathToRoot.isEmpty() ? f : f + "." + pathToRoot; getNestedColsFromExprNodeDesc(((ExprNodeFieldDesc) desc).getDesc(), p, paths); } else { List<ExprNodeDesc> children = desc.getChildren(); if (children == null || children.isEmpty()) { return; } for (ExprNodeDesc c : children) { getNestedColsFromExprNodeDesc(c, pathToRoot, paths); } } }
Source:
<code>public Trigger atPayload(final Map payload) { return this.toBuilder() <START> .buildNumber(null) <END> .hash(null) .digest(null) .payload(payload) .build(); }</code><technical_language>set necessary fields? This delete stuff especially chained together</technical_language>

Target:
public Trigger atPayload(final Map payload) { return this.toBuilder() .payload(payload) .build(); }
Source:
<code>public void testAddSourceFinish() { PlanNodeId sourceId = new PlanNodeId("source"); final List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT); TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(99, new PlanNodeId("test"), "values"), sourceId, new PageSourceProvider() { @Override public ConnectorPageSource createPageSource(Session session, Split split, TableHandle table, List<ColumnHandle> columns) { return new FixedPageSource(rowPagesBuilder(types) .addSequencePage(10, 20, 30, 40) .build()); } }, <START> new TableHandle( <END> new ConnectorId("test"), new ConnectorTableHandle() {}, new ConnectorTransactionHandle() {}, Optional.empty()), ImmutableList.of()); PageConsumerOperator sink = createSinkOperator(types); Driver driver = Driver.createDriver(driverContext, source, sink); assertSame(driver.getDriverContext(), driverContext); assertFalse(driver.isFinished()); assertFalse(driver.processFor(new Duration(1, TimeUnit.MILLISECONDS)).isDone()); assertFalse(driver.isFinished()); driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, newMockSplit())), true)); assertFalse(driver.isFinished()); assertTrue(driver.processFor(new Duration(1, TimeUnit.SECONDS)).isDone()); assertTrue(driver.isFinished()); assertTrue(sink.isFinished()); assertTrue(source.isFinished()); }</code><technical_language>nit: extract this a private constant, e.g.: TESTING_TABLE_HANDLE</technical_language>

Target:
public void testAddSourceFinish() { PlanNodeId sourceId = new PlanNodeId("source"); final List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT); TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(99, new PlanNodeId("test"), "values"), sourceId, new PageSourceProvider() { @Override public ConnectorPageSource createPageSource(Session session, Split split, TableHandle table, List<ColumnHandle> columns) { return new FixedPageSource(rowPagesBuilder(types) .addSequencePage(10, 20, 30, 40) .build()); } }, TESTING_TABLE_HANDLE, ImmutableList.of()); PageConsumerOperator sink = createSinkOperator(types); Driver driver = Driver.createDriver(driverContext, source, sink); assertSame(driver.getDriverContext(), driverContext); assertFalse(driver.isFinished()); assertFalse(driver.processFor(new Duration(1, TimeUnit.MILLISECONDS)).isDone()); assertFalse(driver.isFinished()); driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, newMockSplit())), true)); assertFalse(driver.isFinished()); assertTrue(driver.processFor(new Duration(1, TimeUnit.SECONDS)).isDone()); assertTrue(driver.isFinished()); assertTrue(sink.isFinished()); assertTrue(source.isFinished()); }
Source:
<code>private static void runOnce(Context context, ClosableIterator<RowResult<Value>> iter) { Multimap<Cell, Value> batchToCreate = ArrayListMultimap.create(); Multimap<Cell, Long> batchToDelete = ArrayListMultimap.create(); while (iter.hasNext()) { RowResult<Value> rowResult = iter.next(); byte[] row = rowResult.getRowName(); for (Entry<byte[], Value> entry : rowResult.getColumns().entrySet()) { byte[] col = entry.getKey(); Value value = entry.getValue(); long timestamp = value.getTimestamp(); String[] tableNames = StringUtils.split( <START> PtBytes.toString(value.getContents()), '\0'); <END> for (String tableName : tableNames) { byte[] tableBytes = EncodingUtils.encodeVarString(tableName); byte[] newCol = EncodingUtils.add(tableBytes, col); Cell newCell = Cell.create(row, newCol); batchToCreate.put(newCell, Value.create(EMPTY_CONTENTS, timestamp)); } batchToDelete.put(Cell.create(row, col), timestamp); if (batchToDelete.size() >= context.batchSize) { flush(context, batchToCreate, batchToDelete); } } } if (!batchToDelete.isEmpty()) { flush(context, batchToCreate, batchToDelete); } }</code><technical_language>'\0' AtlasDBConstants. SCRUB_TABLE_SEPARATOR_CHAR. Lets delete it, rename OLD_SCRUB_TABLE_SEPARATOR_CHAR</technical_language>

Target:
private static void runOnce(Context context, ClosableIterator<RowResult<Value>> iter) { Multimap<Cell, Value> batchToCreate = ArrayListMultimap.create(); Multimap<Cell, Long> batchToDelete = ArrayListMultimap.create(); while (iter.hasNext()) { RowResult<Value> rowResult = iter.next(); byte[] row = rowResult.getRowName(); for (Entry<byte[], Value> entry : rowResult.getColumns().entrySet()) { byte[] col = entry.getKey(); Value value = entry.getValue(); long timestamp = value.getTimestamp(); String[] tableNames = StringUtils.split( PtBytes.toString(value.getContents()), AtlasDbConstants.OLD_SCRUB_TABLE_SEPARATOR_CHAR); for (String tableName : tableNames) { byte[] tableBytes = EncodingUtils.encodeVarString(tableName); byte[] newCol = EncodingUtils.add(tableBytes, col); Cell newCell = Cell.create(row, newCol); batchToCreate.put(newCell, Value.create(DUMMY_CONTENTS, timestamp)); } batchToDelete.put(Cell.create(row, col), timestamp); if (batchToDelete.size() >= context.batchSize) { flush(context, batchToCreate, batchToDelete); } } } if (!batchToDelete.isEmpty()) { flush(context, batchToCreate, batchToDelete); } }
Source:
<code>boolean updateNewAndRestoringTasks() { <START> Utils.sleep(10); <END> active.initializeNewTasks(); standby.initializeNewTasks(); final Collection<TopicPartition> restored = changelogReader.restore(active); active.updateRestored(restored); if (active.allTasksRunning() && standby.allTasksRunning()) { final Set<TopicPartition> assignment = consumer.assignment(); log.trace("Resuming partitions {}", assignment); consumer.resume(assignment); assignStandbyPartitions(); return true; } return false; }</code><technical_language>This out. StreamThread runOnce method state is PARTITIONS_ASSIGNED StreamThread calls taskManager.updateNewAndRestoringTasks(). If lock is held another thread cleaning this call return false state transition running. In next iteration of runOnce() StreamThread attempt operation state set RUNNING</technical_language>

Target:
boolean updateNewAndRestoringTasks() { active.initializeNewTasks(); standby.initializeNewTasks(); final Collection<TopicPartition> restored = changelogReader.restore(active); active.updateRestored(restored); if (active.allTasksRunning()) { final Set<TopicPartition> assignment = consumer.assignment(); log.trace("Resuming partitions {}", assignment); consumer.resume(assignment); assignStandbyPartitions(); return standby.allTasksRunning(); } return false; }
Source:
<code>public static int getShortestIndexLength(List<String> indices) { String initialValue = "REALLY_LONG_VALUE_THAT_WILL_SURELY_GET_REPLACED_BUT_HERE_ARE_SOME_MORE_CHARACTERS_JUST_IN_CASE"; <START> String shortestIndex = indices.stream() <END> .reduce(initialValue, (shortest, current) -> { if (current != null && current.length() > 0 && current.length() < shortest.length()) return current; return shortest; }); if (shortestIndex == null || initialValue.equals(shortestIndex)) return 0; return shortestIndex.length(); }</code><technical_language>do indicies.stream().filter(Objects::nonNull).mapToInt(String::length).min().getAsInt()</technical_language>

Target:
private static int getShortestIndexLength(List<String> indices) { try { int shortestIndex = indices.stream().filter(Objects::nonNull) .mapToInt(String::length).min().getAsInt(); if (shortestIndex == 0) return 0; return shortestIndex; } catch (NoSuchElementException e) { return 0; } }
Source:
<code>public void listSecretVersions(String projectId, String secretId) throws IOException { try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) { SecretName parent = SecretName.of(projectId, secretId); ListSecretVersionsRequest request = ListSecretVersionsRequest.newBuilder().setParent(parent.toString()).build(); <START> ListSecretVersionsPagedResponse iterator = client.listSecretVersions(request); <END> for (SecretVersion version : iterator.iterateAll()) { System.out.printf("Secret version %s, %s\n", version.getName(), version.getState()); } } }</code><technical_language>nit: suggestion ListSecretVersionsPagedResponse pagedResonse = client.listSecretVersions(request);</technical_language>

Target:
public void listSecretVersions(String projectId, String secretId) throws IOException { try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) { SecretName parent = SecretName.of(projectId, secretId); ListSecretVersionsRequest request = ListSecretVersionsRequest.newBuilder().setParent(parent.toString()).build(); ListSecretVersionsPagedResponse pagedResponse = client.listSecretVersions(request); pagedResponse .iterateAll() .forEach( version -> { System.out.printf("Secret version %s, %s\n", version.getName(), version.getState()); }); } }
Source:
<code>public IStatus validate(Object[] selection) { String errorMessage = ""; <START> if (selection.length == 0) { <END> errorMessage = NO_SELECTION; } else { final Object firstSelection = selection[0]; if (selection.length != 1 || false == firstSelection instanceof Property || (firstSelection instanceof Property && false == ((Property) firstSelection).getType() instanceof PrimitiveType)) { errorMessage = Messages.SinglePropertyAttributeValidator_errorMessage; } } return buildIStatus(errorMessage); }</code><technical_language>notice: preferable manage comparison '<=' instead of '=='</technical_language>

Target:
public IStatus validate(Object[] selection) { String errorMessage = ""; if (selection.length <= 0) { errorMessage = NO_SELECTION; } else { final Object firstSelection = selection[0]; if (selection.length != 1 || false == firstSelection instanceof Property || (firstSelection instanceof Property && false == ((Property) firstSelection).getType() instanceof PrimitiveType)) { errorMessage = Messages.SinglePropertyAttributeValidator_errorMessage; } } return buildIStatus(errorMessage); }
Source:
<code>public Date getUpdatedAt() { return updatedAt; <START> } <END></code><technical_language>Is a reason for variables public getters</technical_language>

Target:
public Date getUpdatedAt() { return (updatedAt == null) ? Const.TIME_REPRESENTS_DEFAULT_TIMESTAMP : updatedAt; }
Source:
<code>public DefaultExecutionTopology(ExecutionGraph graph) { this.executionGraph = checkNotNull(graph, "execution graph can not be null"); this.executionVerticesById = new HashMap<>(); this.executionVerticesList = new ArrayList<>(graph.getTotalNumberOfVertices()); Map<IntermediateResultPartitionID, DefaultResultPartition> tmpResultPartitionsById = new HashMap<>(); Map<ExecutionVertex, DefaultExecutionVertex> executionVertexMap = new HashMap<>(); for (ExecutionVertex vertex : graph.getAllExecutionVertices()) { List<DefaultResultPartition> producedPartitions = generateProducedSchedulingResultPartition(vertex.getProducedPartitions()); producedPartitions.forEach(partition -> tmpResultPartitionsById.put(partition.getId(), partition)); DefaultExecutionVertex schedulingVertex = generateSchedulingExecutionVertex(vertex, producedPartitions); this.executionVerticesById.put(schedulingVertex.getId(), schedulingVertex); this.executionVerticesList.add(schedulingVertex); executionVertexMap.put(vertex, schedulingVertex); } this.resultPartitionsById = tmpResultPartitionsById; connectVerticesToConsumedPartitions(executionVertexMap, tmpResultPartitionsById); this.pipelinedRegionsByVertex = new HashMap<>(); this.pipelinedRegions = new ArrayList<>(); initializePipelinedRegions(); <START> ensureCoLocatedVerticesInSameRegion(); <END> }</code><technical_language>a side note for this PR: I put initializePipelinedRegions ensureCoLocatedVerticesInSameRegion a factory method fromExecutionGraph</technical_language>

Target:
private DefaultExecutionTopology(ExecutionGraph graph) { checkNotNull(graph, "execution graph can not be null"); this.executionVerticesById = new HashMap<>(); this.executionVerticesList = new ArrayList<>(graph.getTotalNumberOfVertices()); Map<IntermediateResultPartitionID, DefaultResultPartition> tmpResultPartitionsById = new HashMap<>(); Map<ExecutionVertex, DefaultExecutionVertex> executionVertexMap = new HashMap<>(); for (ExecutionVertex vertex : graph.getAllExecutionVertices()) { List<DefaultResultPartition> producedPartitions = generateProducedSchedulingResultPartition(vertex.getProducedPartitions()); producedPartitions.forEach(partition -> tmpResultPartitionsById.put(partition.getId(), partition)); DefaultExecutionVertex schedulingVertex = generateSchedulingExecutionVertex(vertex, producedPartitions); this.executionVerticesById.put(schedulingVertex.getId(), schedulingVertex); this.executionVerticesList.add(schedulingVertex); executionVertexMap.put(vertex, schedulingVertex); } this.resultPartitionsById = tmpResultPartitionsById; connectVerticesToConsumedPartitions(executionVertexMap, tmpResultPartitionsById); }
Source:
<code>private KeyProvider toKeyProvider(DwrfProto.Encryption.KeyProvider keyProvider) { <START> switch (keyProvider) { <END> case CRYPTO_SERVICE: return KeyProvider.CRYPTO_SERVICE; default: return KeyProvider.UNKNOWN; } }</code><technical_language>UNKNOWN is basically a stub for anything. For example, test, write a file some fake key provider, set unknown. long reader key provider, is able read file making fake provider actual provider in proto</technical_language>

Target:
private static KeyProvider toKeyProvider(DwrfProto.Encryption.KeyProvider keyProvider) { switch (keyProvider) { case CRYPTO_SERVICE: return KeyProvider.CRYPTO_SERVICE; default: return KeyProvider.UNKNOWN; } }
Source:
<code>public IGerritHudsonTriggerConfig getConfig(String serverName) { <START> return PluginImpl.getInstance().getServer(serverName).getConfig(); <END> }</code><technical_language>NPE</technical_language>

Target:
public IGerritHudsonTriggerConfig getConfig(String serverName) { GerritServer server = PluginImpl.getInstance().getServer(serverName); if (server != null) { return server.getConfig(); } else { logger.error("Could not find the Gerrit Server: {}", serverName); } return null; }
Source:
<code>public void emitResult(Tuple2<byte[], Integer> resultTuple) throws Exception { byte[] udafResult = resultTuple.f0; int length = resultTuple.f1; bais.setBuffer(udafResult, 0, length); int rowCount = arrowSerializer.load(); for (int i = 0; i < rowCount; i++) { <START> RowData input = forwardedInputQueue.poll(); <END> reuseJoinedRow.setRowKind(input.getRowKind()); RowData data = arrowSerializer.read(i); rowDataWrapper.collect(reuseJoinedRow.replace(input, data)); } }</code><technical_language>suggestion RowData key = forwardedInputQueue.poll();</technical_language>

Target:
public void emitResult(Tuple2<byte[], Integer> resultTuple) throws Exception { byte[] udafResult = resultTuple.f0; int length = resultTuple.f1; bais.setBuffer(udafResult, 0, length); int rowCount = arrowSerializer.load(); for (int i = 0; i < rowCount; i++) { RowData key = forwardedInputQueue.poll(); reuseJoinedRow.setRowKind(key.getRowKind()); RowData result = arrowSerializer.read(i); rowDataWrapper.collect(reuseJoinedRow.replace(key, result)); } }
Source:
<code>public static Date parseDateString(String datetime) throws ParseException { Date result; try { result = new SimpleDateFormat(MarketoConstants.DATETIME_PATTERN_PARAM).parse(datetime); return result; <START> } catch (ParseException e) { <END> } try { result = new SimpleDateFormat(MarketoConstants.DATETIME_PATTERN_PARAM_ALT).parse(datetime); return result; } catch (ParseException e) { } try { result = new SimpleDateFormat(MarketoConstants.DATETIME_PATTERN_PARAM_UTC).parse(datetime); return result; } catch (ParseException e) { } try { result = new SimpleDateFormat(MarketoConstants.DATETIME_PATTERN_REST).parse(datetime); return result; } catch (ParseException e) { } try { result = new SimpleDateFormat(MarketoConstants.DATETIME_PATTERN_SOAP).parse(datetime); return result; } catch (ParseException e) { } throw new ParseException(datetime + " don't use a pattern allowed.", 0); }</code><technical_language>managed exceptions ? Edit: exception management is done end. this : - SimpleDateFormat instanciated (they times) - return statement - method more concise understandable parseDateString(...){ result = null; for(SimpleDateFormat sdf : sdf_list){ // SimpleDateFormat instanciated a static list try{ result = sdf.parse(datetime); break; } catch(ParseException e){ // do } } if(result == null){ throw new ParseException(datetime + " a pattern allowed.", 0); } return result; }</technical_language>

Target:
public static Date parseDateString(String datetime) throws ParseException { Date result = null; for (SimpleDateFormat sdf : allowedDateFormats) { try { result = sdf.parse(datetime); break; } catch (ParseException e) { } } if (result == null) { throw new ParseException(datetime + " don't use a pattern allowed.", 0); } return result; }
Source:
<code>public static String screenshot(String screenshotPath) { if (!Configuration.screenshots) { return ""; } <START> if (Configuration.savePageSource) { <END> if (screenshotPath == null || screenshotPath.isEmpty()) { return "\nScreenshot: " + screenshotPath; } return "\nScreenshot: " + screenshotPath + "\nHtml: " + screenshotPath.substring(0, screenshotPath.lastIndexOf('.')) + ".html"; } else { return "\nScreenshot: " + screenshotPath; } }</code><technical_language>if Configuration.screenshots=false Configuration.savePageSource=true PageSource in error message. I guess wrong</technical_language>

Target:
public static String screenshot(String screenshotPath) { if (!Configuration.screenshots) { return ""; } if (screenshotPath == null || screenshotPath.isEmpty()) { return "\nScreenshot: " + screenshotPath; } if (Configuration.savePageSource) { String htmlFilePath = getHtmlFilePath(screenshotPath); return "\nScreenshot: " + screenshotPath + "\nPage source: " + htmlFilePath; } else { return "\nScreenshot: " + screenshotPath; } }
Source:
<code>public void createAlreadyExisting() throws Exception { ObjectMapper mapper = new ObjectMapper(); BitstreamFormatRest bitstreamFormatRest = this.createRandomMockBitstreamRest(true); String token = getAuthToken(admin.getEmail(), password); getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes(bitstreamFormatRest)).contentType(contentType)) .andExpect(status().isCreated()); getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes(bitstreamFormatRest)).contentType(contentType)) <START> .andExpect(status().isInternalServerError()); <END> }</code><technical_language>this a 400 Bad request 422 (I suggest modify rest contract 422 for invalid support level, mismatch ID in json put request constraints violation that)</technical_language>

Target:
public void createAlreadyExisting() throws Exception { ObjectMapper mapper = new ObjectMapper(); BitstreamFormatRest bitstreamFormatRest = this.createRandomMockBitstreamRest(true); AtomicReference<Integer> idRef = new AtomicReference<>(); try { String token = getAuthToken(admin.getEmail(), password); getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes(bitstreamFormatRest)) .contentType(contentType)) .andExpect(status().isCreated()) .andDo(result -> idRef .set(read(result.getResponse().getContentAsString(), "$.id"))); getClient(token).perform(post("/api/core/bitstreamformats/") .content(mapper.writeValueAsBytes(bitstreamFormatRest)) .contentType(contentType)) .andExpect(status().isInternalServerError()); getClient().perform(get("/api/core/bitstreamformats/")) .andExpect(status().isOk()) .andExpect(jsonPath("$.page.totalElements", is(DEFAULT_AMOUNT_FORMATS + 1))); } finally { BitstreamFormatBuilder.deleteBitstreamFormat(idRef.get()); } }
Source:
<code>public JoinFilterPreAnalysis computeJoinFilterPreAnalysisIfAbsent( Filter filter, List<JoinableClause> clauses, VirtualColumns virtualColumns ) { synchronized (analyses) { if (filter != null) { <START> filter.hashCode(); <END> } } JoinFilterPreAnalysisGroupKey key = new JoinFilterPreAnalysisGroupKey(filter, clauses, virtualColumns); return analyses.computeIfAbsent( key, (groupKey) -> { return JoinFilterAnalyzer.computeJoinFilterPreAnalysis( JoinableClauses.fromList(clauses), virtualColumns, filter, joinFilterRewriteConfig ); } ); }</code><technical_language>Oh, is this need thread-safety filter hashcode methods i guess? This kind of a funny prime cached values, I supplier.memoize pattern a cleaner this necessary</technical_language>

Target:
public JoinFilterPreAnalysis computeJoinFilterPreAnalysisIfAbsent( Filter filter, List<JoinableClause> clauses, VirtualColumns virtualColumns ) { JoinFilterPreAnalysisGroupKey key = new JoinFilterPreAnalysisGroupKey(filter, clauses, virtualColumns); return analyses.computeIfAbsent( key, (groupKey) -> { return JoinFilterAnalyzer.computeJoinFilterPreAnalysis( JoinableClauses.fromList(clauses), virtualColumns, filter, joinFilterRewriteConfig ); } ); }
Source:
<code>public Iterator<Chatter[]> getChatter(String fileJson) { Collection<Chatter[]> chattersArray = new ArrayList<Chatter[]>(); try { parser = new JSONParser(); Object jsonObject = parser.parse(new FileReader("src/test/resources/" + fileJson)); JSONArray jsonArray = (JSONArray) jsonObject; ObjectMapper objectMapper = new ObjectMapper(); List<Chatter> navigation = objectMapper.readValue(jsonArray.toJSONString(), objectMapper.getTypeFactory().constructCollectionType( List.class, Chatter.class)); for (Chatter chatter : navigation) chattersArray.add(new Chatter[]{chatter}); } catch (FileNotFoundException e) { LoggerManager.getInstance().addErrorLog(this.getClass().getName(), "File not found for chatter - Json file:", e);; } catch (IOException e) { LoggerManager.getInstance().addErrorLog(this.getClass().getName(), "Error on data for Chatter from Json file:", e); } catch (ParseException e) { <START> LoggerManager.getInstance().addErrorLog(this.getClass().getName(), "Error on data for Chatter:", e); <END> } return chattersArray.iterator(); }</code><technical_language>Notice logger is duplicated times java LoggerManager.getInstance().addErrorLog(this.getClass().getName(), refactor that? this java \\class attribute private static final LoggerManager LOGGER = LoggerManager.getInstance().setClassName(this.getClass().getName()); try { \\..... } catch(FileNotFoundException e) { LOGGER.addErrorLog("File for chatter - Json file:", e); } \\....... Try apply this in project</technical_language>

Target:
public Iterator<Chatter[]> getChatter(String fileJson) { Collection<Chatter[]> chattersArray = new ArrayList<Chatter[]>(); try { parser = new JSONParser(); Object jsonObject = parser.parse(new FileReader("src/test/resources/" + fileJson)); JSONArray jsonArray = (JSONArray) jsonObject; ObjectMapper objectMapper = new ObjectMapper(); List<Chatter> navigation = objectMapper.readValue(jsonArray.toJSONString(), objectMapper.getTypeFactory().constructCollectionType( List.class, Chatter.class)); for (Chatter chatter : navigation) chattersArray.add(new Chatter[]{chatter}); } catch (FileNotFoundException e) { LOGGER.addErrorLog("File not found for chatter - Json file:", e);; } catch (IOException e) { LOGGER.addErrorLog("Error on data for Chatter from Json file:", e); } catch (ParseException e) { LOGGER.addErrorLog( "Error on data for Chatter:", e); } return chattersArray.iterator(); }