auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public LogUnitServerCache(LogUnitServerConfig config, StreamLog streamLog) { <START> this.streamLog = streamLog; <END> this.dataCache = Caffeine.newBuilder() .<Long, ILogData>weigher((addr, logData) -> getLogDataTotalSize(logData)) .maximumWeight(config.getMaxCacheSize()) .recordStats() .removalListener(this::handleEviction) .build(this::handleRetrieval); MeterRegistryProvider.getInstance().ifPresent(registry -> CaffeineCacheMetrics.monitor(registry, dataCache, "logunit.read_cache")); readTimer = MeterRegistryProvider.getInstance().map(registry -> Timer.builder("logunit.read.timer").register(registry)); }</code><technical_language>capture stats hit ratio, load time total weight</technical_language>

Target:
public LogUnitServerCache(LogUnitServerConfig config, StreamLog streamLog) { this.streamLog = streamLog; this.dataCache = Caffeine.newBuilder() .<Long, ILogData>weigher((addr, logData) -> getLogDataTotalSize(logData)) .maximumWeight(config.getMaxCacheSize()) .recordStats() .removalListener(this::handleEviction) .build(this::handleRetrieval); MeterRegistryProvider.getInstance().ifPresent(registry -> CaffeineCacheMetrics.monitor(registry, dataCache, "logunit.read_cache")); hitRatio = MeterRegistryProvider.getInstance().map(registry -> Gauge.builder(hitRatioName, dataCache, cache -> cache.stats().hitRate()).register(registry)); loadTime = MeterRegistryProvider.getInstance().map(registry -> Gauge.builder(loadTimeName, dataCache, cache -> cache.stats().totalLoadTime()) .register(registry)); weight = MeterRegistryProvider.getInstance().map(registry -> Gauge.builder(weightName, dataCache, cache -> cache.stats().evictionWeight()) .register(registry)); readTimer = MeterRegistryProvider.getInstance().map(registry -> Timer.builder("logunit.read.timer").register(registry)); }
Source:
<code>public static Strand decode(final char ch) { switch (ch) { <START> case '+': return POSITIVE; <END> case '-': return NEGATIVE; case '!': return NONE; default: throw new IllegalArgumentException( "Unable to match encoding to Strand enum for encoding char: " + ch); } }</code><technical_language>This duplicates relationship established in enum definition. Instead write for (Strand strand : values()) { if (strand.charEncoding == ch) { return strand; } } throw new ..</technical_language>

Target:
public static Strand decode(final char ch) { for(final Strand value : VALUES) { if (value.charEncoding == ch) { return value; } } return NONE; }
Source:
<code>private void suspendPublisher(long timeout, TimeUnit timeUnit) throws InterruptedException { try { lock.lock(); if (!publisherEnabled) { throw new InterruptedException(); } if (!notifyPending) { <START> if (timeout == -1) { <END> logger.debug("Suspending publishing thread indefinitely"); lockCondition.await(); } else { logger.debug("Suspending publishing thread for milliseconds", timeout); lockCondition.await(timeout, timeUnit); } } notifyPending = false; } finally { lock.unlock(); } }</code><technical_language>publisherEnabled checked in a lock? need throw Exception, return</technical_language>

Target:
private void suspendPublisher(long timeout, TimeUnit timeUnit) { if (!publisherEnabled.get()) { return; } try { lock.lock(); if (!notifyPending) { if (timeout == -1) { logger.debug("Suspending publishing thread indefinitely"); lockCondition.await(); } else { logger.debug("Suspending publishing thread for milliseconds", timeout); lockCondition.await(timeout, timeUnit); } } notifyPending = false; } catch (InterruptedException e) { } finally { lock.unlock(); } }
Source:
<code>private static void initializeRealm(Realm realm) { boolean commitChanges = false; try { realm.beginTransaction(); long currentVersion = realm.getVersion(); boolean unversioned = currentVersion == UNVERSIONED; commitChanges = unversioned; if (unversioned) { realm.setVersion(realm.configuration.getSchemaVersion()); } final RealmProxyMediator mediator = realm.configuration.getSchemaMediator(); final Set<Class<? extends RealmModel>> modelClasses = mediator.getModelClasses(); final Map<Class<? extends RealmModel>, ColumnInfo> columnInfoMap = new HashMap<>(modelClasses.size()); for (Class<? extends RealmModel> modelClass : modelClasses) { if (unversioned) { mediator.createTable(modelClass, realm.sharedRealm); } columnInfoMap.put(modelClass, mediator.validateTable(modelClass, realm.sharedRealm, false)); } realm.schema.columnIndices = new ColumnIndices( (unversioned) ? realm.configuration.getSchemaVersion() : currentVersion, columnInfoMap); if (unversioned) { final Transaction transaction = realm.configuration.getInitialDataTransaction(); if (transaction != null) { <START> transaction.execute(realm); <END> } } } finally { if (commitChanges) { realm.commitTransaction(false); } else { realm.cancelTransaction(); } } }</code><technical_language>This is called in a try catch block in initializeSyncedRealm this one. I suggest a catch line 360 prevent unexpected exception thrown eg.: mediator.createTable</technical_language>

Target:
private static void initializeRealm(Realm realm) { boolean commitChanges = false; try { realm.beginTransaction(); long currentVersion = realm.getVersion(); boolean unversioned = currentVersion == UNVERSIONED; commitChanges = unversioned; if (unversioned) { realm.setVersion(realm.configuration.getSchemaVersion()); } final RealmProxyMediator mediator = realm.configuration.getSchemaMediator(); final Set<Class<? extends RealmModel>> modelClasses = mediator.getModelClasses(); final Map<Class<? extends RealmModel>, ColumnInfo> columnInfoMap = new HashMap<>(modelClasses.size()); for (Class<? extends RealmModel> modelClass : modelClasses) { if (unversioned) { mediator.createTable(modelClass, realm.sharedRealm); } columnInfoMap.put(modelClass, mediator.validateTable(modelClass, realm.sharedRealm, false)); } realm.schema.columnIndices = new ColumnIndices( (unversioned) ? realm.configuration.getSchemaVersion() : currentVersion, columnInfoMap); if (unversioned) { final Transaction transaction = realm.configuration.getInitialDataTransaction(); if (transaction != null) { transaction.execute(realm); } } } catch (Exception e) { commitChanges = false; throw e; } finally { if (commitChanges) { realm.commitTransaction(false); } else { realm.cancelTransaction(); } } }
Source:
<code>private boolean exec(List<String> cmd) throws Exception { Reader reader = null; InputStream in = null; BufferedReader buf = null; StringBuffer log = null; Process proc = null; try { log = new StringBuffer(); ProcessBuilder pb = new ProcessBuilder(cmd); pb.redirectErrorStream(true); proc = pb.start(); in = proc.getInputStream(); reader = new InputStreamReader(in); buf = new BufferedReader(reader); for ( String line = null; (line=buf.readLine()) != null; ){ log.append( line + "\n" ); <START> System.out.println(" Zoomify tiles creation: " + line + "\n"); <END> } DAMSClient.close(in); DAMSClient.close(reader); DAMSClient.close(buf); int status = proc.waitFor(); if ( status == 0 ) return true; else { in = proc.getErrorStream(); reader = new InputStreamReader(in); buf = new BufferedReader(reader); for ( String line = null; (line=buf.readLine()) != null; ) log.append( line + "\n" ); throw new Exception( log.toString() ); } } catch ( Exception ex ) { throw new Exception( log.toString(), ex ); } finally { DAMSClient.close(in); DAMSClient.close(reader); DAMSClient.close(buf); if(proc != null){ proc.destroy(); proc = null; } } }</code><technical_language>this System.out removed, merged log.append call above</technical_language>

Target:
private boolean exec(List<String> cmd) throws Exception { Reader reader = null; InputStream in = null; BufferedReader buf = null; StringBuffer log = null; Process proc = null; try { log = new StringBuffer(); ProcessBuilder pb = new ProcessBuilder(cmd); pb.redirectErrorStream(true); proc = pb.start(); in = proc.getInputStream(); reader = new InputStreamReader(in); buf = new BufferedReader(reader); for ( String line = null; (line=buf.readLine()) != null; ){ log.append( line + "\n" ); } DAMSClient.close(in); DAMSClient.close(reader); DAMSClient.close(buf); int status = proc.waitFor(); if ( status == 0 ) return true; else { in = proc.getErrorStream(); reader = new InputStreamReader(in); buf = new BufferedReader(reader); for ( String line = null; (line=buf.readLine()) != null; ) log.append( line + "\n" ); throw new Exception( log.toString() ); } } catch ( Exception ex ) { throw new Exception( log.toString(), ex ); } finally { DAMSClient.close(in); DAMSClient.close(reader); DAMSClient.close(buf); if(proc != null){ proc.destroy(); proc = null; } } }
Source:
<code>public void create_default_instance_according_to_place() { <START> final int currentOffset = TimeZone.getDefault().getRawOffset()/1000; <END> assertEquals(currentOffset, ZoneOffsets.getDefault().getAmountSeconds()); }</code><technical_language>constant mean</technical_language>

Target:
public void create_default_instance_according_to_place() { final int currentOffset = TimeZone.getDefault().getRawOffset()/(int)MILLIS_PER_SECOND; assertEquals(currentOffset, ZoneOffsets.getDefault().getAmountSeconds()); }
Source:
<code>boolean isEqualMutation(Mutation expectedMutation, Mutation actualMutation){ List<Cell> expectedCells = new ArrayList<>(); for (List<Cell> cells : expectedMutation.getFamilyCellMap().values()) { expectedCells.addAll(cells); } List<Cell> actualCells = new ArrayList<>(); for (List<Cell> cells : actualMutation.getFamilyCellMap().values()) { actualCells.addAll(cells); } <START> assertEquals(expectedCells.size(), actualCells.size()); <END> for(Cell expected : expectedCells){ boolean found = false; for(Cell actual: actualCells){ if (isEqualCell(expected, actual)){ actualCells.remove(actual); found = true; break; } } if (!found) return false; } return true; }</code><technical_language>return false instead of assert</technical_language>

Target:
boolean isEqualMutation(Mutation expectedMutation, Mutation actualMutation){ List<Cell> expectedCells = new ArrayList<>(); for (List<Cell> cells : expectedMutation.getFamilyCellMap().values()) { expectedCells.addAll(cells); } List<Cell> actualCells = new ArrayList<>(); for (List<Cell> cells : actualMutation.getFamilyCellMap().values()) { actualCells.addAll(cells); } if (expectedCells.size() != actualCells.size()) return false; for(Cell expected : expectedCells) { boolean found = false; for(Cell actual: actualCells){ if (isEqualCell(expected, actual)) { actualCells.remove(actual); found = true; break; } } if (!found) return false; } return true; }
Source:
<code>public Sequence<T> run(final Query<T> query, Map<String, Object> responseContext) { <START> if (QueryContexts.isBySegment(query, false)) { <END> final Sequence<T> baseSequence = base.run(query, responseContext); final List<T> results = Sequences.toList(baseSequence, Lists.<T>newArrayList()); return Sequences.simple( Arrays.asList( (T) new Result<BySegmentResultValueClass<T>>( timestamp, new BySegmentResultValueClass<T>( results, segmentIdentifier, query.getIntervals().get(0) ) ) ) ); } return base.run(query, responseContext); }</code><technical_language>isBySegment is called false default argument, remove parameter</technical_language>

Target:
public Sequence<T> run(final Query<T> query, Map<String, Object> responseContext) { if (QueryContexts.isBySegment(query)) { final Sequence<T> baseSequence = base.run(query, responseContext); final List<T> results = Sequences.toList(baseSequence, Lists.<T>newArrayList()); return Sequences.simple( Arrays.asList( (T) new Result<BySegmentResultValueClass<T>>( timestamp, new BySegmentResultValueClass<T>( results, segmentIdentifier, query.getIntervals().get(0) ) ) ) ); } return base.run(query, responseContext); }
Source:
<code>public Set<String> getAll() throws SshKeyStoreException { Map<String, String> keys; try { keys = getSshKeys(); } catch (ApiException | IOException | JsonParseException e) { throw new SshKeyStoreException("Failed to get keys", e); } if (keys == null) { throw new SshKeyStoreException("Impossible get keys"); } final Set<String> privateKeys = new HashSet<>(); privateKeys.addAll(keys.keySet() .stream() .filter(str -> str.startsWith(PRIVATE_KEY_ATTRIBUTE_PREFIX)) .map(str -> str.substring(PRIVATE_KEY_ATTRIBUTE_PREFIX.length())) <START> .collect(Collectors.toList())); <END> return privateKeys; }</code><technical_language>collect(Collectors.toSet())</technical_language>

Target:
public Set<String> getAll() throws SshKeyStoreException { try { Map<String, String> keys = getSshKeys(); return keys.keySet() .stream() .filter(str -> str.startsWith(PRIVATE_KEY_ATTRIBUTE_PREFIX)) .map(str -> str.substring(PRIVATE_KEY_ATTRIBUTE_PREFIX.length())) .collect(Collectors.toSet()); } catch (ApiException | IOException | JsonParseException e) { throw new SshKeyStoreException("Failed to get keys ", e); } }
Source:
<code>public String toString() { <START> return "Configurator observer method [Bean class = " + getBeanClass().toString() <END> + ", type = " + getObservedType() + ", qualifiers =" + Formats.formatAnnotations(getObservedQualifiers()) + ", priority =" + getPriority() + ", async =" + isAsync() + ", reception =" + getReception() + ", transaction phase =" + getTransactionPhase() + "]"; }</code><technical_language>allow set null bean class. If remove toString() here, this method throw NPE resulting string same</technical_language>

Target:
public String toString() { return "Configurator observer method [Bean class = " + getBeanClass() + ", type = " + getObservedType() + ", qualifiers =" + Formats.formatAnnotations(getObservedQualifiers()) + ", priority =" + getPriority() + ", async =" + isAsync() + ", reception =" + getReception() + ", transaction phase =" + getTransactionPhase() + "]"; }
Source:
<code>public void setLatitude(double latitude) { <START> this.mLatitude = <END> latitude; }</code><technical_language>avoid this</technical_language>

Target:
public void setLatitude(double latitude) { mLatitude = latitude; }
Source:
<code>public double approximate(int currentNode) { Dijkstra dijkstra = new Dijkstra(graph, weighting, traversalMode); Path path = reverse ? dijkstra.calcPath(to, currentNode) : dijkstra.calcPath(currentNode, to); <START> if (path.isFound()) return path.getWeight(); else return Double.POSITIVE_INFINITY; <END> }</code><technical_language>btw :) .... return path.isFound() ? path.getWeight() : Double.POSITIVE_INFINITY; slightly ternary op in line above</technical_language>

Target:
public double approximate(int currentNode) { Dijkstra dijkstra = new Dijkstra(graph, weighting, traversalMode); Path path = reverse ? dijkstra.calcPath(to, currentNode) : dijkstra.calcPath(currentNode, to); return path.isFound() ? path.getWeight() : Double.POSITIVE_INFINITY; }
Source:
<code>public OnmsMonitoredServiceDetail(OnmsMonitoredService service) { m_nodeLabel = service.getIpInterface().getNode().getLabel(); m_ipAddress = service.getIpAddress(); m_serviceName = service.getServiceName(); m_isMonitored = "A".equals(service.getStatus()); m_isDown = service.isDown(); m_statusCode = service.getStatus(); m_status = service.getStatusLong(); m_id = service.getXmlId(); <START> m_ipInterfaceId = service.getIpInterface().getId(); <END> }</code><technical_language>Do need store this a field, return in getIpinterfaceId() method</technical_language>

Target:
public OnmsMonitoredServiceDetail(OnmsMonitoredService service) { m_nodeLabel = service.getIpInterface().getNode().getLabel(); m_ipAddress = service.getIpAddress(); m_serviceName = service.getServiceName(); m_isMonitored = "A".equals(service.getStatus()); m_isDown = service.isDown(); m_statusCode = service.getStatus(); m_status = service.getStatusLong(); m_id = service.getXmlId(); m_ipInterfaceId = service.getIpInterfaceId(); }
Source:
<code>public void theoryLeavesHaveIstream(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(resource())); InputStream result = res.in(); try { assertThat(result, notNullValue()); } finally { <START> result.close(); <END> } }</code><technical_language>try-with-resources</technical_language>

Target:
public void theoryLeavesHaveIstream(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(resource())); try (InputStream result = res.in()) { assertThat(result, notNullValue()); } }
Source:
<code>public void testSingleDynamicFormCheckboxForm() throws Exception { if (!endToEndTestEnabled()) { return; } try { createNewNote(); setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + "(\"luke\",\"Luke\")); println(\"Greetings \"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))"); runParagraph(1); waitForParagraph(1, "FINISHED"); collector.checkThat("Output text should display all of the options included in check boxes", driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings han and leia and luke")); WebElement firstCheckbox = driver.findElement(By.xpath(getParagraphXPath(1) + " firstCheckbox.click(); <START> collector.checkThat("After unchecking one of the boxes, output should not display any change", <END> driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings han and leia and luke")); runParagraph(1); waitForParagraph(1, "FINISHED"); collector.checkThat("Only after paragraph run we should see the new output without the box we unchecked", driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings leia and luke")); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testSingleDynamicFormTextInput ", e); } }</code><technical_language>A extra space is display :D</technical_language>

Target:
public void testSingleDynamicFormCheckboxForm() throws Exception { if (!endToEndTestEnabled()) { return; } try { createNewNote(); setTextOfParagraph(1, "%spark val options = Seq((\"han\",\"Han\"), (\"leia\",\"Leia\"), " + "(\"luke\",\"Luke\")); println(\"Greetings \"+z.checkbox(\"skywalkers\",options).mkString(\" and \"))"); runParagraph(1); waitForParagraph(1, "FINISHED"); collector.checkThat("Output text should display all of the options included in check boxes", driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings han and leia and luke")); WebElement firstCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + " firstCheckbox.click(); collector.checkThat("After unchecking one of the boxes, we can see the newly updated output without the option we unchecked", driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings leia and luke")); driver.findElement(By.xpath(getParagraphXPath(1) + " clickAndWait(By.xpath(getParagraphXPath(1) + " WebElement secondCheckbox = driver.findElement(By.xpath("(" + getParagraphXPath(1) + " secondCheckbox.click(); collector.checkThat("After 'Run on selection change' checkbox is unchecked, the paragraph should not run if check box state is modified", driver.findElement(By.xpath(getParagraphXPath(1) + " CoreMatchers.containsString("Greetings leia and luke")); runParagraph(1); waitForParagraph(1, "FINISHED"); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testSingleDynamicFormCheckboxForm ", e); } }
Source:
<code>private boolean suspendNoteAvailable() { <START> if (mCurrentCard == null || getControlBlocked() != ControlBlock.NONE) { <END> return false; } return getCol().getDb().queryScalar("select 1 from cards where nid = ? and id != ? and queue != " + Consts.QUEUE_TYPE_SUSPENDED + " limit 1", new Object[] {mCurrentCard.getNid(), mCurrentCard.getId()}) == 1; }</code><technical_language>getControlBlocked() != ControlBlock.NONE is duplicated, extracted a method</technical_language>

Target:
private boolean suspendNoteAvailable() { if (mCurrentCard == null || isControlBlocked()) { return false; } return getCol().getDb().queryScalar("select 1 from cards where nid = ? and id != ? and queue != " + Consts.QUEUE_TYPE_SUSPENDED + " limit 1", new Object[] {mCurrentCard.getNid(), mCurrentCard.getId()}) == 1; }
Source:
<code>public Set<AgentIdentity> filterApprovedAgents(Set<AgentIdentity> agents) { if (agents.size() == 0) { return agents; } Set<String> ips = new HashSet<>(); for (AgentInfo each : cachedLocalAgentService.getLocalAgents()) { if (each.isApproved()) { ips.add(each.getIp() + each.getName()); } } Set<AgentIdentity> approvedAgent = new HashSet<>(); for (AgentIdentity each : agents) { if (ips.contains(((AgentControllerIdentityImplementation) each).getIp() + each.getName())) { <START> approvedAgent.add(each); <END> } } return approvedAgent; }</code><technical_language>stream here</technical_language>

Target:
public Set<AgentIdentity> filterApprovedAgents(Set<AgentIdentity> agents) { if (agents.size() == 0) { return agents; } Set<String> ips = cachedLocalAgentService.getLocalAgents() .stream() .filter(AgentInfo::isApproved) .map(agentInfo -> agentInfo.getIp() + agentInfo.getName()) .collect(toSet()); return agents.stream() .map(AgentManager::convert) .filter(identity -> ips.contains(identity.getIp() + identity.getName())) .collect(toSet()); }
Source:
<code>private CommandEntity getParentCommandEntity(Guid cmdId, VdcActionType actionType, VdcActionParametersBase parameters) { CommandEntity cmdEntity = Guid.isNullOrEmpty(cmdId) ? null : coco.getCommandEntity(cmdId); if (cmdEntity == null) { cmdEntity = new CommandEntity(); <START> cmdEntity.setId(cmdId); <END> cmdEntity.setCommandType(actionType); cmdEntity.setCommandParameters(parameters); if (!Guid.isNullOrEmpty(cmdId)) { cmdEntity.setCommandStatus(CommandStatus.ACTIVE); coco.persistCommand(cmdEntity); } } return cmdEntity; }</code><technical_language>place created command entity in coco</technical_language>

Target:
private CommandEntity getParentCommandEntity(Guid cmdId, VdcActionType actionType, VdcActionParametersBase parameters) { CommandEntity cmdEntity = Guid.isNullOrEmpty(cmdId) ? null : coco.getCommandEntity(cmdId); if (cmdEntity == null) { cmdEntity = coco.createCommandEntity(cmdId, actionType, parameters); if (!Guid.isNullOrEmpty(cmdId)) { cmdEntity.setCommandStatus(CommandStatus.ACTIVE); coco.persistCommand(cmdEntity); } } return cmdEntity; }
Source:
<code>public void onServiceConnected(ComponentName name, IBinder service) { if (DEBUG) { Log.d(TAG, "onServiceConnected " + name + " " + this); } if (!mToken.getPackageName().equals(name.getPackageName())) { Log.wtf(TAG, "Expected connection to " + mToken.getPackageName() + <START> " but " + name + " was connected"); <END> return; } connectToSession(IMediaSession2.Stub.asInterface(service)); }</code><technical_language>minor) is connected 'name'</technical_language>

Target:
public void onServiceConnected(ComponentName name, IBinder service) { if (DEBUG) { Log.d(TAG, "onServiceConnected " + name + " " + this); } if (!mToken.getPackageName().equals(name.getPackageName())) { Log.wtf(TAG, "Expected connection to " + mToken.getPackageName() + " but is" + " connected to " + name); return; } connectToSession(IMediaSession2.Stub.asInterface(service)); }
Source:
<code>private void visitNonLeafNode(Context context, ExecutionBlock current) { if (!plan.isTerminal(current)) { if (current.hasJoin()) { List<ExecutionBlock> childs = plan.getChilds(current); Map<ExecutionBlockId, ExecutionBlockId> unionScanMap = current.getUnionScanMap(); LogicalNode found = PlannerUtil.findTopNode(current.getPlan(), NodeType.JOIN); if (found == null) { throw new TajoInternalError("ExecutionBlock " + current.getId() + " doesn't have any join operator, " + "but the master plan indicates that it has."); } JoinType joinType = ((JoinNode)found).getJoinType(); for (ExecutionBlock child : childs) { if (!child.isPreservedRow()) { updateBroadcastableRelForChildEb(context, child, joinType); updateInputBasedOnChildEb(child, current); } } if (current.hasBroadcastRelation()) { for (ExecutionBlock child : childs) { addUnionNodeIfNecessary(unionScanMap, plan, child, current); mergeTwoPhaseJoinIfPossible(plan, child, current); } checkTotalSizeOfBroadcastableRelations(context, current); long outputVolume = estimateOutputVolume(current); context.estimatedEbOutputSize.put(current.getId(), outputVolume); } } else { List<ScanNode> relations = new ArrayList<>(); <START> relations.addAll(current.getBroadcastRelations()); <END> for (ScanNode eachRelation : relations) { current.removeBroadcastRelation(eachRelation); } } } }</code><technical_language>rewritten a single constructor call</technical_language>

Target:
private void visitNonLeafNode(Context context, ExecutionBlock current) { if (!plan.isTerminal(current)) { if (current.hasJoin()) { List<ExecutionBlock> childs = plan.getChilds(current); Map<ExecutionBlockId, ExecutionBlockId> unionScanMap = current.getUnionScanMap(); LogicalNode found = PlannerUtil.findTopNode(current.getPlan(), NodeType.JOIN); if (found == null) { throw new TajoInternalError("ExecutionBlock " + current.getId() + " doesn't have any join operator, " + "but the master plan indicates that it has."); } JoinType joinType = ((JoinNode)found).getJoinType(); for (ExecutionBlock child : childs) { if (!child.isPreservedRow()) { updateBroadcastableRelForChildEb(context, child, joinType); updateInputBasedOnChildEb(child, current); } } if (current.hasBroadcastRelation()) { for (ExecutionBlock child : childs) { addUnionNodeIfNecessary(unionScanMap, plan, child, current); mergeTwoPhaseJoinIfPossible(plan, child, current); } checkTotalSizeOfBroadcastableRelations(context, current); long outputVolume = estimateOutputVolume(current); context.estimatedEbOutputSize.put(current.getId(), outputVolume); } } else { List<ScanNode> relations = new ArrayList<>(current.getBroadcastRelations()); for (ScanNode eachRelation : relations) { current.removeBroadcastRelation(eachRelation); } } } }
Source:
<code><START> public CityInformation(City city, String state, Set<Restaurant> restaurants, Set<Attraction> attractions) { <END> this.city = city; this.state = state; this.restaurants = restaurants; this.attractions = attractions; }</code><technical_language>a public constructor if a builder</technical_language>

Target:
private CityInformation(City city, String state, Set<Restaurant> restaurants, Set<Attraction> attractions) { this.city = city; this.state = state; this.restaurants = restaurants; this.attractions = attractions; }
Source:
<code>public void canAccessCurrencyCustomAttributes() throws Exception { final CurrencySearchModel<ProductProjection, DirectionlessMultiValueSearchSortModel<ProductProjection>> path = attributeModel().ofMoney("originalPrice").currency(); assertThat(path.faceted().byAllTerms().expression()).isEqualTo("variants.attributes.originalPrice.currencyCode"); <START> assertThat(path.filtered().by(currency("EUR"))).extracting(expr -> expr.expression()).containsExactly("variants.attributes.originalPrice.currencyCode:\"EUR\""); <END> assertThat(path.sorted().byDescWithMin().expression()).isEqualTo("variants.attributes.originalPrice.currencyCode desc.min"); }</code><technical_language>optimize extracting</technical_language>

Target:
public void canAccessCurrencyCustomAttributes() throws Exception { final String attrName = "originalPrice"; assertThat(FACET_ATTR.ofMoney(attrName).currency().allTerms().expression()).isEqualTo("variants.attributes.originalPrice.currencyCode"); assertThat(FILTER_ATTR.ofMoney(attrName).currency().by(currency("EUR"))).extracting(expression()).containsExactly("variants.attributes.originalPrice.currencyCode:\"EUR\""); assertThat(SORT_ATTR.ofMoney(attrName).currency().byDescWithMin().expression()).isEqualTo("variants.attributes.originalPrice.currencyCode desc.min"); }
Source:
<code>public ConnectionHandler(Socket s, ConnectionHandlerFailureCallback parentTerminator) { this.s = s; synchronized(getClass()) { id = iotaGen++; } setName("TCP agent connection handler #"+id+" with "+s.getRemoteSocketAddress()); setUncaughtExceptionHandler((t, e) -> { LOGGER.log(Level.SEVERE, "Uncaught exception in TcpSlaveAgentListener ConnectionHandler " + t, e); try { <START> parentTerminator.run(e); <END> s.close(); } catch (IOException e1) { LOGGER.log(Level.WARNING, "Could not close socket after unexpected thread death", e1); } }); }</code><technical_language>cay a race condition, current socket handling Socket parent thread restarts. happen if Thread is delayed for 5 seconds, is non-realistic</technical_language>

Target:
public ConnectionHandler(Socket s, ConnectionHandlerFailureCallback parentTerminator) { this.s = s; synchronized(getClass()) { id = iotaGen++; } setName("TCP agent connection handler #"+id+" with "+s.getRemoteSocketAddress()); setUncaughtExceptionHandler((t, e) -> { LOGGER.log(Level.SEVERE, "Uncaught exception in TcpSlaveAgentListener ConnectionHandler " + t, e); try { s.close(); parentTerminator.run(e); } catch (IOException e1) { LOGGER.log(Level.WARNING, "Could not close socket after unexpected thread death", e1); } }); }
Source:
<code>public void checkCommandMetadata() throws Exception { try (CommandController controller = uiTestHarness.createCommandController(CDINewInterceptorCommand.class, project.getRoot())) { controller.initialize(); assertTrue(controller.getCommand() instanceof CDINewInterceptorCommand); UICommandMetadata metadata = controller.getMetadata(); assertEquals("CDI: New Interceptor", metadata.getName()); assertEquals("Java EE", metadata.getCategory().getName()); assertEquals("CDI", metadata.getCategory().getSubCategory().getName()); assertEquals(4, controller.getInputs().size()); assertFalse("Project is created, shouldn't have targetLocation", controller.hasInput("targetLocation")); assertTrue(controller.hasInput("named")); assertTrue(controller.hasInput("targetPackage")); assertTrue(controller.hasInput("overwrite")); assertTrue(controller.hasInput("interceptorBinding")); <START> assertTrue(controller.getValueFor("targetPackage").toString().endsWith("beans")); <END> } }</code><technical_language>created constant instead</technical_language>

Target:
public void checkCommandMetadata() throws Exception { try (CommandController controller = uiTestHarness.createCommandController(CDINewInterceptorCommand.class, project.getRoot())) { controller.initialize(); assertTrue(controller.getCommand() instanceof CDINewInterceptorCommand); UICommandMetadata metadata = controller.getMetadata(); assertEquals("CDI: New Interceptor", metadata.getName()); assertEquals("Java EE", metadata.getCategory().getName()); assertEquals("CDI", metadata.getCategory().getSubCategory().getName()); assertEquals(4, controller.getInputs().size()); assertFalse("Project is created, shouldn't have targetLocation", controller.hasInput("targetLocation")); assertTrue(controller.hasInput("named")); assertTrue(controller.hasInput("targetPackage")); assertTrue(controller.hasInput("overwrite")); assertTrue(controller.hasInput("interceptorBinding")); assertTrue(controller.getValueFor("targetPackage").toString().endsWith(DEFAULT_CDI_PACKAGE)); } }
Source:
<code>public void setUp(){ apduHeader = new byte { (byte) 0x0C, 0x20, (byte) 0x80, 0x00}; <START> commandData = new byte { 0x01, (byte) 0xFF }; <END> }</code><technical_language>this variable name is misleading, contains commandData Ne field (see other ApduTest classes)</technical_language>

Target:
public void setUp(){ apduHeader = new byte { (byte) 0x0C, 0x20, (byte) 0x80, 0x00}; lc = new byte {0x01}; commandData = new byte {(byte) 0xFF}; }
Source:
<code>public void testFullConfig() throws Exception { InputStream stream = TesseractOCRConfigTest.class.getResourceAsStream( "/test-properties/TesseractOCRConfig-full.properties"); TesseractOCRConfig config = new TesseractOCRConfig(stream); assertEquals("Invalid overridden tesseractPath value", "/opt/tesseract" + File.separator, config.getTesseractPath()); assertEquals("Invalid overridden tesseractPath value", "/usr/local/share" + File.separator, config.getTessdataPath()); assertEquals("Invalid overridden language value", "fra+deu", config.getLanguage()); assertEquals("Invalid overridden pageSegMode value", "2", config.getPageSegMode()); assertEquals("Invalid overridden minFileSizeToOcr value", 1, config.getMinFileSizeToOcr()); assertEquals("Invalid overridden maxFileSizeToOcr value", 2000000, config.getMaxFileSizeToOcr()); assertEquals("Invalid overridden timeout value", 240, config.getTimeout()); <START> assertEquals("Invalid overridden ImageMagickPath value", "/usr/local/bin/", config.getImageMagickPath()); <END> assertEquals("Invalid overridden density value", 200 , config.getDensity()); assertEquals("Invalid overridden depth value", 8 , config.getDepth()); assertEquals("Invalid overridden filter value", "box" , config.getFilter()); assertEquals("Invalid overridden resize value", 300 , config.getResize()); }</code><technical_language>This pass a non-unix OS</technical_language>

Target:
public void testFullConfig() throws Exception { InputStream stream = TesseractOCRConfigTest.class.getResourceAsStream( "/test-properties/TesseractOCRConfig-full.properties"); TesseractOCRConfig config = new TesseractOCRConfig(stream); if(SystemUtils.IS_OS_UNIX) { assertEquals("Invalid overridden tesseractPath value", "/opt/tesseract" + File.separator, config.getTesseractPath()); assertEquals("Invalid overridden tesseractPath value", "/usr/local/share" + File.separator, config.getTessdataPath()); assertEquals("Invalid overridden ImageMagickPath value", "/usr/local/bin/", config.getImageMagickPath()); } assertEquals("Invalid overridden language value", "fra+deu", config.getLanguage()); assertEquals("Invalid overridden pageSegMode value", "2", config.getPageSegMode()); assertEquals("Invalid overridden minFileSizeToOcr value", 1, config.getMinFileSizeToOcr()); assertEquals("Invalid overridden maxFileSizeToOcr value", 2000000, config.getMaxFileSizeToOcr()); assertEquals("Invalid overridden timeout value", 240, config.getTimeout()); assertEquals("Invalid overridden density value", 200 , config.getDensity()); assertEquals("Invalid overridden depth value", 8 , config.getDepth()); assertEquals("Invalid overridden filter value", "box" , config.getFilter()); assertEquals("Invalid overridden resize value", 300 , config.getResize()); }
Source:
<code>public int hashCode() { <START> return Objects.hash(this.version, this.globalLsn, this.localLsnByRegion); <END> }</code><technical_language>Is suppress this warning create a work item for this</technical_language>

Target:
public int hashCode() { return super.hashCode(); }
Source:
<code>private void activateContextService() { if (!fActiveContexts.isEmpty()) { deactivateContextService(); <START> } <END> fActiveContexts.add(fContextService.activateContext(CONTEXT)); }</code><technical_language>I good enough do if active</technical_language>

Target:
private void activateContextService() { if (fActiveContexts.isEmpty()) { fActiveContexts.add(fContextService.activateContext(CONTEXT)); } }
Source:
<code>public void bringToFront() { if (PlatformSpecific.isOnMac()) { try { scriptEngine.eval("tell application \"System Events\" to repeat with p in (every application process whose name contains \"Chrome\" and name does not contain \"Helper\")\nif (title of window of p as string) contains \"" + driver.getTitle() + "\" then tell process p to perform action \"AXRaise\" of window 1 of p\nend repeat"); } catch (ScriptException e) { logger.info("Bring browser window to front script exception! " + e.getLocalizedMessage()); } catch (Exception e) { logger.info("Bring browser window to front exception! " + e.getLocalizedMessage()); <START> } <END> } }</code><technical_language>Yes, I safe remove. dealing AppleScript interface provided ScriptEngine, handling ScriptException. Other errors coming code path (or a JDK bug)</technical_language>

Target:
public void bringToFront() { if (PlatformSpecific.isOnMac()) { try { if (scriptEngine == null) { ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); scriptEngine = scriptEngineManager.getEngineByName("AppleScriptEngine"); } scriptEngine.eval("tell application \"System Events\" to repeat with p in (every application process whose name contains \"Chrome\" and name does not contain \"Helper\")\nif (title of window of p as string) contains \"" + driver.getTitle() + "\" then tell process p to perform action \"AXRaise\" of window 1 of p\nend repeat"); } catch (ScriptException e) { logger.info("Bring browser window to front script exception! " + e.getLocalizedMessage()); } catch (Exception e) { logger.info("Bring browser window to front exception! " + e.getLocalizedMessage()); } } }
Source:
<code>public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException { String pbsServer = attribute.valueAsString(); if (pbsServer == null) throw new WrongReferenceAttributeValueException(attribute, "PbsServer cannot be null."); List<Facility> allFacilities = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilities(perunSession); boolean success = false; for(Facility f: allFacilities) { if(f.getName().equals(pbsServer)) { success = true; break; } } <START> if(!success) throw new WrongReferenceAttributeValueException(attribute, null, facility, null, "No core attribute " + pbsServer + " exist for facility object in perun."); <END> }</code><technical_language>This exception is I meant. is facility "urn:..facility:..def:core:name" pbsServer attribute. I meant core attribute</technical_language>

Target:
public void checkAttributeSemantics(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException { String pbsServer = attribute.valueAsString(); if (pbsServer == null) throw new WrongReferenceAttributeValueException(attribute, "PbsServer cannot be null."); List<Facility> allFacilities = perunSession.getPerunBl().getFacilitiesManagerBl().getFacilities(perunSession); boolean success = false; for(Facility f: allFacilities) { if(f.getName().equals(pbsServer)) { success = true; break; } } try { Attribute name = new Attribute(perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, AttributesManager.NS_FACILITY_ATTR_CORE + ":name")); name.setValue(pbsServer); if(!success) throw new WrongReferenceAttributeValueException(attribute, name, facility, null, "There is no facility with attribute name same as the pbsServer attribute."); } catch (AttributeNotExistsException e) { throw new ConsistencyErrorException(e); } }
Source:
<code>private String getClassName() { String className; int resourceId; String carrierConfig; switch (mTransportType) { case AccessNetworkConstants.TRANSPORT_TYPE_WWAN: resourceId = com.android.internal.R.string.config_wwan_network_service_class; carrierConfig = CarrierConfigManager .KEY_CARRIER_NETWORK_SERVICE_WWAN_CLASS_OVERRIDE_STRING; break; case AccessNetworkConstants.TRANSPORT_TYPE_WLAN: resourceId = com.android.internal.R.string.config_wlan_network_service_class; carrierConfig = CarrierConfigManager .KEY_CARRIER_NETWORK_SERVICE_WLAN_CLASS_OVERRIDE_STRING; break; default: throw new IllegalStateException("Transport type not WWAN or WLAN. type=" + mTransportType); } className = mPhone.getContext().getResources().getString(resourceId); PersistableBundle b = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId()); if (b != null && !TextUtils.isEmpty(b.getString(carrierConfig))) { className = b.getString(carrierConfig, className); } <START> if (b != null && !TextUtils.isEmpty(b.getString(carrierConfig))) { className = b.getString(carrierConfig, className); } <END> List<ResolveInfo> resolveInfo = mPhone.getContext().getPackageManager().queryIntentServices( new Intent(NetworkService.SERVICE_INTERFACE), PackageManager.MATCH_SYSTEM_ONLY); if (resolveInfo != null) { for (ResolveInfo info : resolveInfo) { if (info.serviceInfo == null) continue; if ((info.serviceInfo.name).contains(className)) { className = info.serviceInfo.name; break; } } } return className; }</code><technical_language>redundant</technical_language>

Target:
private String getClassName() { String className; int resourceId; String carrierConfig; switch (mTransportType) { case AccessNetworkConstants.TRANSPORT_TYPE_WWAN: resourceId = com.android.internal.R.string.config_wwan_network_service_class; carrierConfig = CarrierConfigManager .KEY_CARRIER_NETWORK_SERVICE_WWAN_CLASS_OVERRIDE_STRING; break; case AccessNetworkConstants.TRANSPORT_TYPE_WLAN: resourceId = com.android.internal.R.string.config_wlan_network_service_class; carrierConfig = CarrierConfigManager .KEY_CARRIER_NETWORK_SERVICE_WLAN_CLASS_OVERRIDE_STRING; break; default: throw new IllegalStateException("Transport type not WWAN or WLAN. type=" + mTransportType); } className = mPhone.getContext().getResources().getString(resourceId); PersistableBundle b = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId()); if (b != null && !TextUtils.isEmpty(b.getString(carrierConfig))) { className = b.getString(carrierConfig, className); } return className; }
Source:
<code>public void start(Stage stage) { try { setUp(stage); try { LibraryLoader libraryLoader = new LibraryLoader("library.xml"); library = libraryLoader.load(); if (library.size() < 1) { empty = true; } } catch (IOException | NullPointerException e) { library = new Library(); empty = true; log.info("No library found"); } scene.getWindow().setOnHidden(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent arg0) { if (library != null) { XmlExport exporter = new XmlExport("library.xml", library); exporter.export(); } System.exit(0); } }); if (empty) { log.trace("opening folderchooser"); String directory = ""; DirectoryChooser directoryChooser = new DirectoryChooser(); File selectedDirectory = directoryChooser.showDialog(null); if (selectedDirectory == null) { log.warn("No directory selected."); System.exit(-1); } else { directory = selectedDirectory.getAbsolutePath(); } FolderLoader folderLoader = new FolderLoader(directory); String playlistname = FileName.getName(directory); Playlist playlist = folderLoader.load(); PlaylistSorter sorter = new MaximumFlowPlaylistSorter(); Playlist mixablePlaylist = sorter.sort(playlist); controller.setEverything(mixablePlaylist, playlistname, scene); } else { controller.setLibrary(library, scene); } } catch (Exception e) { log.fatal(e.getMessage(), e); <START> e.printStackTrace(); <END> System.exit(-1); } }</code><technical_language>deleted</technical_language>

Target:
public void start(Stage stage) { try { setUp(stage); try { LibraryLoader libraryLoader = new LibraryLoader("library.xml"); library = libraryLoader.load(); if (library.size() < 1) { empty = true; } } catch (IOException | NullPointerException e) { library = new Library(); empty = true; log.info("No library found"); } scene.getWindow().setOnHidden(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent arg0) { if (library != null) { XmlExport exporter = new XmlExport("library.xml", library); exporter.export(); } System.exit(0); } }); if (empty) { log.trace("opening folderchooser"); String directory = ""; DirectoryChooser directoryChooser = new DirectoryChooser(); File selectedDirectory = directoryChooser.showDialog(null); if (selectedDirectory == null) { log.warn("No directory selected."); System.exit(-1); } else { directory = selectedDirectory.getAbsolutePath(); } FolderLoader folderLoader = new FolderLoader(directory); String playlistname = FileName.getName(directory); Playlist playlist = folderLoader.load(); PlaylistSorter sorter = new MaximumFlowPlaylistSorter(); Playlist mixablePlaylist = sorter.sort(playlist); controller.setEverything(mixablePlaylist, playlistname, scene); } else { controller.setLibrary(library, scene); } } catch (Exception e) { log.fatal(e.getMessage(), e); System.exit(-1); } }
Source:
<code>@Override public Boolean call() throws RuntimeException { try { ClassLoader loader = getClass().getClassLoader(); Object jnr = PosixAPI.jnr(); Method waitpidMethod = jnr.getClass().getDeclaredMethod("waitpid", int.class, int[].class, int.class); Class WaitFlags = loader.loadClass("jnr.constants.platform.WaitFlags"); Method intValue = WaitFlags.getDeclaredMethod("intValue"); Integer WNOHANG = (Integer) intValue.invoke(Enum.valueOf(WaitFlags, "WNOHANG")); int[] code = new int[1]; waitpidMethod.setAccessible(true); Integer ret = (Integer) waitpidMethod.invoke(jnr, pid, code, WNOHANG); return ret != -1; } catch (InvocationTargetException x) { <START> LOGGER.log(Level.FINE, "jnr doesn't have waitpid support", x); <END> } catch (IllegalAccessException x) { LOGGER.log(Level.FINE, "jnr doesn't have waitpid support", x); } catch (ClassNotFoundException x) { LOGGER.log(Level.FINE, "jnr doesn't have waitpid support", x); } catch (NoSuchMethodException x) { LOGGER.log(Level.FINE, "jnr doesn't have waitpid support", x); } LibC libc = LibC.INSTANCE; if (libc.getpgid(0) == -1) { throw new IllegalStateException("getpgid does not seem to work on this platform"); } return libc.getpgid(pid) != -1; }</code><technical_language>Add "falling JNA LibC implementation" text log entry</technical_language>

Target:
@Override public Boolean call() throws IllegalStateException { final String fallback_msg = "jnr doesn't have waitpid support; "+ "falling back to the JNA LibC implementation"; try { ClassLoader loader = getClass().getClassLoader(); Object jnr = PosixAPI.jnr(); Method waitpidMethod = jnr.getClass().getDeclaredMethod("waitpid", int.class, int[].class, int.class); Class WaitFlags = loader.loadClass("jnr.constants.platform.WaitFlags"); Method intValue = WaitFlags.getDeclaredMethod("intValue"); Integer WNOHANG = (Integer) intValue.invoke(Enum.valueOf(WaitFlags, "WNOHANG")); int[] code = new int[1]; waitpidMethod.setAccessible(true); Integer ret = (Integer) waitpidMethod.invoke(jnr, pid, code, WNOHANG); return ret != -1; } catch (InvocationTargetException x) { LOGGER.log(Level.WARNING, fallback_msg, x); } catch (IllegalAccessException x) { LOGGER.log(Level.WARNING, fallback_msg, x); } catch (ClassNotFoundException x) { LOGGER.log(Level.WARNING, fallback_msg, x); } catch (NoSuchMethodException x) { LOGGER.log(Level.WARNING, fallback_msg, x); } catch (SecurityException x) { LOGGER.log(Level.WARNING, fallback_msg, x); } LibC libc = LibC.INSTANCE; if (libc.getpgid(0) == -1) { throw new IllegalStateException("getpgid does not seem to work on this platform"); } return libc.getpgid(pid) != -1; }
Source:
<code>public JpaPagingItemReader<DayActivity> dayActivityReader() { try { String jpqlQuery = "SELECT d FROM DayActivity d WHERE d.startDate <= :yesterday AND d.aggregatesComputed = false"; JpaPagingItemReader<DayActivity> reader = new JpaPagingItemReader<>(); reader.setQueryString(jpqlQuery); reader.setParameterValues( Collections.singletonMap("yesterday", ZonedDateTime.now(DEFAULT_TIME_ZONE).minusDays(1).toLocalDate())); reader.setEntityManagerFactory(entityManager.getEntityManagerFactory()); reader.setPageSize(DAY_ACTIVITY_CHUNK_SIZE); reader.afterPropertiesSet(); reader.setSaveState(true); return reader; } <START> catch (Exception e) <END> { throw YonaException.unexpected(e); } }</code><technical_language>Please change this t a multicatch list of exceptions caught</technical_language>

Target:
public JpaPagingItemReader<DayActivity> dayActivityReader() { try { String jpqlQuery = "SELECT d FROM DayActivity d WHERE d.startDate <= :yesterday AND d.aggregatesComputed = false"; JpaPagingItemReader<DayActivity> reader = new JpaPagingItemReader<>(); reader.setQueryString(jpqlQuery); reader.setParameterValues(Collections.singletonMap("yesterday", TimeUtil.getStartOfDay(DEFAULT_TIME_ZONE, ZonedDateTime.now(DEFAULT_TIME_ZONE).minusDays(1)).toLocalDate())); reader.setEntityManagerFactory(entityManager.getEntityManagerFactory()); reader.setPageSize(DAY_ACTIVITY_CHUNK_SIZE); reader.afterPropertiesSet(); reader.setSaveState(true); return reader; } catch (Exception e) { throw YonaException.unexpected(e); } }