auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public static void main(String[] args) throws Exception { try { if (args.length < 1) { System.out.println("Usage: LocalDLEmulator <zk_host> <zk_port>"); System.exit(-1); } final String zkHost = args[0]; <START> final int zkPort = Integer.parseInt(args[1]); <END> final File zkDir = IOUtils.createTempDir("distrlog", "zookeeper"); final LocalDLMEmulator localDlm = LocalDLMEmulator.newBuilder() .zkHost(zkHost) .zkPort(zkPort) .build(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { localDlm.teardown(); FileUtils.forceDeleteOnExit(zkDir); System.out.println("ByeBye!"); } catch (Exception e) { } } }); localDlm.start(); System.out.println(String.format( "DistributedLog Sandbox is running now. You could access distributedlog://%s:%s", zkHost, zkPort)); } catch (Exception ex) { System.out.println("Exception occurred running emulator " + ex); } }</code><technical_language>compatible version ? handle case in parameter</technical_language>

Target:
public static void main(String[] args) throws Exception { try { if (args.length < 1) { System.out.println("Usage: LocalDLEmulator [<zk_host>] <zk_port>"); System.exit(-1); } String zkHost = DEFAULT_ZK_HOST; int zkPort = DEFAULT_ZK_PORT; if (args.length == 1) { zkPort = Integer.parseInt(args[0]); } else { zkHost = args[0]; zkPort = Integer.parseInt(args[1]); } final File zkDir = IOUtils.createTempDir("distrlog", "zookeeper"); final LocalDLMEmulator localDlm = LocalDLMEmulator.newBuilder() .zkHost(zkHost) .zkPort(zkPort) .build(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { localDlm.teardown(); FileUtils.forceDeleteOnExit(zkDir); System.out.println("ByeBye!"); } catch (Exception e) { } } }); localDlm.start(); System.out.println(String.format( "DistributedLog Sandbox is running now. You could access distributedlog://%s:%s", zkHost, zkPort)); } catch (Exception ex) { System.out.println("Exception occurred running emulator " + ex); } }
Source:
<code>public <E extends RealmModel> Observable<RealmResults<E>> from(final Realm realm, final RealmResults<E> results) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<RealmResults<E>>() { @Override public void call(final Subscriber<? super RealmResults<E>> subscriber) { final Realm observableRealm = Realm.getInstance(realmConfig); resultsRefs.get().acquireReference(results); final RealmChangeListener<RealmResults<E>> listener = new RealmChangeListener<RealmResults<E>>() { @Override <START> public void onChange(RealmResults<E> object) { <END> if (!subscriber.isUnsubscribed()) { subscriber.onNext(results); } } }; results.addChangeListener(listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { results.removeChangeListener(listener); observableRealm.close(); resultsRefs.get().releaseReference(results); } })); subscriber.onNext(results); } }); }</code><technical_language>result, object</technical_language>

Target:
public <E extends RealmModel> Observable<RealmResults<E>> from(final Realm realm, final RealmResults<E> results) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<RealmResults<E>>() { @Override public void call(final Subscriber<? super RealmResults<E>> subscriber) { final Realm observableRealm = Realm.getInstance(realmConfig); resultsRefs.get().acquireReference(results); final RealmChangeListener<RealmResults<E>> listener = new RealmChangeListener<RealmResults<E>>() { @Override public void onChange(RealmResults<E> result) { if (!subscriber.isUnsubscribed()) { subscriber.onNext(results); } } }; results.addChangeListener(listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { results.removeChangeListener(listener); observableRealm.close(); resultsRefs.get().releaseReference(results); } })); subscriber.onNext(results); } }); }
Source:
<code>public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { <START> AnnotatedElement element = context.getElement().orElse(null); return findAnnotation(element, Disabled.class) <END> .map(disabled -> Optional.of(disabled) .map(Disabled::value) .filter(StringUtils::isNotBlank) .orElseGet(() -> element + " is @Disabled")) .map(ConditionEvaluationResult::disabled) .orElse(ENABLED); }</code><technical_language>flatMap here</technical_language>

Target:
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { AnnotatedElement element = context.getElement().orElse(null); return findAnnotation(element, Disabled.class).map(annotation -> toResult(element, annotation)).orElse(ENABLED); }
Source:
<code>protected void executeCommand() { int replicaCount = (getGlusterVolume().getVolumeType() == GlusterVolumeType.REPLICATE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) ? getParameters().getReplicaCount() : 0; VDSReturnValue returnValue = runVdsCommand( VDSCommandType.StartRemoveGlusterVolumeBricks, new GlusterVolumeRemoveBricksVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().getBricks(), replicaCount, true)); setSucceeded(returnValue.getSucceeded()); if (getSucceeded()) { GlusterDBUtils.getInstance().removeBricksFromVolumeInDb(getGlusterVolume(), getParameters().getBricks(), <START> getParameters().getReplicaCount()); <END> } else { handleVdsError(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_FAILED, returnValue.getVdsError().getMessage()); return; } }</code><technical_language>pass replicaCount variable</technical_language>

Target:
protected void executeCommand() { int replicaCount = (getGlusterVolume().getVolumeType() == GlusterVolumeType.REPLICATE || getGlusterVolume().getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) ? getParameters().getReplicaCount() : 0; VDSReturnValue returnValue = runVdsCommand( VDSCommandType.StartRemoveGlusterVolumeBricks, new GlusterVolumeRemoveBricksVDSParameters(upServer.getId(), getGlusterVolumeName(), getParameters().getBricks(), replicaCount, true)); setSucceeded(returnValue.getSucceeded()); if (getSucceeded()) { GlusterDBUtils.getInstance().removeBricksFromVolumeInDb(getGlusterVolume(), getParameters().getBricks(), replicaCount); } else { handleVdsError(AuditLogType.GLUSTER_VOLUME_REMOVE_BRICKS_FAILED, returnValue.getVdsError().getMessage()); return; } }
Source:
<code>public Connection connect(String url, Properties info) throws SQLException { try { LOGGER.info("Initiating connection to database for url: " + url); PinotClientTransport pinotClientTransport = new JsonAsyncHttpPinotClientTransportFactory().buildTransport(); String controllerUrl = DriverUtils.getControllerFromURL(url); <START> Preconditions.checkArgument(info.containsKey(TENANT), "Pinot tenant missing in the properties"); <END> String tenant = info.getProperty(TENANT); return new PinotConnection(controllerUrl, pinotClientTransport, tenant); } catch (Exception e) { throw new SQLException(String.format("Failed to connect to url : %s", url), e); } }</code><technical_language>needed, default tenant name it</technical_language>

Target:
public Connection connect(String url, Properties info) throws SQLException { try { LOGGER.info("Initiating connection to database for url: " + url); PinotClientTransport pinotClientTransport = new JsonAsyncHttpPinotClientTransportFactory().buildTransport(); String controllerUrl = DriverUtils.getControllerFromURL(url); String tenant = info.getProperty(TENANT, DEFAULT_TENANT); return new PinotConnection(controllerUrl, pinotClientTransport, tenant); } catch (Exception e) { throw new SQLException(String.format("Failed to connect to url : %s", url), e); } }
Source:
<code>@Override public void onError(Throwable e) { U.error(context().planningContext().logger(), "Error occurred during execution: " + X.getFullStackTrace(e)); <START> dest.targets().forEach(nodeId -> { <END> try { sendError(nodeId, e); } catch (IgniteCheckedException ex) { U.error(context().planningContext().logger(), "Error occurred during send error message: " + X.getFullStackTrace(e)); } }); }</code><technical_language>move specific Buffer method</technical_language>

Target:
@Override public void onError(Throwable e) { U.error(context().planningContext().logger(), "Error occurred during execution: " + X.getFullStackTrace(e)); nodeBuffers.values().forEach(b -> b.onError(e)); }
Source:
<code>public static Boolean getBoolean(String val) { if (val == null || val.trim().length() == 0) { return false; } try { return Boolean.valueOf(val); <START> } catch (Exception e) { <END> return false; } }</code><technical_language>is exception attempt catch? Java doc exceptions this method</technical_language>

Target:
public static Boolean getBoolean(String val) { if (val == null || val.trim().length() == 0) { return false; } try { return Boolean.valueOf(val); } catch (IllegalArgumentException e) { return false; } }
Source:
<code>public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); if (targetPlayer == null) { return true; } int count = targetPlayer.discard(targetPlayer.getHand(), source, game).size(); targetPlayer.drawCards(count, source.getSourceId(), game); <START> return false; <END> }</code><technical_language>return true. return false code (targetPlayer == null)</technical_language>

Target:
public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); if (targetPlayer == null) { return false; } int count = targetPlayer.discard(targetPlayer.getHand(), source, game).size(); targetPlayer.drawCards(count, source.getSourceId(), game); return true; }
Source:
<code>public void enumerateTest2() throws Exception { PigTest test = createPigTest("test/pig/datafu/test/pig/bags/enumerateTest.pig"); writeLinesToFile("input", "({(10,{(1),(2),(3)}),(20,{(4),(5),(6)}),(30,{(7),(8)}),(40,{(9),(10),(11)}),(50,{(12),(13),(14),(15)})})", <START> "({(10,{(1),(2),(3)}),(20,{(4),(5),(6)}),(30,{(7),(8)}),(40,{(9),(10),(11)}),(50,{(12),(13),(14),(15)})})"); <END> test.runScript(); assertOutput(test, "data4", "(10,{(1),(2),(3)},0)", "(20,{(4),(5),(6)},1)", "(30,{(7),(8)},2)", "(40,{(9),(10),(11)},3)", "(50,{(12),(13),(14),(15)},4)", "(10,{(1),(2),(3)},0)", "(20,{(4),(5),(6)},1)", "(30,{(7),(8)},2)", "(40,{(9),(10),(11)},3)", "(50,{(12),(13),(14),(15)},4)"); }</code><technical_language>numbers good for bag</technical_language>

Target:
public void enumerateTest2() throws Exception { PigTest test = createPigTest("test/pig/datafu/test/pig/bags/enumerateTest.pig"); writeLinesToFile("input", "({(10,{(1),(2),(3)}),(20,{(4),(5),(6)}),(30,{(7),(8)}),(40,{(9),(10),(11)}),(50,{(12),(13),(14),(15)})})", "({(11,{(11),(12),(13),(14)}),(21,{(15),(16),(17),(18)}),(31,{(19),(20)}),(41,{(21),(22),(23),(24)}),(51,{(25),(26),(27)})})"); test.runScript(); assertOutput(test, "data4", "(10,{(1),(2),(3)},0)", "(20,{(4),(5),(6)},1)", "(30,{(7),(8)},2)", "(40,{(9),(10),(11)},3)", "(50,{(12),(13),(14),(15)},4)", "(11,{(11),(12),(13),(14)},0)", "(21,{(15),(16),(17),(18)},1)", "(31,{(19),(20)},2)", "(41,{(21),(22),(23),(24)},3)", "(51,{(25),(26),(27)},4)"); }
Source:
<code>public void testJsonAPIPost() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body( datum( resource( type("post"), id("1"), attributes( attr("content", "This is my first post. woot."), attr("date", "2019-01-01T00:00Z") ) ) ) ) .post("/api/v1/post") .then() .statusCode(HttpStatus.SC_CREATED) .extract().body().asString(); given() .when() .get("/api/v1/postView") <START> .then() <END> .statusCode(200); given() .when() .get("/api/v1/postView") .then() .body("data.id", hasItems("0")) .body("data.attributes.content", hasItems("This is my first post. woot.")); }</code><technical_language>combine this test in a single request (test body status code)</technical_language>

Target:
public void testJsonAPIPost() { given() .contentType(JSONAPI_CONTENT_TYPE) .accept(JSONAPI_CONTENT_TYPE) .body( datum( resource( type("post"), id("1"), attributes( attr("content", "This is my first post. woot."), attr("date", "2019-01-01T00:00Z") ) ) ) ) .post("/api/v1/post") .then() .statusCode(HttpStatus.SC_CREATED) .extract().body().asString(); given() .when() .get("/api/v1/postView") .then() .statusCode(200) .body("data.id", hasItems("0")) .body("data.attributes.content", hasItems("This is my first post. woot.")); }
Source:
<code>public void deactivateApp(String id) { <START> App app = findAppById(id); <END> app.setActive(false); dataService.update(AppMetadata.APP, app); String pluginId = generatePluginId(app); dataService.deleteById(PluginMetadata.PLUGIN, pluginId); }</code><technical_language>if find returns null</technical_language>

Target:
public void deactivateApp(String id) { App app = findAppById(id); app.setActive(false); dataService.update(AppMetadata.APP, app); String pluginId = generatePluginId(app); dataService.deleteById(PluginMetadata.PLUGIN, pluginId); Menu menu = menuReaderService.getMenu(); menu.setItems(menu.deleteMenuItem(pluginId)); menuManagerService.saveMenu(menu); }
Source:
<code>public ArtAlnRecord getNextAln() throws IOException { if (currentLine == null) { return null; } final String refAln = br.readLine().trim(); final String readAln = br.readLine().trim(); final String[] alnFields = splitterPattern.split(currentLine.trim().substring(1)); int direction = (alnFields[3].equals("-")) ? 1 : 0; final int refLength = refAln.replace("-", "").length(); ArtAlnRecord record = new ArtAlnRecord(new ChrString(alnFields[0]), Integer.parseInt(alnFields[2]) + 1, direction, alnFields[1], refLength); if (!chromosomeLengths.containsKey(record.chromosome)) { <START> log.warning("got nonexistent chromosome " + record.chromosome + " at aln file line " + (br.getLineNumber() - 2)); <END> return null; } if (record.direction == 1) { final int chromosomeLength = chromosomeLengths.get(record.chromosome); record.location = chromosomeLength - (record.location - 1) + 1 - refLength; } currentLine = br.readLine(); return record; }</code><technical_language>If possible, print offending line too</technical_language>

Target:
public ArtAlnRecord getNextAln() throws IOException { if (currentLine == null) { return null; } final String refAln = br.readLine().trim(); final String readAln = br.readLine().trim(); final String[] alnFields = splitterPattern.split(currentLine.trim().substring(1)); int direction = (alnFields[3].equals("-")) ? 1 : 0; final int refLength = refAln.replace("-", "").length(); ArtAlnRecord record = new ArtAlnRecord(new ChrString(alnFields[0]), Integer.parseInt(alnFields[2]) + 1, direction, alnFields[1], refLength); if (!chromosomeLengths.containsKey(record.chromosome)) { log.warn("got nonexistent chromosome " + record.chromosome + " at aln file line " + (br.getLineNumber() - 2) + ": " + currentLine.trim()); return null; } if (record.direction == 1) { final int chromosomeLength = chromosomeLengths.get(record.chromosome); record.location = chromosomeLength - (record.location - 1) + 1 - refLength; } currentLine = br.readLine(); return record; }
Source:
<code>public void testFloat() { assertEquals(getDomain(REAL, 0, null), all(REAL)); float minimum = 4.3f; float maximum = 40.3f; assertEquals(getDomain(REAL, 10, floatColumnStats(minimum, minimum)), singleValue(REAL, (long) floatToRawIntBits(minimum))); assertEquals( getDomain(REAL, 10, floatColumnStats(minimum, maximum)), create(ValueSet.ofRanges(range(REAL, (long) floatToRawIntBits(minimum), true, (long) floatToRawIntBits(maximum), true)), false)); try { <START> assertEquals(getDomain(REAL, 10, floatColumnStats(maximum, minimum)), create(ValueSet.all(REAL), false)); <END> fail("Parquet with corrupted statistics"); } catch (ParquetCorruptionException e) { assertEquals(e.getMessage(), "Parquet with corrupted statistics"); } }</code><technical_language>Remove assertEquals() called, expect test throw</technical_language>

Target:
public void testFloat() throws ParquetCorruptionException { String column = "FloatColumn"; assertEquals(getDomain(REAL, 0, null, ID, column, true), all(REAL)); float minimum = 4.3f; float maximum = 40.3f; assertEquals(getDomain(REAL, 10, floatColumnStats(minimum, minimum), ID, column, true), singleValue(REAL, (long) floatToRawIntBits(minimum))); assertEquals( getDomain(REAL, 10, floatColumnStats(minimum, maximum), ID, column, true), create(ValueSet.ofRanges(range(REAL, (long) floatToRawIntBits(minimum), true, (long) floatToRawIntBits(maximum), true)), false)); assertEquals(getDomain(REAL, 10, floatColumnStats(maximum, minimum), ID, column, false), create(ValueSet.all(REAL), false)); assertThatExceptionOfType(ParquetCorruptionException.class) .isThrownBy(() -> getDomain(REAL, 10, floatColumnStats(maximum, minimum), ID, column, true)) .withMessage("Corrupted statistics for column \"FloatColumn\" in Parquet file \"testFile\": [min: 40.30000, max: 4.30000, num_nulls: 0]"); }
Source:
<code>public void testRunParagraphJob() throws IOException, InterruptedException { Note note1 = ZeppelinServer.notebook.createNote(anonymous); note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); Paragraph p = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); PostMethod post = httpPost("/notebook/job/" + note1.getId() + "/" + p.getId(), ""); assertThat(post, isAllowed()); Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); assertEquals(resp.get("status"), "OK"); post.releaseConnection(); assertEquals(p.getStatus(), Job.Status.FINISHED); p.setText("%spark.pyspark\nprint(\"test\")"); post = httpPost("/notebook/job/" + note1.getId() + "/" + p.getId(), ""); assertThat(post, isAllowed()); resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); assertEquals(resp.get("status"), "OK"); post.releaseConnection(); <START> long startTimeInMins = (System.currentTimeMillis() / (1000 * 60)) % 60; <END> while (!p.getStatus().equals(Job.Status.FINISHED)) { long currentTimeInMins = (System.currentTimeMillis() / (1000 * 60)) % 60; if (currentTimeInMins - startTimeInMins > 1) { if (!p.getStatus().equals(Job.Status.FINISHED)) { fail("Job is running for too long"); } } TimeUnit.SECONDS.sleep(10); } assertEquals("test\n", p.getResult().message().get(0).getData()); ZeppelinServer.notebook.removeNote(note1.getId(), anonymous); }</code><technical_language>move this logic test of notebookservice responsibility of running paragraph is in charge of notebookservice</technical_language>

Target:
public void testRunParagraphJob() throws IOException { Note note1 = ZeppelinServer.notebook.createNote(anonymous); note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); Paragraph p = note1.addNewParagraph(AuthenticationInfo.ANONYMOUS); PostMethod post = httpPost("/notebook/job/" + note1.getId() + "/" + p.getId(), ""); assertThat(post, isAllowed()); Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); assertEquals(resp.get("status"), "OK"); post.releaseConnection(); assertEquals(p.getStatus(), Job.Status.FINISHED); p.setText("test"); post = httpPost("/notebook/job/" + note1.getId() + "/" + p.getId(), ""); assertThat(post, isAllowed()); resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {}.getType()); assertEquals(resp.get("status"), "OK"); post.releaseConnection(); assertNotEquals(p.getStatus(), Job.Status.READY); ZeppelinServer.notebook.removeNote(note1.getId(), anonymous); }
Source:
<code>public void testCloseAutoRead() { EmbeddedChannel channel = new EmbeddedChannel(); channel.config().setAutoRead(false); Queue<Object> inboundMessages = channel.inboundMessages(); channel.writeInbound(1L, 2L, 3L); assertEquals(0, inboundMessages.size()); channel.read(); assertEquals(3, inboundMessages.size()); inboundMessages.clear(); channel.writeOneInbound(1L); channel.flushInbound(); assertEquals(0, inboundMessages.size()); <START> channel.finish(); <END> }</code><technical_language>assert return</technical_language>

Target:
public void testCloseAutoRead() { EmbeddedChannel channel = new EmbeddedChannel(); channel.config().setAutoRead(false); Queue<Object> inboundMessages = channel.inboundMessages(); channel.writeInbound(1L, 2L, 3L); assertEquals(0, inboundMessages.size()); channel.read(); assertEquals(3, inboundMessages.size()); inboundMessages.clear(); channel.writeOneInbound(1L); channel.flushInbound(); assertEquals(0, inboundMessages.size()); assertFalse(channel.finish()); }
Source:
<code>private void revert() { final GitOutputConsole console = gitOutputConsoleFactory.create(REVERT_COMMAND_NAME); service .revert(project.getLocation(), selectedRevision.getId()) .then( result -> { console.print(formRevertMessage(result)); String conflictsMessage = formConflictsMessage(result.getConflicts()); <START> if (conflictsMessage != null && !conflictsMessage.isEmpty()) { <END> console.printError(conflictsMessage); } consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); notificationManager.notify(constant.revertCommitSuccessfully()); project.synchronize(); }) .catchError( error -> { String errorMessage = (error.getMessage() != null) ? error.getMessage() : constant.revertCommitFailed(); console.printError(errorMessage); consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); notificationManager.notify(constant.revertCommitFailed(), FAIL, FLOAT_MODE); }); }</code><technical_language>conflictsMessage null</technical_language>

Target:
private void revert() { final GitOutputConsole console = gitOutputConsoleFactory.create(constant.consoleRevertCommandName()); service .revert(project.getLocation(), selectedRevision.getId()) .then( result -> { console.print(formRevertMessage(result)); String conflictsMessage = formConflictsMessage(result.getConflicts()); if (!conflictsMessage.isEmpty()) { console.printError(conflictsMessage); } consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); notificationManager.notify(constant.revertCommitSuccessfully()); project.synchronize(); }) .catchError( error -> { String errorMessage = (error.getMessage() != null) ? error.getMessage() : constant.revertCommitFailed(); console.printError(errorMessage); consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); notificationManager.notify(constant.revertCommitFailed(), FAIL, FLOAT_MODE); }); }
Source:
<code>public void testCreateIndexAndInsertWithExpressionsBatchWithFullNullRow() throws Exception { String tableName = "TEST_IDX_BATCH_INSERT"; methodWatcher.executeUpdate(format("create table %s (c char(4), i int, d double)", tableName)); methodWatcher.executeUpdate(format("insert into %s values ('abc', 10, 1.1), ('def', 20, 2.2)", tableName)); methodWatcher.executeUpdate(format("CREATE INDEX %s_IDX ON %s (upper(c), i + 2)", tableName, tableName)); methodWatcher.executeUpdate(format("insert into %s values ('jkl', 30, 2.2), (NULL, NULL, NULL)", tableName)); <START> methodWatcher.executeUpdate(format("update %s set c = 'def' where i = 10", tableName)); <END> }</code><technical_language>verify results of operations</technical_language>

Target:
public void testCreateIndexAndInsertWithExpressionsBatchWithFullNullRow() throws Exception { String tableName = "TEST_IDX_BATCH_INSERT"; methodWatcher.executeUpdate(format("create table %s (c char(4), i int, d double)", tableName)); methodWatcher.executeUpdate(format("insert into %s values ('abc', 10, 1.1), ('def', 20, 2.2)", tableName)); methodWatcher.executeUpdate(format("CREATE INDEX %s_IDX ON %s (upper(c), i + 2)", tableName, tableName)); methodWatcher.executeUpdate(format("insert into %s values ('jkl', 30, 2.2), (NULL, NULL, NULL)", tableName)); methodWatcher.executeUpdate(format("update %s set c = 'def' where i = 10", tableName)); String query = format("select c from %s order by c nulls last", tableName); String expected = "C |\n" + "------\n" + " def |\n" + " def |\n" + " jkl |\n" + "NULL |"; try (ResultSet rs = methodWatcher.executeQuery(query)) { Assert.assertEquals(expected, TestUtils.FormattedResult.ResultFactory.toStringUnsorted(rs)); } }
Source:
<code>public static Set<String> findApplicationIdFromLog(String logFilePath, Logger log) { File logFile = new File(logFilePath); if (!logFile.exists()) { throw new IllegalArgumentException("the logFilePath does not exist: " + logFilePath); } if (!logFile.isFile()) { throw new IllegalArgumentException("the logFilePath specified is not a valid file: " + logFilePath); } if (!logFile.canRead()) { throw new IllegalArgumentException("unable to read the logFilePath specified: " + logFilePath); } BufferedReader br = null; Set<String> applicationIds = new HashSet<String>(); <START> Pattern p = Pattern.compile(".* (application_\\d+_\\d+).*"); <END> try { br = new BufferedReader(new FileReader(logFile)); String input; while ((input = br.readLine()) != null) { Matcher m = p.matcher(input); if (m.find()) { String appId = m.group(1); if (!applicationIds.contains(appId)) { applicationIds.add(appId); } } } } catch (IOException e) { e.printStackTrace(); log.info("Error while trying to find applicationId for Spark log", e); } finally { try { if (br != null) br.close(); } catch (Exception e) { } } return applicationIds; }</code><technical_language>move this out a class static variable</technical_language>

Target:
public static Set<String> findApplicationIdFromLog(String logFilePath, Logger log) { File logFile = new File(logFilePath); if (!logFile.exists()) { throw new IllegalArgumentException("the logFilePath does not exist: " + logFilePath); } if (!logFile.isFile()) { throw new IllegalArgumentException("the logFilePath specified is not a valid file: " + logFilePath); } if (!logFile.canRead()) { throw new IllegalArgumentException("unable to read the logFilePath specified: " + logFilePath); } BufferedReader br = null; Set<String> applicationIds = new HashSet<String>(); try { br = new BufferedReader(new FileReader(logFile)); String input; while ((input = br.readLine()) != null) { Matcher m = APPLICATION_ID_PATTERN.matcher(input); if (m.find()) { String appId = m.group(1); applicationIds.add(appId); } } } catch (IOException e) { log.error("Error while trying to find applicationId for Spark log", e); } finally { try { if (br != null) br.close(); } catch (Exception e) { } } return applicationIds; }
Source:
<code><START> public void setCommandBus(CommandBus commandBus) { <END> this.commandBus = commandBus; this.rescheduler = new Rescheduler(commandBus); }</code><technical_language>usage is in CommandBus.Builder, hide public API</technical_language>

Target:
protected void setCommandBus(CommandBus commandBus) { this.commandBus = commandBus; this.rescheduler = new Rescheduler(commandBus); }
Source:
<code>public void validate(ServerStoreConfiguration clientStoreConfiguration) throws ClusterTierException, TimeoutException { try { <START> invokeInternalAndWait(endpoint.beginInvoke(), timeouts.getWriteOperationTimeout(), messageFactory.validateServerStore(storeIdentifier , clientStoreConfiguration), false); <END> } catch (ClusterException e) { throw new ClusterTierValidationException("Error validating cluster tier '" + storeIdentifier + "'", e); } }</code><technical_language>is validate a write operation</technical_language>

Target:
public void validate(ServerStoreConfiguration clientStoreConfiguration) throws ClusterTierException, TimeoutException { try { invokeInternalAndWait(endpoint.beginInvoke(), timeouts.getConnectionTimeout(), messageFactory.validateServerStore(storeIdentifier , clientStoreConfiguration), false); } catch (ClusterException e) { throw new ClusterTierValidationException("Error validating cluster tier '" + storeIdentifier + "'", e); } }
Source:
<code>private List<Item> getItems(TreeWalkerAuditEvent event) { final RootNode rootNode; if (event.getRootAst() == null) { rootNode = null; } else { rootNode = new RootNode(event.getRootAst()); } final List<Item> items; try { final XPathDynamicContext xpathDynamicContext = xpathExpression.createDynamicContext(rootNode); items = xpathExpression.evaluate(xpathDynamicContext); } catch (XPathException ex) { <START> throw new IllegalStateException(ex); <END> } return items; }</code><technical_language>put some context wrapper exception</technical_language>

Target:
private List<Item> getItems(TreeWalkerAuditEvent event) { final RootNode rootNode; if (event.getRootAst() == null) { rootNode = null; } else { rootNode = new RootNode(event.getRootAst()); } final List<Item> items; try { final XPathDynamicContext xpathDynamicContext = xpathExpression.createDynamicContext(rootNode); items = xpathExpression.evaluate(xpathDynamicContext); } catch (XPathException ex) { throw new IllegalStateException("Cannot initialize context and evaluate query: " + xpathQuery, ex); } return items; }
Source:
<code>public static StreamApplication createStreamApplication(Config config) { if (config.get(StreamApplication.APP_CLASS_CONFIG) != null && !config.get(StreamApplication.APP_CLASS_CONFIG).isEmpty()) { TaskConfig taskConfig = new TaskConfig(config); if (taskConfig.getTaskClass() != null && !taskConfig.getTaskClass().isEmpty()) { throw new ConfigException("High level StreamApplication API cannot be used together with low-level API using task.class."); } String appClassName = config.get(StreamApplication.APP_CLASS_CONFIG); try { Class<?> builderClass = Class.forName(appClassName); return (StreamApplication) builderClass.newInstance(); } catch (Throwable t) { <START> String errorMsg = String.format("Failed to validate StreamApplication class from the config. %s = %s", <END> StreamApplication.APP_CLASS_CONFIG, config.get(StreamApplication.APP_CLASS_CONFIG)); log.error(errorMsg, t); throw new ConfigException(String.format("%s is not a StreamApplication.", appClassName)); } } else { return null; } }</code><technical_language>"Failed create"? Also, update message in thrown ConfigException handler of exception log it. this error logged twice, messages</technical_language>

Target:
public static StreamApplication createStreamApplication(Config config) { if (config.get(StreamApplication.APP_CLASS_CONFIG) != null && !config.get(StreamApplication.APP_CLASS_CONFIG).isEmpty()) { TaskConfig taskConfig = new TaskConfig(config); if (taskConfig.getTaskClass() != null && !taskConfig.getTaskClass().isEmpty()) { throw new ConfigException("High level StreamApplication API cannot be used together with low-level API using task.class."); } String appClassName = config.get(StreamApplication.APP_CLASS_CONFIG); try { Class<?> builderClass = Class.forName(appClassName); return (StreamApplication) builderClass.newInstance(); } catch (Throwable t) { String errorMsg = String.format("Failed to create StreamApplication class from the config. %s = %s", StreamApplication.APP_CLASS_CONFIG, config.get(StreamApplication.APP_CLASS_CONFIG)); log.error(errorMsg, t); throw new ConfigException(errorMsg, t); } } else { return null; } }
Source:
<code>private void showErrorMessage(@StringRes int errorMsg, @NonNull Icon errorIcon) { if (!pageIsLoaded) { errorTextView.setVisibility(View.VISIBLE); errorTextView.setText(errorMsg); <START> TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(errorTextView, null, <END> new IconDrawable(getContext(), errorIcon) .sizeRes(getContext(), R.dimen.content_unavailable_error_icon_size) .colorRes(getContext(), R.color.edx_grayscale_neutral_light), null, null ); tryToClearWebView(); } }</code><technical_language>drawable is applied top, need "relative" method here, TextViewCompat</technical_language>

Target:
private void showErrorMessage(@StringRes int errorMsg, @NonNull Icon errorIcon) { if (!pageIsLoaded) { tryToClearWebView(); Context context = getContext(); errorTextView.setVisibility(View.VISIBLE); errorTextView.setText(errorMsg); errorTextView.setCompoundDrawablesWithIntrinsicBounds(null, new IconDrawable(context, errorIcon) .sizeRes(context, R.dimen.content_unavailable_error_icon_size) .colorRes(context, R.color.edx_grayscale_neutral_light), null, null ); } }
Source:
<code>public List<String> getAllExtensions() { final List<String> extensions = new LinkedList<>(); extensions.add(defaultExtension); <START> Optional.ofNullable(otherExtensions).map(Arrays::asList).ifPresent(extensions::addAll); <END> return Collections.unmodifiableList(extensions); }</code><technical_language>I prefer assume, fix if necessary, otherExtensions null (it empty anyway), this code easier: final List<String> extensions = new LinkedList<>(); extensions.add(defaultExtension); extensions.addAll(Arrays.asList(otherExtensions)); return Collections.unmodifiableList(extensions); IMO Optional.ofNullable for null-checking of instance unnecessary produce a bit of overhead, I prefer a conditional sentence instead... if (null != whatever) {}</technical_language>

Target:
public List<String> getAllExtensions() { final List<String> extensions = new LinkedList<>(); extensions.add(defaultExtension); extensions.addAll(Arrays.asList(otherExtensions)); return Collections.unmodifiableList(extensions); }
Source:
<code>private IProject getProject(final IJavaElementDelta delta) { final IJavaProject javaProject = delta.getElement().getJavaProject(); if (javaProject != null) { return javaProject.getProject(); } for (IJavaElementDelta affectedChild : delta.getAffectedChildren()) { <START> return getProject(affectedChild); <END> } return null; }</code><technical_language>returning iteration. of consequences of that</technical_language>

Target:
private IProject getProject(final IJavaElementDelta delta) { final IJavaProject javaProject = delta.getElement().getJavaProject(); if (javaProject != null) { return javaProject.getProject(); } for (IJavaElementDelta affectedChild : delta.getAffectedChildren()) { final IProject project = getProject(affectedChild); if(project != null) { return project; } } return null; }
Source:
<code>void initDropDownData() { this.isDropDownDataEnum = true; final Map<String, String> currentValueMap = new HashMap<String, String>(); if (constraintList != null && constraintList.getConstraints() != null) { for (FieldConstraint con : constraintList.getConstraints()) { if (con instanceof SingleFieldConstraint) { SingleFieldConstraint sfc = (SingleFieldConstraint) con; String fieldName = sfc.getFieldName(); currentValueMap.put(fieldName, sfc.getValue()); } } } this.dropDownData = oracle.getEnums(this.factType, fieldName, currentValueMap); <START> if (DataType.TYPE_BOOLEAN.equals(this.fieldType) && this.dropDownData != null) { <END> this.isDropDownDataEnum = false; this.dropDownData = DropDownData.create(new String[]{"true", "false"}); } }</code><technical_language>Is this if block correct? override declared enums for case, customer is complaining in ticket</technical_language>

Target:
void initDropDownData() { this.isDropDownDataEnum = true; final Map<String, String> currentValueMap = new HashMap<String, String>(); if (constraintList != null && constraintList.getConstraints() != null) { for (FieldConstraint con : constraintList.getConstraints()) { if (con instanceof SingleFieldConstraint) { SingleFieldConstraint sfc = (SingleFieldConstraint) con; String fieldName = sfc.getFieldName(); currentValueMap.put(fieldName, sfc.getValue()); } } } this.dropDownData = oracle.getEnums(this.factType, fieldName, currentValueMap); if (DataType.TYPE_BOOLEAN.equals(this.fieldType) && this.dropDownData == null) { this.isDropDownDataEnum = false; this.dropDownData = DropDownData.create(new String[]{"true", "false"}); } }
Source:
<code>public void testAggregationNodeSymbolMapping() { PlanBuilder builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata); ValuesNode values = builder.values(a, b); AggregationNode aggregation = builder.aggregation(aggregationBuilder -> aggregationBuilder .addGroupingSet(a, b) .addAggregation(c, builder.expression("count(b)"), ImmutableList.of(BIGINT)) .hashSymbol(a) .groupIdSymbol(a) .source(values)); AggregationNode mappedAggregation = SYMBOL_MAPPER.map(aggregation, values); assertEquals(mappedAggregation.getGroupingSets(), singletonList(singletonList(A))); assertEquals(mappedAggregation.getAggregations().keySet(), singleton(c)); assertEquals(getOnlyElement(mappedAggregation.getAggregations().values()).getCall().getArguments(), singletonList(A.toSymbolReference())); assertEquals(mappedAggregation.getHashSymbol().get(), c); <START> assertEquals(mappedAggregation.getGroupIdSymbol().get(), c); <END> }</code><technical_language>aggregation mask</technical_language>

Target:
public void testAggregationNodeSymbolMapping() { PlanBuilder builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata); ValuesNode values = builder.values(a, b); AggregationNode aggregationNode = builder.aggregation(aggregationBuilder -> aggregationBuilder .addGroupingSet(a, b) .addAggregation(c, builder.expression("count(b)"), ImmutableList.of(BIGINT), a) .hashSymbol(a) .groupIdSymbol(a) .source(values)); AggregationNode mappedAggregationNode = SYMBOL_MAPPER.map(aggregationNode, values); assertEquals(mappedAggregationNode.getGroupingSets(), singletonList(singletonList(A))); assertEquals(mappedAggregationNode.getAggregations().keySet(), singleton(c)); AggregationNode.Aggregation mappedAggregation = getOnlyElement(mappedAggregationNode.getAggregations().values()); assertEquals(mappedAggregation.getCall().getArguments(), singletonList(A.toSymbolReference())); assertEquals(mappedAggregation.getMask().get(), A); assertEquals(mappedAggregationNode.getHashSymbol().get(), A); assertEquals(mappedAggregationNode.getGroupIdSymbol().get(), A); }
Source:
<code>public void voidTestWrite() throws Exception { AmqpTemplate amqpTemplate = mock(AmqpTemplate.class); amqpTemplate.convertAndSend("foo"); amqpTemplate.convertAndSend("bar"); AmqpItemWriter<String> amqpItemWriter = new AmqpItemWriterBuilder<String>().amqpTemplate(amqpTemplate).build(); <START> amqpItemWriter.write(Arrays.asList("foo", "bar")); <END> }</code><technical_language>This test validate anything..</technical_language>

Target:
public void voidTestWrite() throws Exception { AmqpTemplate amqpTemplate = mock(AmqpTemplate.class); AmqpItemWriter<String> amqpItemWriter = new AmqpItemWriterBuilder<String>().amqpTemplate(amqpTemplate).build(); amqpItemWriter.write(Arrays.asList("foo", "bar")); verify(amqpTemplate).convertAndSend("foo"); verify(amqpTemplate).convertAndSend("bar"); }
Source:
<code>private void copyProjects() { File tmpDir = new File(EXTERNAL_STORAGE_ROOT_DIRECTORY, "/tmp"); if (tmpDir.exists()) { try { StorageOperations.deleteDir(tmpDir); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } try { copyProjectsFromExternalToInternalStorage(EXTERNAL_STORAGE_ROOT_DIRECTORY, FlavoredConstants.DEFAULT_ROOT_DIRECTORY); } catch (IOException e) { Log.e(TAG, e.getMessage()); <START> } <END> }</code><technical_language>move this out of this function showImportProjectsDialog is called, build a dialog if want show</technical_language>

Target:
private static boolean copyProjects() { File tmpDir = new File(OLD_EXTERNAL_STORAGE_ROOT_DIRECTORY, "/tmp"); if (tmpDir.exists()) { try { StorageOperations.deleteDir(tmpDir); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } try { copyFolderRecursive(OLD_EXTERNAL_STORAGE_ROOT_DIRECTORY, FlavoredConstants.DEFAULT_ROOT_DIRECTORY); return true; } catch (IOException e) { Log.e(TAG, e.getMessage()); return false; } }
Source:
<code>static public Expectation<java.util.UUID> insert(final OvsdbClient client, final Table table, Table.OvsdbInsert op) { final Expectation<java.util.UUID> result = new Expectation<>(); Expectation<OperationResult> opResult = singleOp(client, table.getDbSchema(), op); opResult.onComplete(new Expectation.OnComplete<OperationResult>() { @Override public void onSuccess(OperationResult r) { if (r.getCount() > 0) { Row<GenericTableSchema> row = r.getRows().get(0); result.success(table.parseUuid(row)); } else { result.success(null); } <START> } @Override public void onFailure(Throwable exc) { result.failure(exc); } }, callingThreadContext); <END> return result; }</code><technical_language>This chunk common functions, new Expectation.OnComplete<..> boilerplate. sense have: abstract class OperationWrapper extends Expectation.OnComplete<OperationResult> { // implement onFailure } code end as: opResult.onComplete(new OperationWrapper() { @Override public void onSuccess(OperationResult r) { ... } } is verbose, duplication. mandatory, a lot readability for next read :D</technical_language>

Target:
static public Expectation<java.util.UUID> insert(final OvsdbClient client, final Table table, Table.OvsdbInsert op) { final Expectation<java.util.UUID> result = new Expectation<>(); Expectation<OperationResult> opResult = singleOp(client, table.getDbSchema(), op); opResult.onComplete(new ResultWrapper<java.util.UUID>(result) { @Override public void onSuccess(OperationResult r) { if (r.getCount() > 0) { Row<GenericTableSchema> row = r.getRows().get(0); result.success(table.parseUuid(row)); } else { result.success(null); } } }, callingThreadContext); return result; }
Source:
<code>public DataSource create(Configuration hdpConfig) throws SQLException { LOG.debug("Creating Hikari connection pool for the MetaStore"); String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig); <START> LOG.info("XXX got url " + driverUrl + " from DataSourceProvider"); <END> String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig); String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig); int maxPoolSize = MetastoreConf.getIntVar(hdpConfig, MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS); Properties properties = replacePrefix( DataSourceProvider.getPrefixedProperties(hdpConfig, HIKARI)); long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L); HikariConfig config = null; try { config = new HikariConfig(properties); } catch (Exception e) { throw new SQLException("Cannot create HikariCP configuration: ", e); } config.setMaximumPoolSize(maxPoolSize); config.setJdbcUrl(driverUrl); config.setUsername(user); config.setPassword(passwd); config.setConnectionTimeout(connectionTimeout); return new HikariDataSource(config); }</code><technical_language>is this msg format intentional</technical_language>

Target:
public DataSource create(Configuration hdpConfig) throws SQLException { LOG.debug("Creating Hikari connection pool for the MetaStore"); String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig); String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig); String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig); int maxPoolSize = MetastoreConf.getIntVar(hdpConfig, MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS); Properties properties = replacePrefix( DataSourceProvider.getPrefixedProperties(hdpConfig, HIKARI)); long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L); HikariConfig config = null; try { config = new HikariConfig(properties); } catch (Exception e) { throw new SQLException("Cannot create HikariCP configuration: ", e); } config.setMaximumPoolSize(maxPoolSize); config.setJdbcUrl(driverUrl); config.setUsername(user); config.setPassword(passwd); config.setConnectionTimeout(connectionTimeout); return new HikariDataSource(config); }
Source:
<code>private String getAuthToken() { <START> return getIntent().getData().getQueryParameter(SignInActivity.TOKEN_PARAMETER); <END> }</code><technical_language>I need a null check getData() here. Right a problem hasMagicLinkLoginIntent() null check this is called, I this called road</technical_language>

Target:
private @Nullable String getAuthToken() { Uri uri = getIntent().getData(); return uri != null ? uri.getQueryParameter(SignInActivity.TOKEN_PARAMETER) : null; }
Source:
<code>public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) { Log.w("DBAdapter", "Upgrading from version " + oldVersion + " to " + newVersion + "."); DBUpgrader.upgrade(db, oldVersion, newVersion); <START> if (oldVersion == 1090000) { <END> db.execSQL("ALTER TABLE " + TABLE_NAME_FEEDS + " ADD COLUMN " + KEY_FEED_SKIP_INTRO + " INTEGER DEFAULT 0;"); db.execSQL("ALTER TABLE " + TABLE_NAME_FEEDS + " ADD COLUMN " + KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0;"); } }</code><technical_language>Please move this DBUpgrader. Also, oldVersion < 1090001. Users skip AntennaPod versions. checking for equality, this skips migration coming from, 1080100 instead of 1090000</technical_language>

Target:
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) { Log.w("DBAdapter", "Upgrading from version " + oldVersion + " to " + newVersion + "."); DBUpgrader.upgrade(db, oldVersion, newVersion); }
Source:
<code>public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ContainerPlacementMessage message = (ContainerPlacementMessage) o; <START> return getUuid().equals(message.getUuid()) && getDeploymentId().equals(message.getDeploymentId()) && getProcessorId().equals(message.getProcessorId()) && getDestinationHost().equals( message.getDestinationHost()); <END> }</code><technical_language>is expected ignoring requestExpiry, statusCode timestamp comparing? for other classes</technical_language>

Target:
public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ContainerPlacementMessage message = (ContainerPlacementMessage) o; return getTimestamp() == message.getTimestamp() && getUuid().equals(message.getUuid()) && getDeploymentId().equals( message.getDeploymentId()) && getProcessorId().equals(message.getProcessorId()) && getDestinationHost().equals( message.getDestinationHost()) && Objects.equals(getRequestExpiry(), message.getRequestExpiry()) && getStatusCode() == message.getStatusCode(); }
Source:
<code>public SchemaRegistrationResponse register(String subject, String format, String schema) { SchemaRegistrationResponse response = delegate.register(subject,format,schema); <START> cacheManager.getCache("refCache").put(response.getSchemaReference(),schema); <END> cacheManager.getCache("idCache").put(response.getId(),schema); return response; }</code><technical_language>cache names constants</technical_language>

Target:
public SchemaRegistrationResponse register(String subject, String format, String schema) { SchemaRegistrationResponse response = delegate.register(subject,format,schema); cacheManager.getCache(ID_CACHE).put(response.getSchemaReference(),schema); cacheManager.getCache(REF_CACHE).put(response.getId(),schema); return response; }