auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void testRequestBulkCancel() { TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker(); AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker); List<SlotExecutionVertexAssignment> assignments1 = context.allocateSlotsFor(EV1, EV3); fulfilOneOfTwoSlotRequestsAndGetPendingProfile(context, new AllocationID()); PhysicalSlotRequestBulk bulk1 = bulkChecker.getBulk(); List<SlotExecutionVertexAssignment> assignments2 = context.allocateSlotsFor(EV2); bulk1.cancel(new Throwable()); context.allocateSlotsFor(EV1, EV3); boolean ev1failed = assignments1.get(0).getLogicalSlotFuture().isCompletedExceptionally(); <START> boolean ev2failed = assignments1.get(0).getLogicalSlotFuture().isCompletedExceptionally(); <END> assertThat(context.getSlotProvider().getRequests().values(), hasSize(3)); assertThat(ev1failed != ev2failed, is(false)); assertThat(assignments2.get(0).getLogicalSlotFuture().isCompletedExceptionally(), is(false)); }</code><technical_language>suggestion boolean ev3failed = assignments1.get(1).getLogicalSlotFuture().isCompletedExceptionally();</technical_language>

Target:
public void testRequestBulkCancel() { TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker(); AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker); List<SlotExecutionVertexAssignment> assignments1 = context.allocateSlotsFor(EV1, EV3); fulfilOneOfTwoSlotRequestsAndGetPendingProfile(context, new AllocationID()); PhysicalSlotRequestBulk bulk1 = bulkChecker.getBulk(); List<SlotExecutionVertexAssignment> assignments2 = context.allocateSlotsFor(EV2); bulk1.cancel(new Throwable()); CompletableFuture<LogicalSlot> ev1slot = assignments1.get(0).getLogicalSlotFuture(); boolean ev1failed = ev1slot.isCompletedExceptionally(); CompletableFuture<LogicalSlot> ev3slot = assignments1.get(1).getLogicalSlotFuture(); boolean ev3failed = ev3slot.isCompletedExceptionally(); LogicalSlot slot = ev1failed ? ev3slot.join() : ev1slot.join(); releaseLogicalSlot(slot); context.allocateSlotsFor(EV1, EV3); assertThat(context.getSlotProvider().getRequests().values(), hasSize(3)); assertThat(ev1failed != ev3failed, is(true)); assertThat(assignments2.get(0).getLogicalSlotFuture().isCompletedExceptionally(), is(false)); }
Source:
<code>public CqlQuery<R> build() { Preconditions.checkNotNull(queryString, "Empty query string"); PreparedStatement statement = CqlClientImpl.this.prepareStatement(queryString); Object[] argsArray = new Object[args.size()]; for (int i = 0; i < args.size(); i++) { Preconditions.checkState(this.args.keySet().contains(statement.getVariables().getName(i)), <START> "Set argument is not expected"); <END> argsArray[i] = args.get(statement.getVariables().getName(i)); } BoundStatement boundStatement = statement.bind(argsArray); Preconditions.checkNotNull(rowStreamAccumulator, "RowStreamAccumulator is not set"); return new CqlQueryImpl<>(boundStatement, rowStreamAccumulator); }</code><technical_language>nit: I args.keySet()... do Also, do want log of params? Values UnsafeArg, I for names of parameters able mandate safe</technical_language>

Target:
public CqlQuery<R> build() { Preconditions.checkNotNull(queryString, "Empty query string"); PreparedStatement statement = CqlClientImpl.this.prepareStatement(queryString); Object[] argsArray = new Object[args.size()]; for (int i = 0; i < args.size(); i++) { Preconditions.checkState(this.args.containsKey(statement.getVariables().getName(i)), "Expected argument is not set", SafeArg.of("name", statement.getVariables().getName(i))); argsArray[i] = args.get(statement.getVariables().getName(i)); } BoundStatement boundStatement = statement.bind(argsArray); Preconditions.checkNotNull(rowStreamAccumulator, "RowStreamAccumulator is not set"); return new CqlQueryImpl<>(boundStatement, rowStreamAccumulator); }
Source:
<code>public void setUp() { <START> fetcher = new WorldcatFetcher("API_KEY"); <END> }</code><technical_language>please key aMHOf2rfzUt3fuKkb7DXX8pkBv1AmcBWwwoSfwpt8CMhdUdxXscB4ESOmBPs4NlmYJmFtcSZ3Q5kMxzb. This is a sandbox key work (for build server for local testing)</technical_language>

Target:
public void setUp() { fetcher = new WorldcatFetcher("aMHOf2rfzUt3fuKkb7DXX8pkBv1AmcBWwwoSfwpt8CMhdUdxXscB4ESOmBPs4NlmYJmFtcSZ3Q5kMxzb"); }
Source:
<code>public void testSortCompleted() { task1.setCompletionDate(new Date()); assertEquals(1, sorter.compare(new EmptyViewer(), task1, task2)); assertEquals(-1, sorter.compare(new EmptyViewer(), task2, task1)); <START> task2.setCompletionDate(new Date()); <END> assertEquals(0, sorter.compare(new EmptyViewer(), task1, task2)); assertEquals(0, sorter.compare(new EmptyViewer(), task2, task1)); }</code><technical_language>this Date instance above? If midnight in creation of instances, this test fail</technical_language>

Target:
public void testSortCompleted() { Date now = new Date(); task1.setCompletionDate(now); assertEquals(1, sorter.compare(new EmptyViewer(), task1, task2)); assertEquals(-1, sorter.compare(new EmptyViewer(), task2, task1)); task2.setCompletionDate(now); assertEquals(0, sorter.compare(new EmptyViewer(), task1, task2)); assertEquals(0, sorter.compare(new EmptyViewer(), task2, task1)); }
Source:
<code>public SettingsDto(String host, String port, String user, String password, InputStream additionalProperties, String logAddress, String logSubject, String logBody, String logPurgeEnable, String logPurgeTime, String logPurgeTimeMultiplier) { this(host, port, user, password, new HashMap<String, String>(), logAddress, logSubject, logBody, logPurgeEnable, logPurgeTime, logPurgeTimeMultiplier); String data; try { data = IOUtils.toString(additionalProperties); data = data.replaceAll("\\{", ""); data = data.replaceAll("}", ""); if (!"".equals(data)) { for (String property : data.split(",")) { String[] p = property.replaceAll(" ", "").split("="); if (p.length == 2) { this.additionalProperties.put(p[0], p[1]); } else { throw new MotechException("Error loading raw file config to properties"); } } <START> } <END> } catch (IOException e) { throw new MotechException("Error loading raw file config to properties", e); } }</code><technical_language>of this (and should) replaced load(InputStream is) Properties class</technical_language>

Target:
public SettingsDto(String host, String port, String user, String password, InputStream additionalProperties, String logAddress, String logSubject, String logBody, String logPurgeEnable, String logPurgeTime, String logPurgeTimeMultiplier) { this(host, port, user, password, new HashMap<String, String>(), logAddress, logSubject, logBody, logPurgeEnable, logPurgeTime, logPurgeTimeMultiplier); try { Properties props = new Properties(); props.load(additionalProperties); if (props != null) { for (Entry<Object, Object> entry : props.entrySet()) { this.additionalProperties.put((String) entry.getKey(), (String) entry.getValue()); } } } catch (IOException e) { throw new MotechException("Error loading raw file config to properties", e); } }
Source:
<code>final void forceClose() { if ( referenceCount > 0 ) { if ( TRACK_STATEMENTS ) { throw new StatementNotClosedException( "Statements was not correctly closed. See attached open/close stack traces for details.", <START> statementOpenCloseCalls ); <END> } referenceCount = 0; cleanupResources(); } pageCursorTracer.reportEvents(); }</code><technical_language>Good, I right place check this is in forceClose</technical_language>

Target:
final void forceClose() { if ( referenceCount > 0 ) { int leakedStatements = referenceCount; referenceCount = 0; cleanupResources(); if ( TRACK_STATEMENTS && transaction.isSuccess() ) { throw new StatementNotClosedException( format("Statements were not correctly closed. Number of leaked statements: %d. " + "See attached open/close stack traces for details.", leakedStatements), statementOpenCloseCalls ); } } pageCursorTracer.reportEvents(); }
Source:
<code>public void testInvalidAnalyzePartitionedTable() { String tableName = "test_invalid_analyze_partitioned_table"; <START> assertQueryFails("ANALYZE " + tableName, ".*Table.*does not exist.*"); <END> createPartitionedTableForAnalyzeTest(tableName); assertQueryFails(format("ANALYZE %s WITH (error = 1)", tableName), ".*does not support analyze property 'error'.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = 1)", tableName), ".*Cannot convert.*to array\\(array\\(varchar\\)\\).*"); assertQueryFails(format("ANALYZE %s WITH (partitions = NULL)", tableName), ".*Invalid null value for analyze property.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[NULL])", tableName), ".*Invalid null value in analyze partitions property.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[ARRAY['p4']])", tableName), ".*Partition no longer exists: p_varchar=p4.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[ARRAY['p4', 'error']])", tableName), ".*Partition value count does not match the partition column count.*"); assertUpdate(format("DROP TABLE %s", tableName)); }</code><technical_language>verify table name is correctly reported</technical_language>

Target:
public void testInvalidAnalyzePartitionedTable() { String tableName = "test_invalid_analyze_partitioned_table"; assertQueryFails("ANALYZE " + tableName, format(".*Table 'hive.tpch.%s' does not exist.*", tableName)); createPartitionedTableForAnalyzeTest(tableName); assertQueryFails(format("ANALYZE %s WITH (error = 1)", tableName), ".*'hive' does not support analyze property 'error'.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = 1)", tableName), ".*Cannot convert '1' to \\Qarray(array(varchar))\\E.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = NULL)", tableName), ".*Invalid null value for analyze property.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[NULL])", tableName), ".*Invalid null value in analyze partitions property.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[ARRAY['p4', '10']])", tableName), ".*Partition no longer exists.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[ARRAY['p4']])", tableName), ".*Partition value count does not match the partition column count.*"); assertQueryFails(format("ANALYZE %s WITH (partitions = ARRAY[ARRAY['p4', '10', 'error']])", tableName), ".*Partition value count does not match the partition column count.*"); assertUpdate(format("DROP TABLE %s", tableName)); }
Source:
<code>public void leaveNode(Tree tree) { if (!hasSemantic()) { return; } <START> if (tree.is(METHOD) || tree.is(CONSTRUCTOR)) { <END> synchronizedStack.pop(); } }</code><technical_language>need for ||</technical_language>

Target:
public void leaveNode(Tree tree) { if (!hasSemantic()) { return; } if (tree.is(METHOD, CONSTRUCTOR)) { synchronizedStack.pop(); } }
Source:
<code>protected void cleanPersistenceDir() throws Exception { assertTrue("Grids are not stopped", F.isEmpty(G.allGrids())); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "cp", false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "binary_meta", false)); <START> U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_LOCAL_SNAPSHOT_DIRECTORY, false)); <END> }</code><technical_language>test snapshots, override this method clean snapshot dir in this test (before test tests)</technical_language>

Target:
protected void cleanPersistenceDir() throws Exception { assertTrue("Grids are not stopped", F.isEmpty(G.allGrids())); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "cp", false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false)); U.delete(U.resolveWorkDirectory(U.defaultWorkDirectory(), "binary_meta", false)); }
Source:
<code>public static IRemoteConnection createConnection(URI hostUri, String hostName) throws RemoteConnectionException { IRemoteConnection connection = null; IRemoteConnectionType connectionType = getConnectionType(hostUri); IConnectionFactory connectionFactory = CONNECTION_FACTORIES.get(connectionType.getId()); if (connectionFactory != null) { connection = connectionFactory.createConnection(hostUri, hostName); } else { <START> connection = DEFAULT_CONNECTION_FACTORY.createConnection(hostUri, hostName); <END> } return connection; }</code><technical_language>set connectionFactory default, create connection in return statement</technical_language>

Target:
public static IRemoteConnection createConnection(URI hostUri, String hostName) throws RemoteConnectionException { IRemoteConnectionType connectionType = getConnectionType(hostUri); IConnectionFactory connectionFactory = CONNECTION_FACTORIES.get(connectionType.getId()); if (connectionFactory == null) { connectionFactory = DEFAULT_CONNECTION_FACTORY; } return connectionFactory.createConnection(hostUri, hostName); }
Source:
<code>public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final boolean withPluginInfo, final boolean withAttempts, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException { <START> return paymentProcessor.searchPayments(searchKey, offset, limit, pluginName, withPluginInfo, properties, context, internalCallContextFactory.createInternalTenantContext(context)); <END> }</code><technical_language>here: new flag withAttempts is passed (used) paymentProcessor#getAccountPayments</technical_language>

Target:
public Pagination<Payment> searchPayments(final String searchKey, final Long offset, final Long limit, final String pluginName, final boolean withPluginInfo, final boolean withAttempts, final Iterable<PluginProperty> properties, final TenantContext context) throws PaymentApiException { return paymentProcessor.searchPayments(searchKey, offset, limit, pluginName, withPluginInfo, withAttempts, properties, context, internalCallContextFactory.createInternalTenantContext(context)); }
Source:
<code>public void connect() throws Exception { if (channel.getClusterName() != null && !clusterName.equals(channel.getClusterName())) { throw new ConnectionFailedException("Already joined cluster: " + channel.getClusterName()); } channel.setReceiver(this); channel.connect(clusterName); Address localAddress = channel.getAddress(); String localName = localAddress.toString(); SimpleMember<Address> localMember = new SimpleMember<>(localName, localAddress, LOCAL_MEMBER, null); members.put(localAddress, new VersionedMember(localMember, membershipVersion.getAndIncrement())); updateConsistentHash(ch -> ch.with(localMember, loadFactor, commandFilter)); if (!executorProvided) { <START> executorService = Executors.newCachedThreadPool(new AxonThreadFactory("JGroupsConnector")); <END> } }</code><technical_language>add localName thread names? easier debug logs multiple instances merged logging system</technical_language>

Target:
public void connect() throws Exception { if (channel.getClusterName() != null && !clusterName.equals(channel.getClusterName())) { throw new ConnectionFailedException("Already joined cluster: " + channel.getClusterName()); } channel.setReceiver(this); channel.connect(clusterName); Address localAddress = channel.getAddress(); String localName = localAddress.toString(); SimpleMember<Address> localMember = new SimpleMember<>(localName, localAddress, LOCAL_MEMBER, null); members.put(localAddress, new VersionedMember(localMember, membershipVersion.getAndIncrement())); updateConsistentHash(ch -> ch.with(localMember, loadFactor, commandFilter)); if (!executorProvided) { executorService = Executors.newCachedThreadPool(new AxonThreadFactory("JGroupsConnector - " + localName)); } }
Source:
<code>public int compareTo(Property property) { <START> return this.getTitle().toLowerCase().compareTo(property.getTitle().toLowerCase()); <END> }</code><technical_language>I enough compare titles, consider actual value</technical_language>

Target:
public int compareTo(Property property) { int title = this.getTitle().toLowerCase().compareTo(property.getTitle().toLowerCase()); int value = this.getValue().toLowerCase().compareTo(property.getValue().toLowerCase()); if (title == 0 && value == 0) { return 0; } else if (value == 0) { return title; } else { return value; } }
Source:
<code>private static CString getHMAC(String algorithm, Target t, Construct[] args) { try { SecretKeySpec signingKey = new SecretKeySpec(args[0].val().getBytes(), algorithm); Mac mac = Mac.getInstance(algorithm); mac.init(signingKey); byte[] hmac = mac.doFinal(args[1].val().getBytes()); String hash = StringUtils.toHex(hmac).toLowerCase(); return new CString(hash, t); <START> } catch (NoSuchAlgorithmException ex) { <END> throw new ConfigRuntimeException("An error occured while trying to hash your data", ExceptionType.PluginInternalException, t, ex); } catch (InvalidKeyException ex) { throw new ConfigRuntimeException("An error occured while trying to hash your data", ExceptionType.PluginInternalException, t, ex); } }</code><technical_language>aware, build Java 7, MultiCatch here</technical_language>

Target:
private static CString getHMAC(String algorithm, Target t, Construct[] args) { try { SecretKeySpec signingKey = new SecretKeySpec(args[0].val().getBytes(), algorithm); Mac mac = Mac.getInstance(algorithm); mac.init(signingKey); byte[] hmac = mac.doFinal(args[1].val().getBytes()); String hash = StringUtils.toHex(hmac).toLowerCase(); return new CString(hash, t); } catch (NoSuchAlgorithmException | InvalidKeyException ex) { throw new ConfigRuntimeException("An error occured while trying to hash your data", ExceptionType.PluginInternalException, t, ex); } }
Source:
<code>public void load() throws IOException { super.load(); if (servers == null) { <START> servers = new ArrayList<GerritServer>(); <END> if (config != null) { GerritServer defaultServer = new GerritServer(DEFAULT_SERVER_NAME); defaultServer.setConfig(config); servers.add(defaultServer); } } }</code><technical_language>A LinkedList is access specific indexes anyways</technical_language>

Target:
public void load() throws IOException { super.load(); if (servers == null) { servers = new LinkedList<GerritServer>(); if (config != null) { GerritServer defaultServer = new GerritServer(DEFAULT_SERVER_NAME); defaultServer.setConfig(config); servers.add(defaultServer); } setServers(servers); save(); } }
Source:
<code>public void startup() { for (int i = 0; i < _ports.size(); i++) { Integer port = _ports.get(i); File logDir = FileUtils.constructRandomDirectoryInTempDir("kafka-local-" + port); Properties properties = new Properties(); properties.putAll(_baseProperties); properties.setProperty("zookeeper.connect", _zkConnection); properties.setProperty("broker.id", String.valueOf(i + 1)); properties.setProperty("host.name", "localhost"); properties.setProperty("port", Integer.toString(port)); properties.setProperty("log.dir", logDir.getAbsolutePath()); properties.setProperty("log.flush.interval.messages", String.valueOf(1)); properties.setProperty("log.cleaner.enable", Boolean.FALSE.toString()); properties.setProperty("offsets.topic.num.partitions", "1"); <START> properties.setProperty("auto.create.topics.enable", "false"); <END> KafkaServer broker = startBroker(properties); _brokerList.add(broker); _logDirs.add(logDir); } }</code><technical_language>This is a good idea. auto topic creation is enabled LinkedIn, for krc/kac. I I intentionally leave is. I override in some of specific tests</technical_language>

Target:
public void startup() { for (int i = 0; i < _ports.size(); i++) { Integer port = _ports.get(i); File logDir = FileUtils.constructRandomDirectoryInTempDir("kafka-local-" + port); Properties properties = new Properties(); properties.putAll(_baseProperties); properties.setProperty("zookeeper.connect", _zkConnection); properties.setProperty("broker.id", String.valueOf(i + 1)); properties.setProperty("host.name", "localhost"); properties.setProperty("port", Integer.toString(port)); properties.setProperty("log.dir", logDir.getAbsolutePath()); properties.setProperty("log.flush.interval.messages", String.valueOf(1)); properties.setProperty("log.cleaner.enable", Boolean.FALSE.toString()); properties.setProperty("offsets.topic.num.partitions", "1"); KafkaServer broker = startBroker(properties); _brokerList.add(broker); _logDirs.add(logDir); } }
Source:
<code>public void renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration, Consumer<Throwable> onError) { final String lockToken = message != null ? message.getLockToken() : "null"; final Consumer<Throwable> throwableConsumer = onError != null ? onError : error -> logger.warning("Exception occurred while renewing lock token '{}'.", lockToken, error); asyncClient.renewMessageLock(message, maxLockRenewalDuration).subscribe( v -> logger.verbose("Completed renewing lock token: '{}'", lockToken), <START> throwableConsumer); <END> }</code><technical_language>worth adding a log onComplete() is called too</technical_language>

Target:
public void renewMessageLock(ServiceBusReceivedMessage message, Duration maxLockRenewalDuration, Consumer<Throwable> onError) { final String lockToken = message != null ? message.getLockToken() : "null"; final Consumer<Throwable> throwableConsumer = onError != null ? onError : error -> logger.warning("Exception occurred while renewing lock token '{}'.", lockToken, error); asyncClient.renewMessageLock(message, maxLockRenewalDuration).subscribe( v -> logger.verbose("Completed renewing lock token: '{}'", lockToken), throwableConsumer, () -> logger.verbose("Auto message lock renewal operation completed: {}", lockToken)); }
Source:
<code>public VisualEditorSaveChangesDialog clickReturnToSaveFormButton() { waitForElementClickableByElement(returnToSaveFormButton); returnToSaveFormButton.click(); PageObjectLogging <START> .log("clickReturnToSaveFormButton", "Return To Save Form button clicked", true); <END> return new VisualEditorSaveChangesDialog(driver); }</code><technical_language>Global listener catch click. need log it</technical_language>

Target:
public VisualEditorSaveChangesDialog clickReturnToSaveFormButton() { waitForElementClickableByElement(returnToSaveFormButton); returnToSaveFormButton.click(); return new VisualEditorSaveChangesDialog(driver); }
Source:
<code>private Node findExpandableInTree(Node node) { if (canExpand(node)) { return node; } <START> ; <END> List<Node> children = tree.getNodeStorage().getChildren(node); for (Node child : children) { Node descendant = findExpandableInTree(child); if (descendant != null) { return descendant; } } return null; }</code><technical_language>redundant line</technical_language>

Target:
private Node findExpandableInTree(Node node) { if (canExpand(node)) { return node; } List<Node> children = tree.getNodeStorage().getChildren(node); for (Node child : children) { Node descendant = findExpandableInTree(child); if (descendant != null) { return descendant; } } return null; }
Source:
<code>public void setSecurityEnabled(final boolean enabled, boolean createAdminUser) { m_securityEnabled = enabled; if (createAdminUser) { addUsers(new UserInfo[] <START> {new UserInfo("defaultadmin", "admin", new String[] {CatalogUtil.ADMIN.toUpperCase()})}); <END> } }</code><technical_language>change one? CatalogUtil is place put in Constants</technical_language>

Target:
public void setSecurityEnabled(final boolean enabled, boolean createAdminUser) { m_securityEnabled = enabled; if (createAdminUser) { addUsers(new UserInfo[] {new UserInfo("defaultadmin", "admin", new String[] {"ADMINISTRATOR"})}); } }
Source:
<code>private void createSubs() throws IOException { Set<Key<?>> visitedKeys = Sets.newHashSet(); <START> while(! foundSubs.isEmpty()) { <END> Iterator<Subgraph> iterator = foundSubs.iterator(); Subgraph sub = iterator.next(); iterator.remove(); if (!visitedKeys.contains(sub.key)) { graphModule(sub.name , sub.injector, rootKeySetCreator.getRootKeys(sub.injector), 1); visitedKeys.add(sub.key); } } }</code><technical_language>style issue here: rm blank space ! var</technical_language>

Target:
private void createSubs() throws IOException { Set<Key<?>> visitedKeys = Sets.newHashSet(); while (!foundSubgraphs.isEmpty()) { Iterator<Subgraph> iterator = foundSubgraphs.iterator(); Subgraph sub = iterator.next(); iterator.remove(); if (!visitedKeys.contains(sub.getKey())) { graphModule(sub.getName(), sub.getInjector(), rootKeySetCreator.getRootKeys( sub.getInjector())); visitedKeys.add(sub.getKey()); } } }
Source:
<code>public static PreUploadHook newChain(List<? extends PreUploadHook> hooks) { PreUploadHook[] newHooks = new PreUploadHook[hooks.size()]; int i = 0; for (PreUploadHook hook : hooks) { <START> if (hook != PreUploadHook.NULL) <END> newHooks[i++] = hook; } if (i == 0) return PreUploadHook.NULL; else if (i == 1) return newHooks[0]; else return new PreUploadHookChain(newHooks); }</code><technical_language>bug</technical_language>

Target:
public static PreUploadHook newChain(List<? extends PreUploadHook> hooks) { PreUploadHook[] newHooks = new PreUploadHook[hooks.size()]; int i = 0; for (PreUploadHook hook : hooks) if (hook != PreUploadHook.NULL) newHooks[i++] = hook; if (i == 0) return PreUploadHook.NULL; else if (i == 1) return newHooks[0]; else return new PreUploadHookChain(newHooks, i); }
Source:
<code>private void redirectFromFullSiteToOasis() { MercuryFooterComponentObject footer = new MercuryFooterComponentObject(driver); ArticleNavigationComponentObject navigation = new ArticleNavigationComponentObject(driver); SkinHelper helper = new SkinHelper(driver); new ArticlePageObject(driver).openWikiPage(url); <START> footer.clickFullSiteLink(); <END> navigation.clickRandomArticle(); Assertion.assertTrue(helper.isSkin(Skin.OASIS)); }</code><technical_language>footer is once, cast</technical_language>

Target:
private void redirectFromFullSiteToOasis() { ArticleNavigationComponentObject navigation = new ArticleNavigationComponentObject(driver); SkinHelper helper = new SkinHelper(driver); new ArticlePageObject(driver).openWikiPage(url); new MercuryFooterComponentObject(driver).clickFullSiteLink(); navigation.clickRandomArticle(); Assertion.assertTrue(helper.isSkin(Skin.OASIS)); }
Source:
<code><START> @Test public void listPackagesFromJarTest() throws IOException, JarToBundleConverterException { <END> List<Object> actual = new ArrayList<>(); BundleGeneratorUtils.listPackages(TestConstants.SAMPLE_JAR_FILE).forEach(actual::add); List<Object> expected = new ArrayList<>(); expectedPackageList().forEach(expected::add); assert TestUtils.isMatching(expected, actual); }</code><technical_language>check formatting</technical_language>

Target:
public void listPackagesFromJarTest() throws IOException, JarToBundleConverterException { List<Object> actual = new ArrayList<>(); BundleGeneratorUtils.listPackages(TestConstants.SAMPLE_JAR_FILE).forEach(actual::add); List<Object> expected = new ArrayList<>(); expectedPackageList().forEach(expected::add); assert TestUtils.isMatching(expected, actual); }
Source:
<code>public void receiveHeader(PacketLineIn pckIn) throws IOException { try { <START> String version = versionPattern.matcher(pckIn.readStringRaw()) .group(1); <END> if (version.equals("0.1")) { pusher = pusherPattern.matcher(pckIn.readStringRaw()).group(1); pushee = pusheePattern.matcher(pckIn.readStringRaw()).group(1); receivedNonce = noncePattern.matcher(pckIn.readStringRaw()) .group(1); } else { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "version not supported")); } } catch (EOFException eof) { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "broken push certificate Header")); } nonceStatus = checkNonce(); }</code><technical_language>This work. need call matches() access group: Matcher m = versionPattern.matcher(pckIn.readStringRaw()); if (!m.matches()) { throw new IOException(... invalid cert ...) } String version = m.group(1); This is reason bother regex. Especially for simple patterns this. easier say: private static final String VERSION = "version "; String s = pckIn.readStringRaw(); if (!s.startsWith(VERSION)) throw ... String version = s.substring(VERSION.length());</technical_language>

Target:
public void receiveHeader(PacketLineIn pckIn) throws IOException { try { String s = pckIn.readStringRaw(); if (!s.startsWith(VERSION)) throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "expected push certificate version")); String version = s.substring(VERSION.length()); if (!version.equals("0.1\n")) { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "version not supported")); } pusher = parseNextLine(pckIn, PUSHER, "expected pusher"); pushee = parseNextLine(pckIn, PUSHEE, "expected pushee"); receivedNonce = parseNextLine(pckIn, NONCE, "expected nonce"); parseNextLine(pckIn, "\n", "expected new line"); } catch (EOFException eof) { throw new IOException(MessageFormat.format( JGitText.get().errorInvalidPushCert, "broken push certificate Header")); } nonceStatus = nonceGenerator.verify(receivedNonce, sentNonce, seed, db, nonceSlopLimit); }
Source:
<code>public void ImageStorage_001_deleteImage() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); SpecialNewFilesPageObject newFiles = base.openSpecialNewFiles(wikiURL); <START> Boolean noRedirect = true; <END> FilePagePageObject file = newFiles.openImage(PageContent.FILE_DELETE_AND_RESTORE, noRedirect); imageURL = file.getImageUrl(); imageThumbnailURL = file.getImageThumbnailUrl(); newFiles.verifyURLStatus(200, imageURL); newFiles.verifyURLStatus(200, imageThumbnailURL); DeletePageObject delete = newFiles.deletePage(); base = delete.submitDeletion(); base.verifyNotificationMessage(); base.verifyURLStatus(404, imageURL); base.verifyURLStatus(404, imageThumbnailURL); SpecialRestorePageObject restore = delete.undeleteByFlashMessage(); restore.giveReason(PageContent.CAPTION); restore.restorePage(); restore.verifyNotificationMessage(); newFiles.verifyURLStatus(200, imageURL); newFiles.verifyURLStatus(200, imageThumbnailURL); }</code><technical_language>need for another variable</technical_language>

Target:
public void ImageStorage_001_deleteImage() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); SpecialNewFilesPageObject newFiles = base.openSpecialNewFiles(wikiURL); FilePagePageObject file = newFiles.openImage(PageContent.FILE_DELETE_AND_RESTORE, true); imageURL = file.getImageUrl(); imageThumbnailURL = file.getImageThumbnailUrl(); newFiles.verifyURLStatus(200, imageURL); newFiles.verifyURLStatus(200, imageThumbnailURL); DeletePageObject delete = newFiles.deletePage(); base = delete.submitDeletion(); base.verifyNotificationMessage(); base.verifyURLStatus(404, imageURL); base.verifyURLStatus(404, imageThumbnailURL); SpecialRestorePageObject restore = delete.undeleteByFlashMessage(); restore.giveReason(PageContent.CAPTION); restore.restorePage(); restore.verifyNotificationMessage(); newFiles.verifyURLStatus(200, imageURL); newFiles.verifyURLStatus(200, imageThumbnailURL); }
Source:
<code><START> public long getSize() { <END> return size; }</code><technical_language>etc. for rest</technical_language>

Target:
public long getSize() { return this.size; }
Source:
<code>protected ICommand getBeforeMoveCommand(final MoveRequest request) { <START> ICommand gmfCommand = super.getBeforeMoveCommand(request); <END> if (request.getTargetContainer().eIsProxy()) { return UnexecutableCommand.INSTANCE; } return gmfCommand; }</code><technical_language>call super if return is call, gmfCommand used. More gmfCommand null. necessary call super. return unexecutable command in case of proxy null: return request.getTargetContainer().eIsProxy()?UnexecutableCommand.INSTANCE:null enough</technical_language>

Target:
protected ICommand getBeforeMoveCommand(final MoveRequest request) { return request.getTargetContainer().eIsProxy() ? UnexecutableCommand.INSTANCE : null; }
Source:
<code><START> private void requestNodeSourcesForBucket(String bucketName) { <END> String nodeSourcesListUrl = new CatalogUrlBuilder().getCatalogUrl() + "/buckets/" + bucketName + "/resources?kind=nodesource"; RequestBuilder nodeSourcesRequest = new RequestBuilder(RequestBuilder.GET, nodeSourcesListUrl); nodeSourcesRequest.setHeader(SESSION_ID_PARAMETER_NAME, LoginModel.getInstance().getSessionId()); nodeSourcesRequest.setCallback(getNodeSourcesRequestCallback(bucketName)); try { nodeSourcesRequest.send(); } catch (RequestException e) { logErrorMessage(e); } }</code><technical_language>this method is requestNodeSourcesList .... refactor passing a function a generic method</technical_language>

Target:
private void requestNodeSourcesForBucket(String bucketName) { String nodeSourcesListUrl = this.catalogUrl + "/buckets/" + bucketName + "/resources?kind=nodesource"; sendRequestToCatalog(nodeSourcesListUrl, getNodeSourcesRequestCallback(bucketName)); }
Source:
<code>public void test() throws Exception { WorkspaceModifyOperation operation = new TraceImportOperation(fSourcePath, fDestFolder); PlatformUI.getWorkbench().getProgressService().run(true, true, operation); WaitUtils.waitUntil(folder -> folder.getTraces().size() == 11, fDestFolder, () -> String.format("expected: <START> 9 but <END> was: %d", fDestFolder.getTraces().size())); validateImport(fSourcePath, fDestFolder, true); }</code><technical_language>update error message</technical_language>

Target:
public void test() throws Exception { WorkspaceModifyOperation operation = new TraceImportOperation(fSourcePath, fDestFolder); PlatformUI.getWorkbench().getProgressService().run(true, true, operation); WaitUtils.waitUntil(folder -> folder.getTraces().size() == EXPECTED_TRACE_COUNT, fDestFolder, () -> String.format("expected: %d but was: %d", EXPECTED_TRACE_COUNT, fDestFolder.getTraces().size())); validateImport(fSourcePath, fDestFolder, true); }
Source:
<code>@Test public void testSelectDistinctWikiNoTables() { final String sql = "select distinct \"countryName\"\n" + "from \"wikiticker\"\n" + "where \"page\" = 'Jeremy Corbyn'"; final String explain = "PLAN=" + "EnumerableInterpreter\n" + " DruidQuery(table=[[wiki, wikiticker]], " + "intervals=[[1900-01-01T00:00:00.000/3000-01-01T00:00:00.000]], " + "filter=[=($17, 'Jeremy Corbyn')], groups=[{7}], aggs=[[]])\n"; final String druidQuery = "{'queryType':'groupBy'," + "'dataSource':'wikiticker','granularity':'all'," <START> + "'dimensions':[{\"type\":\"default\",\"dimension\":\"countryName\"}],'limitSpec':{'type':'default'}," <END> + "'filter':{'type':'selector','dimension':'page','value':'Jeremy Corbyn'}," + "'aggregations':[{'type':'longSum','name':'dummy_agg','fieldName':'dummy_agg'}]," + "'intervals':['1900-01-01T00:00:00.000/3000-01-01T00:00:00.000']}"; sql(sql, WIKI_AUTO2) .returnsUnordered("countryName=United Kingdom", "countryName=null") .explainContains(explain) .queryContains(druidChecker(druidQuery)); sql("select count(*) as c from \"foodmart\"", WIKI_AUTO2) .returnsUnordered("C=86829"); }</code><technical_language>escape + " instead of single quote? Is same</technical_language>

Target:
@Test public void testSelectDistinctWikiNoTables() { final String sql = "select distinct \"countryName\"\n" + "from \"wikiticker\"\n" + "where \"page\" = 'Jeremy Corbyn'"; final String explain = "PLAN=" + "EnumerableInterpreter\n" + " DruidQuery(table=[[wiki, wikiticker]], " + "intervals=[[1900-01-01T00:00:00.000/3000-01-01T00:00:00.000]], " + "filter=[=($17, 'Jeremy Corbyn')], groups=[{7}], aggs=[[]])\n"; final String druidQuery = "{'queryType':'groupBy'," + "'dataSource':'wikiticker','granularity':'all'," + "'dimensions':[{'type':'default','dimension':'countryName'}],'limitSpec':{'type':'default'}," + "'filter':{'type':'selector','dimension':'page','value':'Jeremy Corbyn'}," + "'aggregations':[{'type':'longSum','name':'dummy_agg','fieldName':'dummy_agg'}]," + "'intervals':['1900-01-01T00:00:00.000/3000-01-01T00:00:00.000']}"; sql(sql, WIKI_AUTO2) .returnsUnordered("countryName=United Kingdom", "countryName=null") .explainContains(explain) .queryContains(druidChecker(druidQuery)); sql("select count(*) as c from \"foodmart\"", WIKI_AUTO2) .returnsUnordered("C=86829"); }
Source:
<code>protected EntitySpec<?> getMemberSpec() { @SuppressWarnings("unchecked") EntitySpec<ElasticSearchNode> spec = (EntitySpec<ElasticSearchNode>)getConfig(MEMBER_SPEC, EntitySpec.create(ElasticSearchNode.class)); <START> spec.configure(ElasticSearchNode.CLUSTER_NAME, getConfig(ElasticSearchClusterImpl.CLUSTER_NAME)) <END> .configure(ElasticSearchNode.NODE_NAME, "elasticsearch-" + nextMemberId.incrementAndGet()); return spec; }</code><technical_language>modify spec object retrieved config. Instead copy it. this modify default of MEMBER_SPEC, of inherited config shared multiple instances</technical_language>

Target:
protected EntitySpec<?> getMemberSpec() { EntitySpec<?> spec = EntitySpec.create(getConfig(MEMBER_SPEC, EntitySpec.create(ElasticSearchNode.class))); spec.configure(ElasticSearchNode.CLUSTER_NAME, getConfig(ElasticSearchClusterImpl.CLUSTER_NAME)) .configure(ElasticSearchNode.NODE_NAME, "elasticsearch-" + nextMemberId.incrementAndGet()); return spec; }
Source:
<code>public int compare(FSAppAttempt app1, FSAppAttempt app2) { return Resources.fitsIn(app1.getStarvation(), app2.getStarvation()) <START> ? -1 : 1; <END> }</code><technical_language>Missed this before. see: int ret = 1; if (Resources.fitsIn(app1.getStarvation(), app2.getStarvation())) { ret = -1; } return ret;</technical_language>

Target:
public int compare(FSAppAttempt app1, FSAppAttempt app2) { int ret = 1; if (Resources.fitsIn(app1.getStarvation(), app2.getStarvation())) { ret = -1; } return ret; }
Source:
<code><START> private boolean isHttpsWebsite(String siteUrl) throws IOException <END> { URL url = new URL("https://" + siteUrl); HttpsURLConnection httpsCon = (HttpsURLConnection)url.openConnection(); int responseCode = 0; if (httpsCon == null) return (false); try { responseCode = httpsCon.getResponseCode(); } catch (SSLException e) { e.printStackTrace(); return (false); } httpsCon.disconnect(); if (responseCode == 200) return (true); return (false); }</code><technical_language>throw IOException here? - catch SSLException, IOException</technical_language>

Target:
private boolean isHttpsWebsite(String siteUrl) throws IOException { URL url = new URL("https://" + siteUrl); HttpsURLConnection httpsCon = (HttpsURLConnection)url.openConnection(); int responseCode = 0; if (httpsCon == null) return (false); try { responseCode = httpsCon.getResponseCode(); } catch (SSLException e) { Log.e("URLHelper", "SSLException", e.getCause()); return (false); } catch (UnknownHostException e1) { Log.e("URLHelper", "UnknownHostException", e1.getCause()); return (false); } httpsCon.disconnect(); if (responseCode == 200) return (true); return (false); }
Source:
<code>public boolean handle(HttpServletRequest request, HttpServletResponse response, Account account) { <START> System.out.println("----> PostRegisterHandler"); <END> return true; }</code><technical_language>above, remove System.out.println. Applies System.out.println's in this PR</technical_language>

Target:
public boolean handle(HttpServletRequest request, HttpServletResponse response, Account account) { log.debug("----> PostRegisterHandler"); return true; }
Source:
<code><START> public void shouldReturnEmptyForEmptyCursor() { <END> TransmissionMapper mapper = new TransmissionMapper(null); given(mockCursor.getCount()).willReturn(0); given(mockCursor.moveToFirst()).willReturn(false); doNothing().when(mockCursor).close(); List<Transmission> transmissions = mapper.transform(mockCursor); assertTrue(transmissions.isEmpty()); }</code><technical_language>here.. is difference null empty</technical_language>

Target:
public void shouldReturnEmptyForEmptyCursor() { TransmissionMapper mapper = new TransmissionMapper(mockS3Mapper); given(mockCursor.getCount()).willReturn(0); given(mockCursor.moveToFirst()).willReturn(false); doNothing().when(mockCursor).close(); List<Transmission> transmissions = mapper.transform(mockCursor); assertTrue(transmissions.isEmpty()); }
Source:
<code>private GenericArray copyColumnarArray(ColumnarArray from) { Object arr; boolean isPrimitiveArray = true; switch (eleType.getTypeRoot()) { case BOOLEAN: <START> arr = from.toBooleanArray(); <END> break; case TINYINT: arr = from.toByteArray(); break; case SMALLINT: arr = from.toShortArray(); break; case INTEGER: case DATE: case TIME_WITHOUT_TIME_ZONE: arr = from.toIntArray(); break; case BIGINT: arr = from.toLongArray(); break; case FLOAT: arr = from.toFloatArray(); break; case DOUBLE: arr = from.toDoubleArray(); break; default: Object[] newArray = new Object[from.numElements()]; for (int i = 0; i < newArray.length; i++) { if (!from.isNullAt(i)) { newArray[i] = eleSer.copy(TypeGetterSetters.get(from, i, eleType)); } else { newArray[i] = null; } } arr = newArray; isPrimitiveArray = false; } return new GenericArray(arr, from.numElements(), isPrimitiveArray); }</code><technical_language>invoke toPrimitiveArray nullable is false</technical_language>

Target:
private GenericArray copyColumnarArray(ColumnarArray from) { Object arr = null; boolean isPrimitiveArray = true; if (!eleType.isNullable()) { switch (eleType.getTypeRoot()) { case BOOLEAN: arr = from.toBooleanArray(); break; case TINYINT: arr = from.toByteArray(); break; case SMALLINT: arr = from.toShortArray(); break; case INTEGER: case DATE: case TIME_WITHOUT_TIME_ZONE: arr = from.toIntArray(); break; case BIGINT: arr = from.toLongArray(); break; case FLOAT: arr = from.toFloatArray(); break; case DOUBLE: arr = from.toDoubleArray(); break; } } if (arr == null) { Object[] newArray = new Object[from.numElements()]; for (int i = 0; i < newArray.length; i++) { if (!from.isNullAt(i)) { newArray[i] = eleSer.copy(TypeGetterSetters.get(from, i, eleType)); } else { newArray[i] = null; } } arr = newArray; isPrimitiveArray = false; } return new GenericArray(arr, from.numElements(), isPrimitiveArray); }
Source:
<code>private void testFileRead() throws Exception { Connection conn = getConnection("functions"); Statement stat = conn.createStatement(); String fileName = getBaseDir() + "/test.txt"; Properties prop = System.getProperties(); OutputStream out = FileUtils.newOutputStream(fileName, false); prop.store(out, ""); out.close(); ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + fileName + "')) LEN"); rs.next(); assertEquals(FileUtils.size(fileName), rs.getInt(1)); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "') PROP"); rs.next(); Properties p2 = new Properties(); p2.load(rs.getBinaryStream(1)); assertEquals(prop.size(), p2.size()); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "', NULL) PROP"); rs.next(); String ps = rs.getString(1); InputStreamReader r = new InputStreamReader(FileUtils.newInputStream(fileName)); String ps2 = IOUtils.readStringAndClose(r, -1); assertEquals(ps, ps2); FileUtils.delete(fileName); fileName = "/" + this.getClass().getName().replaceAll("\\.", "/") + ".class"; rs = stat.executeQuery("SELECT LENGTH(FILE_READ('classpath:" + fileName + "')) LEN"); rs.next(); int fileSize = rs.getInt(1); assertTrue(fileSize > 0); rs = stat.executeQuery("SELECT LENGTH(FILE_READ('<LINK_0>')) LEN"); rs.next(); int webResourceSize = rs.getInt(1); assertTrue(webResourceSize > 0); <START> conn.close(); <END> conn.close(); }</code><technical_language>conn.close() duplicated</technical_language>

Target:
private void testFileRead() throws Exception { Connection conn = getConnection("functions"); Statement stat = conn.createStatement(); String fileName = getBaseDir() + "/test.txt"; Properties prop = System.getProperties(); OutputStream out = FileUtils.newOutputStream(fileName, false); prop.store(out, ""); out.close(); ResultSet rs = stat.executeQuery("SELECT LENGTH(FILE_READ('" + fileName + "')) LEN"); rs.next(); assertEquals(FileUtils.size(fileName), rs.getInt(1)); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "') PROP"); rs.next(); Properties p2 = new Properties(); p2.load(rs.getBinaryStream(1)); assertEquals(prop.size(), p2.size()); rs = stat.executeQuery("SELECT FILE_READ('" + fileName + "', NULL) PROP"); rs.next(); String ps = rs.getString(1); InputStreamReader r = new InputStreamReader(FileUtils.newInputStream(fileName)); String ps2 = IOUtils.readStringAndClose(r, -1); assertEquals(ps, ps2); FileUtils.delete(fileName); fileName = "/" + this.getClass().getName().replaceAll("\\.", "/") + ".class"; rs = stat.executeQuery("SELECT LENGTH(FILE_READ('classpath:" + fileName + "')) LEN"); rs.next(); int fileSize = rs.getInt(1); assertTrue(fileSize > 0); rs = stat.executeQuery("SELECT LENGTH(FILE_READ('<LINK_0>')) LEN"); rs.next(); int webResourceSize = rs.getInt(1); assertTrue(webResourceSize > 0); conn.close(); }
Source:
<code>public Result visit(TableFunctionScan e) { final List<SqlNode> inputSqlNodes = new ArrayList<>(); for (int i = 0; i < e.getInputs().size(); i++) { Result child = visitChild(i, e.getInput(i)); inputSqlNodes.add(child.asStatement()); } final Context context = tableFunctionScanContext(inputSqlNodes); SqlNode callNode = context.toSql(null, e.getCall()); SqlNode tableCall = new SqlBasicCall( SqlStdOperatorTable.COLLECTION_TABLE, new SqlNode[]{callNode}, SqlParserPos.ZERO); SqlNode select = new SqlSelect( SqlParserPos.ZERO, null, null, tableCall, null, null, null, null, null, null, null); <START> Result x = new Result(select, <END> ImmutableList.of(Clause.SELECT), null, e.getRowType(), null); return x; }</code><technical_language>additional space new</technical_language>

Target:
public Result visit(TableFunctionScan e) { final List<SqlNode> inputSqlNodes = new ArrayList<>(); final int inputSize = e.getInputs().size(); for (int i = 0; i < inputSize; i++) { Result child = visitChild(i, e.getInput(i)); inputSqlNodes.add(child.asStatement()); } final Context context = tableFunctionScanContext(inputSqlNodes); SqlNode callNode = context.toSql(null, e.getCall()); SqlNode tableCall = new SqlBasicCall( SqlStdOperatorTable.COLLECTION_TABLE, new SqlNode[]{callNode}, SqlParserPos.ZERO); SqlNode select = new SqlSelect( SqlParserPos.ZERO, null, null, tableCall, null, null, null, null, null, null, null, SqlNodeList.EMPTY); Result x = new Result(select, ImmutableList.of(Clause.SELECT), null, e.getRowType(), null); return x; }