auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public synchronized void createIndex(DBObject keys, DBObject options, DBEncoder encoder) throws MongoException { DBCollection indexColl = fongoDb.getCollection("system.indexes"); BasicDBObject rec = new BasicDBObject(); rec.append("v", 1); rec.append("key", keys); rec.append("ns", this.getDB().getName() + "." + this.getName()); if (options != null && !options.containsField("name")) { StringBuilder sb = new StringBuilder(); boolean firstLoop = true; for (String keyName : keys.keySet()) { if (!firstLoop) { sb.append("_"); } sb.append(keyName).append("_").append(keys.get(keyName)); firstLoop = false; } rec.append("name", sb.toString()); } else { rec.append("name", options.get("name")); } if (indexColl.findOne(rec) != null) { return; } boolean unique = options != null && Boolean.TRUE.equals(options.get("unique")); if (unique) { rec.append("unique", unique); } rec.putAll(options); Index index = new Index((String) rec.get("name"), keys, unique); List<List<Object>> notUnique = index.addAll(_idIndex.values()); if (!notUnique.isEmpty()) { if (enforceDuplicates(getWriteConcern())) { fongoDb.errorResult(11000, "E11000 duplicate key error index: " + getFullName() + "." + rec.get("name") + " dup key: { : " + notUnique + " }").throwOnError(); } return; } <START> indexes.put(new HashSet<String>(index.getFields()), index); <END> indexColl.insert(rec); }</code><technical_language>If add compound indexes {a:1,_id:1} {a:1,_id:-1}, overwrite other</technical_language>

Target:
public synchronized void createIndex(DBObject keys, DBObject options, DBEncoder encoder) throws MongoException { DBCollection indexColl = fongoDb.getCollection("system.indexes"); BasicDBObject rec = new BasicDBObject(); rec.append("v", 1); rec.append("key", keys); rec.append("ns", this.getDB().getName() + "." + this.getName()); if (options != null && !options.containsField("name")) { StringBuilder sb = new StringBuilder(); boolean firstLoop = true; for (String keyName : keys.keySet()) { if (!firstLoop) { sb.append("_"); } sb.append(keyName).append("_").append(keys.get(keyName)); firstLoop = false; } rec.append("name", sb.toString()); } else { rec.append("name", options.get("name")); } if (indexColl.findOne(rec) != null) { return; } boolean unique = options != null && Boolean.TRUE.equals(options.get("unique")); if (unique) { rec.append("unique", unique); } rec.putAll(options); Index index = new Index((String) rec.get("name"), keys, unique, false); List<List<Object>> notUnique = index.addAll(_idIndex.values()); if (!notUnique.isEmpty()) { if (enforceDuplicates(getWriteConcern())) { fongoDb.errorResult(11000, "E11000 duplicate key error index: " + getFullName() + "." + rec.get("name") + " dup key: { : " + notUnique + " }").throwOnError(); } return; } indexes.add(index); indexColl.insert(rec); }
Source:
<code>public Document getDocumentById(String id) { ObjectId objectId = ObjectId.valueOf(id); switch (objectId.getType()) { <START> case REPOSITORY: <END> return cmisRepository(); case CONTENT: return cmisContent(objectId.getIdentifier()); case OBJECT: return cmisObject(objectId.getIdentifier()); default: return null; } }</code><technical_language>lets rename REPOSITORY_INFO</technical_language>

Target:
public Document getDocumentById(String id) { ObjectId objectId = ObjectId.valueOf(id); switch (objectId.getType()) { case REPOSITORY_INFO: return cmisRepository(); case CONTENT: return cmisContent(objectId.getIdentifier()); case OBJECT: return cmisObject(objectId.getIdentifier()); default: return null; } }
Source:
<code>private double getP99ForLeaderTime() { return conjureTimelockServiceBlockingMetrics .leaderTime() .getSnapshot() <START> .get99thPercentile(); <END> }</code><technical_language>nit: a function takes a Timer 99th percentile (then shared StartTransaction ones)</technical_language>

Target:
private double getP99ForLeaderTime() { return getP99(() -> conjureTimelockServiceBlockingMetrics.leaderTime()); }
Source:
<code>public void testWithEmptyArrays() { final byte[] authenthicationKey = new byte[1]; final byte[] encryptionKey = new byte[1]; final KeySet keySet = new KeySet(authenthicationKey, encryptionKey); final KeySetDto keySetDto = this.configurationMapper.map(keySet, KeySetDto.class); <START> assertNotNull(keySet); <END> assertNotNull(keySetDto); assertNotNull(keySetDto.getAuthenticationKey()); assertNotNull(keySetDto.getEncryptionKey()); assertEquals(keySet.getAuthenticationKey().length, keySetDto.getAuthenticationKey().length); assertEquals(keySet.getEncryptionKey().length, keySetDto.getEncryptionKey().length); }</code><technical_language>delete this line</technical_language>

Target:
public void testWithEmptyArrays() { final byte[] authenthicationKey = new byte[1]; final byte[] encryptionKey = new byte[1]; final KeySet keySet = new KeySet(authenthicationKey, encryptionKey); final KeySetDto keySetDto = this.configurationMapper.map(keySet, KeySetDto.class); assertNotNull(keySetDto); assertNotNull(keySetDto.getAuthenticationKey()); assertNotNull(keySetDto.getEncryptionKey()); assertEquals(keySet.getAuthenticationKey().length, keySetDto.getAuthenticationKey().length); assertEquals(keySet.getEncryptionKey().length, keySetDto.getEncryptionKey().length); }
Source:
<code>private static double estimateMinorAlleleFraction(final int a, final int r, final double bias) { final double altFraction = (double) a / (a + r); final double initialEstimate = altFraction < 0.5 ? altFraction : 1. - altFraction; final Function<Double, Double> objective = f -> { final double logf = Math.log(f); final double logOneMinusf = Math.log(1. - f); final double logBias = Math.log(bias); final double logAltMinorDenominatorTerm = Math.log(f + (1. - f)*bias); final double logRefMinorDenominatorTerm = Math.log(1. - f + f*bias); final double altMinorLogLikelihood = a * logf + r * (logOneMinusf + logBias) - (a + r) * logAltMinorDenominatorTerm; final double refMinorLogLikelihood = r * (logf + logBias) + a * logOneMinusf - (a + r) * logRefMinorDenominatorTerm; return GATKProtectedMathUtils.logSumExp(altMinorLogLikelihood, refMinorLogLikelihood); }; try { <START> return OptimizationUtils.argmax(objective, AlleleFractionState.MIN_MINOR_FRACTION, AlleleFractionState.MAX_MINOR_FRACTION, initialEstimate); <END> }catch (final TooManyArgumentsException ex){ return initialEstimate; } }</code><technical_language>Space catch {</technical_language>

Target:
private static double estimateMinorAlleleFraction(final int a, final int r, final double bias) { final double altFraction = (double) a / (a + r); final double initialEstimate = altFraction < 0.5 ? altFraction : 1. - altFraction; final Function<Double, Double> objective = f -> { final double logf = Math.log(f); final double logOneMinusf = Math.log(1. - f); final double logBias = Math.log(bias); final double logAltMinorDenominatorTerm = Math.log(f + (1. - f)*bias); final double logRefMinorDenominatorTerm = Math.log(1. - f + f*bias); final double altMinorLogLikelihood = a * logf + r * (logOneMinusf + logBias) - (a + r) * logAltMinorDenominatorTerm; final double refMinorLogLikelihood = r * (logf + logBias) + a * logOneMinusf - (a + r) * logRefMinorDenominatorTerm; return GATKProtectedMathUtils.logSumExp(altMinorLogLikelihood, refMinorLogLikelihood); }; try { return OptimizationUtils.argmax(objective, AlleleFractionState.MIN_MINOR_FRACTION, AlleleFractionState.MAX_MINOR_FRACTION, initialEstimate); } catch (final TooManyEvaluationsException ex){ return initialEstimate; } }
Source:
<code>void shutdown() { if (m_isShutdown) { return; } m_isShutdown = true; try { int waitFor = 1 - Math.min(m_inFlight.availablePermits(), -4); for (int i = 0; i < waitFor; ++i) { try { if (m_inFlight.tryAcquire(1, TimeUnit.SECONDS)) { m_inFlight.release(); break; } } catch (InterruptedException e) { break; } } m_ecryptgw.die(); EncryptedMessages messages = null; while ((messages = m_encryptedQueue.poll()) != null) { messages.m_messages.release(); } <START> if (m_inflightMessages != null && m_inflightMessages.m_messages != null && m_inflightMessages.m_messages.refCnt() > 0) { <END> m_inflightMessages.m_messages.release(); } } finally { m_inFlight.drainPermits(); m_inFlight.release(); } }</code><technical_language>m_messages null check is necessary. I is a bug if m_inflightMessages != null && m_inflightMessages.m_messages.refCnt() == 0. release of messages m_inflightMessages set null</technical_language>

Target:
void shutdown() { if (m_isShutdown) { return; } m_isShutdown = true; try { int waitFor = 1 - Math.min(m_inFlight.availablePermits(), -4); for (int i = 0; i < waitFor; ++i) { try { if (m_inFlight.tryAcquire(1, TimeUnit.SECONDS)) { m_inFlight.release(); break; } } catch (InterruptedException e) { break; } } m_ecryptgw.die(); EncryptedMessages messages = null; while ((messages = m_encryptedQueue.poll()) != null) { messages.m_messages.release(); } if (m_inflightMessages != null) { assert (m_inflightMessages.m_messages != null && m_inflightMessages.m_messages.refCnt() > 0); m_inflightMessages.m_messages.release(); } } finally { m_inFlight.drainPermits(); m_inFlight.release(); } }
Source:
<code>public String version() { <START> if (version == "") { <END> this.version = ping().getVersion(); } return this.version; }</code><technical_language>programming in Javascript here. :-P replacing "" null remove "" variable declaration</technical_language>

Target:
public String version() { if (version == null) { this.version = ping().getVersion(); } return this.version; }
Source:
<code>private static List<Double> buildVariableStatistics( PlanNodeStatsEstimate left, PlanNodeStatsEstimate right, PlanNodeStatsEstimate.Builder statsBuilder, double estimatedRowCount, RangeAdditionStrategy rangeAdder) { <START> List<Double> allRowCounts = new LinkedList<>(); <END> concat(left.getVariablesWithKnownStatistics().stream(), right.getVariablesWithKnownStatistics().stream()) .distinct() .forEach(symbol -> { VariableStatsEstimate symbolStats = VariableStatsEstimate.zero(); if (estimatedRowCount > 0) { symbolStats = addColumnStats( left.getVariableStatistics(symbol), left.getOutputRowCount(), right.getVariableStatistics(symbol), right.getOutputRowCount(), estimatedRowCount, rangeAdder); } statsBuilder.addVariableStatistics(symbol, symbolStats); allRowCounts.add(symbolStats.getDistinctValuesCount()); }); return allRowCounts; }</code><technical_language>nit: Please ImmutableList.builder()</technical_language>

Target:
private static void buildVariableStatistics( PlanNodeStatsEstimate left, PlanNodeStatsEstimate right, PlanNodeStatsEstimate.Builder statsBuilder, double estimatedRowCount, RangeAdditionStrategy rangeAdder) { concat(left.getVariablesWithKnownStatistics().stream(), right.getVariablesWithKnownStatistics().stream()) .distinct() .forEach(symbol -> { VariableStatsEstimate symbolStats = VariableStatsEstimate.zero(); if (estimatedRowCount > 0) { symbolStats = addColumnStats( left.getVariableStatistics(symbol), left.getOutputRowCount(), right.getVariableStatistics(symbol), right.getOutputRowCount(), estimatedRowCount, rangeAdder); } statsBuilder.addVariableStatistics(symbol, symbolStats); }); }
Source:
<code>public static void init() { client = new ResteasyClientBuilder().build(); StringBuilder sb = new StringBuilder(); <START> for (int i = 1; i <= 10 * 1024 * 1024; i++) { <END> sb.append("A"); } original = sb.toString(); StringBuilder sb2 = new StringBuilder(); for (int i = 1; i <= 256; i++) { sb2.append("A"); } trimmed = sb2.toString(); }</code><technical_language>Do need 10M ? 1MB 500K enough for sake of test</technical_language>

Target:
public static void init() { client = new ResteasyClientBuilder().build(); StringBuilder sb = new StringBuilder(); for (int i = 1; i <= 1024; i++) { sb.append("A"); } original = sb.toString(); StringBuilder sb2 = new StringBuilder(); for (int i = 1; i <= 256; i++) { sb2.append("A"); } trimmed = sb2.toString(); }
Source:
<code>public void createRetentionPolicy(final String rpName, final String database, final String duration, final String shardDuration, final int replicationFactor, final boolean isDefault) { Preconditions.checkNonEmptyString(rpName, "retentionPolicyName"); Preconditions.checkNonEmptyString(database, "database"); Preconditions.checkNonEmptyString(duration, "retentionDuration"); Preconditions.checkDuration(duration, "retentionDuration"); if (shardDuration != null && !shardDuration.isEmpty()) { Preconditions.checkDuration(shardDuration, "shardDuration"); } Preconditions.checkPositiveNumber(replicationFactor, "replicationFactor"); StringBuilder queryBuilder = new StringBuilder("CREATE RETENTION POLICY \""); <START> queryBuilder.append(rpName).append("\" ON \"").append(database).append("\" DURATION ").append(duration) <END> .append(" REPLICATION ").append(replicationFactor); if (shardDuration != null && !shardDuration.isEmpty()) { queryBuilder.append(" SHARD DURATION "); queryBuilder.append(shardDuration); } if (isDefault) { queryBuilder.append(" DEFAULT"); } execute(this.influxDBService.postQuery(this.username, this.password, Query.encode(queryBuilder.toString()))); }</code><technical_language>formatting</technical_language>

Target:
public void createRetentionPolicy(final String rpName, final String database, final String duration, final String shardDuration, final int replicationFactor, final boolean isDefault) { Preconditions.checkNonEmptyString(rpName, "retentionPolicyName"); Preconditions.checkNonEmptyString(database, "database"); Preconditions.checkNonEmptyString(duration, "retentionDuration"); Preconditions.checkDuration(duration, "retentionDuration"); if (shardDuration != null && !shardDuration.isEmpty()) { Preconditions.checkDuration(shardDuration, "shardDuration"); } Preconditions.checkPositiveNumber(replicationFactor, "replicationFactor"); StringBuilder queryBuilder = new StringBuilder("CREATE RETENTION POLICY \""); queryBuilder.append(rpName) .append("\" ON \"") .append(database) .append("\" DURATION ") .append(duration) .append(" REPLICATION ") .append(replicationFactor); if (shardDuration != null && !shardDuration.isEmpty()) { queryBuilder.append(" SHARD DURATION "); queryBuilder.append(shardDuration); } if (isDefault) { queryBuilder.append(" DEFAULT"); } executeQuery(this.influxDBService.postQuery(this.username, this.password, Query.encode(queryBuilder.toString()))); }
Source:
<code><START> public void changeMode( <END> @QueryParam("mode") String mode, @QueryParam("reason") String reason) { Mode m = Mode.valueOf(mode); modeManager.enterMode(m, reason); }</code><technical_language>Please add TODO item this removed merged master</technical_language>

Target:
public void changeMode( @QueryParam("mode") String mode, @QueryParam("reason") String reason) { Mode m = Mode.valueOf(mode); Reason r = Reason.valueOf(reason); modeManager.enterMode(m, r); }
Source:
<code>public String getDisplayName() { <START> return "Other Jenkins Configuration Files (secrets are filtered out unless saved in clear in the .xml files)"; <END> }</code><technical_language>Text is slightly I is focus positive, e.g. redact encrypted secrets... leaves unsaid implies non-redaction of "secrets" redacted</technical_language>

Target:
public String getDisplayName() { return "Other Jenkins Configuration Files (Encrypted secrets are redacted)"; }
Source:
<code><START> public List<OutputTestResultDto> testOutput(UUID resultId, UUID taskId, MultipartFile[] files) throws IOException { <END> Result result = resultRepository.findOne(resultId); if (result == null) { throw new IllegalArgumentException("result.invalid"); } Task task = taskRepository.findOneWithTests(taskId); if (task == null) { throw new IllegalArgumentException("task.invalid"); } TaskResult taskResult = taskResultService.findByTaskAndResult(taskId, resultId); Submission submission = new Submission(); submission.setTaskResult(taskResult); submission.setSubmissionTime(ZonedDateTime.now()); submission = repository.save(submission); List<OutputTestResultDto> testResults = new ArrayList<>(); boolean green = true; for (MultipartFile file: files){ UUID testId = UUID.fromString(file.getOriginalFilename()); Test test = testRepository.findOneWithRunner(testId); boolean testResult = runOutputTest(submission, test, file); testResults.add(new OutputTestResultDto(testId, testResult)); green = green && testResult; } if (testResults.size() == task.getTests().size() && green){ submission.setGreen(true); repository.save(submission); taskResultService.finishTaskResult(taskResult, submission.getSubmissionTime(), true); } return testResults; }</code><technical_language>Newline method</technical_language>

Target:
public List<OutputTestResultDto> testOutput(UUID resultId, UUID taskId, MultipartFile[] files) throws IOException { Result result = resultRepository.findOne(resultId); if (result == null) { throw new IllegalArgumentException("result.invalid"); } Task task = taskRepository.findOneWithTests(taskId); if (task == null) { throw new IllegalArgumentException("task.invalid"); } TaskResult taskResult = taskResultService.findByTaskAndResult(taskId, resultId); Submission submission = new Submission(); submission.setTaskResult(taskResult); submission.setSubmissionTime(ZonedDateTime.now()); submission = repository.save(submission); List<OutputTestResultDto> testResults = new ArrayList<>(files.length); boolean green = true; for (MultipartFile file : files) { UUID testId = UUID.fromString(file.getOriginalFilename()); Test test = testRepository.findOneWithRunner(testId); OutputTestResultDto testResult = runOutputTest(submission, test, file); testResults.add(testResult); green = green && testResult.isGreen(); } if (testResults.size() == task.getTests().size() && green) { submission.setGreen(true); repository.save(submission); taskResultService.finishTaskResult(taskResult, submission.getSubmissionTime(), true); } return testResults; }
Source:
<code>protected String getAuthorizationBaseUrl() { throw new UnsupportedOperationException("use getAuthorizationUrl instead"); <START> } <END></code><technical_language>implement this method protected String getAuthorizationBaseUrl() { return "<LINK_0>"; } remove getAuthorizationUrl here. difference overrided impl in DefaultApi20</technical_language>

Target:
protected String getAuthorizationBaseUrl() { return "<LINK_0>"; }
Source:
<code>public boolean supportsFormat(String format) { <START> if (format == null || format.length() == 0) { <END> return false; } return serviceMetadata.getSupportedFormats().stream() .anyMatch(f -> format.equals(f)); }</code><technical_language>length() == 0 -> isEmpty(). stop mentioning for rest of :)</technical_language>

Target:
public boolean supportsFormat(String format) { if (format == null || format.isEmpty()) { return false; } return serviceMetadata.getSupportedFormats().stream() .anyMatch(f -> format.equals(f)); }
Source:
<code>public FragmentationDuplexConnection( DuplexConnection delegate, ByteBufAllocator allocator, int mtu, boolean encodeLength) { Objects.requireNonNull(delegate, "delegate must not be null"); Objects.requireNonNull(allocator, "byteBufAllocator must not be null"); if (mtu < MIN_MTU_SIZE) { <START> throw new IllegalArgumentException("smallest allowed mtu size is 64 bytes"); <END> } this.encodeLength = encodeLength; this.allocator = allocator; this.delegate = delegate; this.mtu = mtu; this.frameReassembler = new FrameReassembler(allocator); delegate.onClose().doFinally(s -> frameReassembler.dispose()).subscribe(); }</code><technical_language>for a hot path exception, worth referring MIN_MTU_SIZE in message instead of 64</technical_language>

Target:
public FragmentationDuplexConnection( DuplexConnection delegate, ByteBufAllocator allocator, int mtu, boolean encodeLength) { Objects.requireNonNull(delegate, "delegate must not be null"); Objects.requireNonNull(allocator, "byteBufAllocator must not be null"); if (mtu < MIN_MTU_SIZE) { throw new IllegalArgumentException("smallest allowed mtu size is " + MIN_MTU_SIZE + " bytes"); } this.encodeLength = encodeLength; this.allocator = allocator; this.delegate = delegate; this.mtu = mtu; this.frameReassembler = new FrameReassembler(allocator); delegate.onClose().doFinally(s -> frameReassembler.dispose()).subscribe(); }
Source:
<code>public List<CourseGroup> getLecturing() { <START> String userId = proxy.getCurrentUser().getDisplayName(); <END> List <CourseGroupDAO> groupDaos = dao.findLecturingCourseGroups(userId); List<CourseGroup> groups = new ArrayList<CourseGroup>(groupDaos.size()); for(CourseGroupDAO groupDao : groupDaos) { groups.add(new CourseGroupImpl(groupDao, this)); } return groups; }</code><technical_language>display name todo a search userId. is a bug in UserProxy this code is wrong</technical_language>

Target:
public List<CourseGroup> getLecturing() { String userId = proxy.getCurrentUser().getId(); List <CourseGroupDAO> groupDaos = dao.findLecturingCourseGroups(userId); List<CourseGroup> groups = new ArrayList<CourseGroup>(groupDaos.size()); for(CourseGroupDAO groupDao : groupDaos) { groups.add(new CourseGroupImpl(groupDao, this)); } return groups; }
Source:
<code>private UserEx getUserFromTwitterLinkage(PartakeConnection con, IPartakeDAOs daos, UserTwitterLink twitterLinkage) throws DAOException, TwitterException { String userId = twitterLinkage.getUserId(); User user = daos.getUserAccess().find(con, userId); if (user == null) { user = new User(userId, twitterLinkage.getScreenName(), twitterLinkage.getProfileImageURL(), TimeUtil.getCurrentDateTime(), null); } else if (!verifyUserProfiles(user, twitterLinkage)) { user = new User(user); user.setScreenName(twitterLinkage.getScreenName()); user.setProfileImageURL(twitterLinkage.getProfileImageURL()); } <START> daos.getUserAccess().put(con, user); <END> user.freeze(); return new UserEx(user, twitterLinkage); }</code><technical_language>In case this put() is needless. I put this if block</technical_language>

Target:
private UserEx getUserFromTwitterLinkage(PartakeConnection con, IPartakeDAOs daos, UserTwitterLink twitterLinkage) throws DAOException, TwitterException { String userId = twitterLinkage.getUserId(); User user = daos.getUserAccess().find(con, userId); if (user == null) { user = new User(userId, twitterLinkage.getScreenName(), twitterLinkage.getProfileImageURL(), TimeUtil.getCurrentDateTime(), null); daos.getUserAccess().put(con, user); user.freeze(); } else { if (!verifyUserProfiles(user, twitterLinkage)) { user = new User(user); user.setScreenName(twitterLinkage.getScreenName()); user.setProfileImageURL(twitterLinkage.getProfileImageURL()); daos.getUserAccess().put(con, user); user.freeze(); } } return new UserEx(user, twitterLinkage); }
Source:
<code>public SleepStatsSample map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException { final SleepStats stats = new SleepStats( resultSet.getInt("sound_sleep"), resultSet.getInt("light_sleep"), resultSet.getInt("duration"), resultSet.getInt("motion"), <START> resultSet.getTimestamp("sleep_time_utc").getTime(), <END> resultSet.getTimestamp("wake_time_utc").getTime(), resultSet.getInt("fall_asleep_time") ); return new SleepStatsSample(stats, new DateTime(resultSet.getTimestamp("local_utc_date"), DateTimeZone.UTC), resultSet.getInt("offset_millis") ); }</code><technical_language>getTime timestamp. local time tz aware. use: java new DateTime(resultSet.getTimestamp("sleep_time_utc", DateTimeZone.UTC); other mappers for inspiration</technical_language>

Target:
public SleepStatsSample map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException { final DateTime sleepTime = new DateTime(resultSet.getTimestamp("sleep_time_utc"), DateTimeZone.UTC); final DateTime wakeTime = new DateTime(resultSet.getTimestamp("wake_time_utc"), DateTimeZone.UTC); final SleepStats stats = new SleepStats( resultSet.getInt("sound_sleep"), resultSet.getInt("light_sleep"), resultSet.getInt("duration"), resultSet.getInt("motion"), sleepTime.getMillis(), wakeTime.getMillis(), resultSet.getInt("fall_asleep_time") ); return new SleepStatsSample(stats, new DateTime(resultSet.getTimestamp("local_utc_date"), DateTimeZone.UTC), resultSet.getInt("offset_millis") ); }
Source:
<code>public void testEquals() throws Exception { final RevCommit a1 = commit(); final RevCommit b1 = commit(); assertEquals(a1, a1); <START> assertEquals(a1, a1); <END> assertFalse(a1.equals(b1)); assertEquals(a1, a1); assertEquals(a1, a1); assertFalse(a1.equals("")); final RevWalk rw2 = new RevWalk(db); final RevCommit a2 = rw2.parseCommit(a1); final RevCommit b2 = rw2.parseCommit(b1); assertNotSame(a1, a2); assertNotSame(b1, b2); assertEquals(a2, a1); assertEquals(b2, b1); assertEquals(a1.hashCode(), a2.hashCode()); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(AnyObjectId.equals(a1, a2)); assertTrue(AnyObjectId.equals(b1, b2)); }</code><technical_language>I understand arguments calling exact assertion is redundant unnecessary,</technical_language>

Target:
public void testEquals() throws Exception { final RevCommit a1 = commit(); final RevCommit b1 = commit(); assertTrue(a1.equals(a1)); assertTrue(a1.equals((Object) a1)); assertFalse(a1.equals(b1)); assertTrue(a1.equals(a1)); assertTrue(a1.equals((Object) a1)); assertFalse(a1.equals("")); final RevWalk rw2 = new RevWalk(db); final RevCommit a2 = rw2.parseCommit(a1); final RevCommit b2 = rw2.parseCommit(b1); assertNotSame(a1, a2); assertNotSame(b1, b2); assertTrue(a1.equals(a2)); assertTrue(b1.equals(b2)); assertEquals(a1.hashCode(), a2.hashCode()); assertEquals(b1.hashCode(), b2.hashCode()); assertTrue(AnyObjectId.equals(a1, a2)); assertTrue(AnyObjectId.equals(b1, b2)); }
Source:
<code>public final ResultIterator iterator(final List<SQLCloseable> dependencies) throws SQLException { if (context.getScanRanges() == ScanRanges.NOTHING) { return ResultIterator.EMPTY_ITERATOR; } Scan scan = context.getScan(); PhoenixConnection connection = context.getConnection(); Long scn = connection.getSCN(); ScanUtil.setTimeRange(scan, scn == null ? context.getCurrentTime() : scn); ScanUtil.setTenantId(scan, connection.getTenantId() == null ? null : connection.getTenantId().getBytes()); ResultIterator iterator = newIterator(); <START> return dependencies == null || dependencies.isEmpty() ? <END> iterator : new DelegateResultIterator(iterator) { @Override public void close() throws SQLException { super.close(); SQLCloseables.closeAll(dependencies); } }; }</code><technical_language>null check need</technical_language>

Target:
public final ResultIterator iterator(final List<SQLCloseable> dependencies) throws SQLException { if (context.getScanRanges() == ScanRanges.NOTHING) { return ResultIterator.EMPTY_ITERATOR; } Scan scan = context.getScan(); PhoenixConnection connection = context.getConnection(); Long scn = connection.getSCN(); ScanUtil.setTimeRange(scan, scn == null ? context.getCurrentTime() : scn); ScanUtil.setTenantId(scan, connection.getTenantId() == null ? null : connection.getTenantId().getBytes()); ResultIterator iterator = newIterator(); return dependencies.isEmpty() ? iterator : new DelegateResultIterator(iterator) { @Override public void close() throws SQLException { try { super.close(); } finally { SQLCloseables.closeAll(dependencies); } } }; }
Source:
<code>public void withDataImportSAV(String userAction, final Command command) { withDependencies( <START> "Preparing Import from SAV", <END> userAction, dataImportSavDependenciesArray(), false, new CommandWithArg<Boolean>() { @Override public void execute(Boolean succeeded) { if (succeeded) command.execute(); } } ); }</code><technical_language>I want refer "SAV" "SPSS". sense</technical_language>

Target:
public void withDataImportSAV(String userAction, final Command command) { withDependencies( "Preparing Import from SPSS, SAS and Stata", userAction, dataImportSavDependenciesArray(), false, new CommandWithArg<Boolean>() { @Override public void execute(Boolean succeeded) { if (succeeded) command.execute(); } } ); }
Source:
<code><START> public Client createWithDropwizardClient(PaymentGatewayName gateway, Optional<GatewayOperation> operation, MetricRegistry metricRegistry) { <END> JerseyClientConfiguration clientConfiguration = conf.getClientConfiguration(); JerseyClientBuilder defaultClientBuilder = new JerseyClientBuilder(environment) .using(new ApacheConnectorProvider()) .using(clientConfiguration); if (operation.isPresent()) { defaultClientBuilder .withProperty(READ_TIMEOUT, getReadTimeoutInMillis(operation.get(), gateway)) .withProperty(CONNECTION_MANAGER, createConnectionManager(gateway.getName(), operation.get().getConfigKey(), metricRegistry)); } else { defaultClientBuilder .withProperty(READ_TIMEOUT, getDefaultTimeout()) .withProperty(CONNECTION_MANAGER, createConnectionManager(gateway.getName(), "all", metricRegistry)); } if (conf.getCustomJerseyClient().isProxyEnabled()) { defaultClientBuilder .withProperty(ClientProperties.PROXY_URI, proxyUrl(clientConfiguration.getProxyConfiguration())); } Client client = defaultClientBuilder.build(gateway.getName()); client.register(RestClientLoggingFilter.class); if (conf.isXrayEnabled()) client.register(XRayHttpClientFilter.class); return client; }</code><technical_language>Optionals argument is a bit smelly, I in this case is necessary - overloaded createWithDropwizardClient (as createGatewayClient)</technical_language>

Target:
private Client createWithDropwizardClient(PaymentGatewayName gateway, Optional<GatewayOperation> operation, MetricRegistry metricRegistry) { JerseyClientConfiguration clientConfiguration = conf.getClientConfiguration(); JerseyClientBuilder defaultClientBuilder = new JerseyClientBuilder(environment) .using(new ApacheConnectorProvider()) .using(clientConfiguration); if (operation.isPresent()) { defaultClientBuilder .withProperty(READ_TIMEOUT, getReadTimeoutInMillis(operation.get(), gateway)) .withProperty(CONNECTION_MANAGER, createConnectionManager(gateway.getName(), operation.get().getConfigKey(), metricRegistry)); } else { defaultClientBuilder .withProperty(READ_TIMEOUT, getDefaultTimeout()) .withProperty(CONNECTION_MANAGER, createConnectionManager(gateway.getName(), "all", metricRegistry)); } if (conf.getCustomJerseyClient().isProxyEnabled()) { defaultClientBuilder .withProperty(ClientProperties.PROXY_URI, proxyUrl(clientConfiguration.getProxyConfiguration())); } Client client = defaultClientBuilder.build(gateway.getName()); client.register(RestClientLoggingFilter.class); if (conf.isXrayEnabled()) client.register(XRayHttpClientFilter.class); return client; }
Source:
<code>private void inspectGetCommand() { String parentPath = "."; if (!m_voltdbRoot.exists()) { try { parentPath = m_voltdbRoot.getCanonicalFile().getParent(); } catch (IOException io) System.err.println("FATAL: " + parentPath + " does not contain a " + "valid database root directory. Use the --dir option to specify the path to the root."); referToDocAndExit(); } File configInfoDir = new VoltFile(m_voltdbRoot, Constants.CONFIG_DIR); switch (m_getOption) { case DEPLOYMENT: { File depFH = new VoltFile(configInfoDir, "deployment.xml"); if (!depFH.exists()) { System.out.println("FATAL: Deployment file \"" + depFH.getAbsolutePath() + "\" not found."); referToDocAndExit(); } m_pathToDeployment = depFH.getAbsolutePath(); return; } case SCHEMA: case CLASSES: { File catalogFH = new VoltFile(configInfoDir, "catalog.jar"); if (!catalogFH.exists()) { try { parentPath = m_voltdbRoot.getCanonicalFile().getParent(); } catch (IOException io) <START> System.out.println("FATAL: "+ m_getOption.name().toUpperCase() + " not found in the provided database directory " + parentPath + <END> ". Make sure the database has been started "); referToDocAndExit(); } m_pathToCatalog = catalogFH.getAbsolutePath(); return; } } }</code><technical_language>exception parentpath is defined. get parentpath getParent() getCanonicalFile(), call parentPath = m_voltdbRoot.getCanonicalFile().getParent()</technical_language>

Target:
private void inspectGetCommand() { String parentPath = m_voltdbRoot.getParent(); if (!m_voltdbRoot.exists()) { try { parentPath = m_voltdbRoot.getCanonicalFile().getParent(); } catch (IOException io) System.err.println("FATAL: " + parentPath + " does not contain a " + "valid database root directory. Use the --dir option to specify the path to the root."); referToDocAndExit(); } File configInfoDir = new VoltFile(m_voltdbRoot, Constants.CONFIG_DIR); switch (m_getOption) { case DEPLOYMENT: { File depFH = new VoltFile(configInfoDir, "deployment.xml"); if (!depFH.exists()) { System.out.println("FATAL: Deployment file \"" + depFH.getAbsolutePath() + "\" not found."); referToDocAndExit(); } m_pathToDeployment = depFH.getAbsolutePath(); return; } case SCHEMA: case CLASSES: { File catalogFH = new VoltFile(configInfoDir, "catalog.jar"); if (!catalogFH.exists()) { try { parentPath = m_voltdbRoot.getCanonicalFile().getParent(); } catch (IOException io) System.err.println("FATAL: "+ m_getOption.name().toUpperCase() + " not found in the provided database directory " + parentPath + ". Make sure the database has been started "); referToDocAndExit(); } m_pathToCatalog = catalogFH.getAbsolutePath(); return; } } }
Source:
<code>public void testMultipleClients() throws Throwable { <START> try (Connection clientA = CLUSTER.newConnection()) { <END> VoltronReadWriteLock lockA = new VoltronReadWriteLock(clientA, "test"); Hold hold = lockA.writeLock(); try (Connection clientB = CLUSTER.newConnection()) { Future<Void> waiter = async(() -> { new VoltronReadWriteLock(clientB, "test").writeLock().unlock(); return null; }); try { waiter.get(100, TimeUnit.MILLISECONDS); fail("TimeoutException expected"); } catch (TimeoutException e) { } CLUSTER.getClusterControl().terminateActive(); CLUSTER.getClusterControl().startOneServer(); try { waiter.get(100, TimeUnit.MILLISECONDS); fail("TimeoutException expected"); } catch (TimeoutException e) { } hold.unlock(); waiter.get(); } } }</code><technical_language>Possibly collapse</technical_language>

Target:
public void testMultipleClients() throws Throwable { try (Connection clientA = CLUSTER.newConnection(); Connection clientB = CLUSTER.newConnection()) { VoltronReadWriteLock lockA = new VoltronReadWriteLock(clientA, "test"); Hold hold = lockA.writeLock(); Future<Void> waiter = async(() -> { new VoltronReadWriteLock(clientB, "test").writeLock().unlock(); return null; }); try { waiter.get(100, TimeUnit.MILLISECONDS); fail("TimeoutException expected"); } catch (TimeoutException e) { } CLUSTER.getClusterControl().terminateActive(); CLUSTER.getClusterControl().startOneServer(); try { waiter.get(100, TimeUnit.MILLISECONDS); fail("TimeoutException expected"); } catch (TimeoutException e) { } hold.unlock(); waiter.get(); } }
Source:
<code>public static String toString(final Integer code, final String label) { return new StringBuffer() <START> .append(String.format("[%04d]", code)) <END> .append(" - ") .append(label) .toString(); }</code><technical_language>do force code 4 digits? btw happen if a new reason code is added 5 digits? In case, a good idea put format in a static variable enum</technical_language>

Target:
public static String toString(final Integer code, final String label) { return new StringBuffer() .append(String.format("["+CODE_FORMAT+"]", code)) .append(" - ") .append(label) .toString(); }
Source:
<code>public CloudCheckrWrapper getCloudCheckrWrapper(String startDate, String endDate, String masterAccountName) throws URISyntaxException, IOException { String cloudCheckrURL = findCloudCheckrEndPoint(); String formattedUrl = MessageFormat.format(cloudCheckrURL, startDate, endDate, masterAccountName); Response response = null; try { Invocation request = buildReportDetailsClientRequest(formattedUrl); response = request.invoke(); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(CloudCheckrWrapper.class); } else { <START> LOG.error("getCloudCheckrWrapper, error calling enpoint. The HTTP response was " + response.getStatus()); <END> throw new IOException("Invalid response code: " + response.getStatus()); } } finally { CURestClientUtils.closeQuietly(response); } }</code><technical_language>Minor typo in sentence of error message</technical_language>

Target:
public CloudCheckrWrapper getCloudCheckrWrapper(String startDate, String endDate, String masterAccountName) throws URISyntaxException, IOException { String cloudCheckrURL = findCloudCheckrEndPoint(); String formattedUrl = MessageFormat.format(cloudCheckrURL, startDate, endDate, masterAccountName); Response response = null; try { Invocation request = buildReportDetailsClientRequest(formattedUrl); response = request.invoke(); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return response.readEntity(CloudCheckrWrapper.class); } else { LOG.error("getCloudCheckrWrapper, error calling endpoint. The HTTP response was " + response.getStatus()); throw new IOException("Invalid response code: " + response.getStatus()); } } finally { CURestClientUtils.closeQuietly(response); } }
Source:
<code>private void doAuthManagerLogin() { final String username = usernameText.getText().toString(); final String password = passwordText.getText().toString(); new AMLoginTask(username, password) { @Override public void onBeforeExecute() { progressDialog.show(); } @Override public void onCatch(Throwable caught) { <START> L.d("Caught " + caught.toString()); <END> if (!progressDialog.isShowing()) { return; } progressDialog.dismiss(); FeedbackUtil.showError(LoginActivity.this, caught); } @Override public void onFinish(AMLoginResult result) { super.onFinish(result); if (!progressDialog.isShowing()) { return; } progressDialog.dismiss(); if ("PASS".equals(result.getStatus())) { funnel.logSuccess(); Bundle extras = getIntent().getExtras(); AccountAuthenticatorResponse response = extras == null ? null : extras.<AccountAuthenticatorResponse>getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); AccountUtil.createAccount(response, username, password); hideSoftKeyboard(LoginActivity.this); setResult(RESULT_LOGIN_SUCCESS); finish(); } else if ("FAIL".equals(result.getStatus())) { funnel.logError(result.getMessage()); handleAuthManagerError(result.getMessage()); } } }.execute(); }</code><technical_language>I SaneAsyncTasks print caught error this line removed</technical_language>

Target:
private void doAuthManagerLogin() { final String username = usernameText.getText().toString(); final String password = passwordText.getText().toString(); new AMLoginTask(username, password) { @Override public void onBeforeExecute() { progressDialog.show(); } @Override public void onCatch(Throwable caught) { if (!progressDialog.isShowing()) { return; } progressDialog.dismiss(); FeedbackUtil.showError(LoginActivity.this, caught); } @Override public void onFinish(AMLoginResult result) { super.onFinish(result); if (!progressDialog.isShowing()) { return; } progressDialog.dismiss(); if (result.pass()) { funnel.logSuccess(); Bundle extras = getIntent().getExtras(); AccountAuthenticatorResponse response = extras == null ? null : extras.<AccountAuthenticatorResponse>getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); AccountUtil.createAccount(response, username, password); hideSoftKeyboard(LoginActivity.this); setResult(RESULT_LOGIN_SUCCESS); finish(); } else if (result.fail()) { funnel.logError(result.getMessage()); handleAuthManagerError(result.getMessage()); } } }.execute(); }
Source:
<code>private void onExit() { <START> int s = exitTasks.size(); <END> for (int i = 0; i < s; i ++) { if (exitTasks.size() <= i) { break; } exitTasks.get(i).run(); } }</code><technical_language>I suggest checking == 0, for (int i = 0; i < s; i ++) { exitTasks.get(i).run(); // in case previous task cleared list if (exitTasks.size() == 0) { break; } } Another qq, tasks added this function is called? I onExit() safe executeTasksOnWakeup() is a concern</technical_language>

Target:
private void onExit() { int s = exitTasks.size(); for (int i = 0; i < s; i++) { if (terminateAllExitTasks) { break; } exitTasks.get(i).run(); } terminateAllExitTasks = false; }
Source:
<code>public void throwsExceptionIfUnknownAliasKicked() throws Exception { <START> final User user = this.rule.get(); <END> final Alias alias = user.aliases().iterate().iterator().next(); final Inbox inbox = alias.inbox(); final Bout bout = inbox.bout(inbox.start()); final String friend = "jim"; bout.friends().kick(friend); }</code><technical_language>@dmzaytsev able inline user, alias, inbox, one-use variables</technical_language>

Target:
public void throwsExceptionIfUnknownAliasKicked() throws Exception { final Inbox inbox = this.rule.get().aliases() .iterate().iterator().next().inbox(); inbox.bout(inbox.start()).friends().kick("jim"); }
Source:
<code>public void throwsIfConfiguredToBeExistingServiceWithoutDirectory() { File mockFile = getMockFileWith(false, true); assertThatThrownBy(ImmutablePaxosInstallConfiguration.builder() .dataDirectory(mockFile) .isNewService(false) <START> ::build).isInstanceOf(IllegalArgumentException.class); <END> }</code><technical_language>nit: extract a method for assertion</technical_language>

Target:
public void throwsIfConfiguredToBeExistingServiceWithoutDirectory() { File mockFile = getMockFileWith(false, true); assertFailsToBuildConfiguration(ImmutablePaxosInstallConfiguration.builder() .dataDirectory(mockFile) .isNewService(false)); }
Source:
<code>private boolean isNoDictionaryColumn(Set<String> noDictionaryColumns, Set<String> invertedIndexColumns, FieldSpec fieldSpec, String column) { FieldSpec.DataType dataType = fieldSpec.getDataType(); if (noDictionaryColumns.contains(column)) { if (fieldSpec instanceof DimensionFieldSpec && _aggregateMetrics && (dataType == FieldSpec.DataType.STRING || dataType == FieldSpec.DataType.BYTES)) { <START> _logger.info("Will create dictionary in consuming segment for column of type {}", column, dataType.toString()); <END> return false; } return fieldSpec.isSingleValueField() && !invertedIndexColumns.contains(column); } return false; }</code><technical_language>more explicit, clarify noDictionary is overwritten aggregateMetrics for column</technical_language>

Target:
private boolean isNoDictionaryColumn(Set<String> noDictionaryColumns, Set<String> invertedIndexColumns, FieldSpec fieldSpec, String column) { FieldSpec.DataType dataType = fieldSpec.getDataType(); if (noDictionaryColumns.contains(column)) { if (fieldSpec instanceof DimensionFieldSpec && _aggregateMetrics && (dataType == FieldSpec.DataType.STRING || dataType == FieldSpec.DataType.BYTES)) { _logger.info("Aggregate metrics is enabled. Will create dictionary in consuming segment for column of type {}", column, dataType.toString()); return false; } return fieldSpec.isSingleValueField() && !invertedIndexColumns.contains(column); } return false; }
Source:
<code><START> public List<VirtualEdgeIteratorState> getUnfavoredVirtualEdges() { <END> return unfavoredEdges; }</code><technical_language>reduce this List<EdgeIteratorState> is implementation necessary</technical_language>

Target:
public Set<EdgeIteratorState> getUnfavoredVirtualEdges() { return new LinkedHashSet<EdgeIteratorState>(unfavoredEdges); }
Source:
<code>public List<Command> transmit(final List<Command> commands) throws DolphinRemotingException { Assert.requireNonNull(commands, "commands"); if (disconnecting.get()) { LOG.warn("Canceled communication based on disconnect"); return Collections.emptyList(); } for (Command command : commands) { if (command instanceof DestroyContextCommand) { disconnecting.set(true); } } try { <START> String data = codec.encode(commands); <END> String receivedContent = client.request(servletUrl, RequestMethod.POST).withContent(data, HttpHeaderConstants.JSON_MIME_TYPE).readString().execute().get().getContent(); return codec.decode(receivedContent); } catch (Exception e) { throw new DolphinRemotingException("Error in remoting layer", e); } }</code><technical_language>Add final keyword</technical_language>

Target:
public List<Command> transmit(final List<Command> commands) throws DolphinRemotingException { Assert.requireNonNull(commands, "commands"); if (disconnecting.get()) { LOG.warn("Canceled communication based on disconnect"); return Collections.emptyList(); } for (Command command : commands) { if (command instanceof DestroyContextCommand) { disconnecting.set(true); } } try { final String data = codec.encode(commands); final String receivedContent = client.request(servletUrl, RequestMethod.POST).withContent(data, HttpHeaderConstants.JSON_MIME_TYPE).readString().execute().get().getContent(); return codec.decode(receivedContent); } catch (final Exception e) { throw new DolphinRemotingException("Error in remoting layer", e); } }
Source:
<code><START> public synchronized Marshaller<Key> getKeyMarshaller() { <END> return keyMarshaller; }</code><technical_language>Instead remove synchronized setter, variable volatile</technical_language>

Target:
public Marshaller<Key> getKeyMarshaller() { return keyMarshaller; }
Source:
<code><START> public com.google.cloud.dataflow.sdk.io.BoundedSource.BoundedReader<Result> createReader( <END> PipelineOptions options) throws IOException { return new Source.Reader(this, configuration, null, null); }</code><technical_language>This BoundedSource.BoundedReader<Result></technical_language>

Target:
public BoundedSource.BoundedReader<Result> createReader(PipelineOptions options) throws IOException { return new Source.Reader(this, configuration, configuration.getScan()); }
Source:
<code>public Map<String, Object> getSpecificEventStyle(ITimeEvent event) { <START> boolean currentThread = isType(event.getEntry(), Type.CURRENT_THREAD); <END> if (currentThread && event instanceof TimeEvent) { int threadEventValue = ((TimeEvent) event).getValue(); if (threadEventValue == IDLE_THREAD) { return ImmutableMap.of(ITimeEventStyleStrings.fillColor(), 0); } int nbColors = getNbColors(); RGB color = fColors.get((((threadEventValue + COLOR_DIFFERENCIATION_FACTOR) % nbColors) + nbColors) % nbColors); return ImmutableMap.of(ITimeEventStyleStrings.fillColor(), color.red << 24 | color.green << 16 | color.blue << 8 | 0xff, ITimeEventStyleStrings.label(), String.valueOf(threadEventValue)); } return super.getSpecificEventStyle(event); }</code><technical_language>inline in 'if'</technical_language>

Target:
public Map<String, Object> getSpecificEventStyle(ITimeEvent event) { if (isType(event.getEntry(), Type.CURRENT_THREAD) && event instanceof TimeEvent) { int threadEventValue = ((TimeEvent) event).getValue(); if (threadEventValue == IDLE_THREAD) { return ImmutableMap.of(ITimeEventStyleStrings.fillColor(), 0); } RGB color = fColors.get((((threadEventValue + COLOR_DIFFERENCIATION_FACTOR) % NUM_COLORS) + NUM_COLORS) % NUM_COLORS); return ImmutableMap.of(ITimeEventStyleStrings.fillColor(), color.red << 24 | color.green << 16 | color.blue << 8 | 0xff, ITimeEventStyleStrings.label(), String.valueOf(threadEventValue)); } return super.getSpecificEventStyle(event); }
Source:
<code>private void onSendMessage(JsonNode jsonNode) { final RequestDTO requestDTO = MessageConverter.jsonNodeToRequest(jsonNode); <START> final String message = requestDTO.getMessage().toLowerCase(); <END> if("stop".equals(message)) { MessageDTO messageDTO = createMessageDTO("1", "1", "Stop", "Stopping actor"); out.tell(MessageConverter.messageToJsonNode(messageDTO), getSelf()); self().tell(PoisonPill.getInstance(), getSelf()); } else { log.info("Actor received. {}", requestDTO); processMessage(requestDTO); } }</code><technical_language>remove finals. adding anything</technical_language>

Target:
private void onSendMessage(JsonNode jsonNode) { RequestDTO requestDTO = MessageConverter.jsonNodeToRequest(jsonNode); String message = requestDTO.getMessage().toLowerCase(); if("stop".equals(message)) { MessageDTO messageDTO = createMessageDTO("1", "1", "Stop", "Stopping actor"); out.tell(MessageConverter.messageToJsonNode(messageDTO), getSelf()); self().tell(PoisonPill.getInstance(), getSelf()); } else { log.info("Actor received. {}", requestDTO); processMessage(requestDTO); } }