auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Map<String, R> resultFromBinary(byte[] binary) { <START> Aggregation<P, R, T> agg = this.result.values().stream().findAny().orElse(null); <END> if (agg == null) { return null; } ByteBuffer bb = ByteBuffer.wrap(binary); int mapSize = bb.getInt(); Map<String, R> resultMap = Maps.newHashMapWithExpectedSize(mapSize); for (int i = 0; i < mapSize; i++) { int keyLen = bb.getInt(); byte[] keyBytes = new byte[keyLen]; bb.get(keyBytes); String key = StringUtils.stringFromBinary(keyBytes); int valLen = bb.getInt(); byte[] valBytes = new byte[valLen]; bb.get(valBytes); R val = agg.resultFromBinary(valBytes); resultMap.put(key, val); } return resultMap; }</code><technical_language>This function ignore local result deserialize binary a map</technical_language>

Target:
public Map<String, R> resultFromBinary(byte[] binary) { final Aggregation<P, R, T> agg = this.getHelperAggregation(); ByteBuffer bb = ByteBuffer.wrap(binary); int mapSize = bb.getInt(); Map<String, R> resultMap = Maps.newHashMapWithExpectedSize(mapSize); for (int i = 0; i < mapSize; i++) { int keyLen = bb.getInt(); byte[] keyBytes = new byte[keyLen]; bb.get(keyBytes); String key = StringUtils.stringFromBinary(keyBytes); int valLen = bb.getInt(); byte[] valBytes = new byte[valLen]; bb.get(valBytes); R val = agg.resultFromBinary(valBytes); resultMap.put(key, val); } return resultMap; }
Source:
<code>private IAction createHierarchicalAction() { IAction action = new Action(Messages.ControlFlowView_hierarchicalViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { if (!fIsFlatList) { <START> swapBetweenFlatViewOrHierarchicalView(); <END> fIsFlatList = true; } } }; action.setToolTipText(Messages.ControlFlowView_hierarchicalViewToolTip); action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(IControlflowImageConstants.IMG_UI_HIERARCHICAL_VIEW)); action.setChecked(true); return action; }</code><technical_language>yeah, this a rush patch get -2 issues out of way. I time code quality</technical_language>

Target:
private IAction createHierarchicalAction() { IAction action = new Action(Messages.ControlFlowView_hierarchicalViewLabel, IAction.AS_RADIO_BUTTON) { @Override public void run() { if (fIsFlatViewClicked) { switchView(fHierarchicalList); fIsFlatViewClicked = false; } } }; action.setChecked(true); return action; }
Source:
<code>protected void initInput() { String treeID = getTreeID(); TmfStatisticsTreeNode statisticsTreeNode; if (TmfStatisticsTreeManager.containsTreeRoot(treeID)) { statisticsTreeNode = TmfStatisticsTreeManager.getStatTreeRoot(treeID); int numNodeTraces = statisticsTreeNode.getNbChildren(); Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(fTrace); int numTraces = traces.size(); if (numTraces == numNodeTraces) { boolean same = true; for (ITmfTrace trace : traces) { String traceName = trace.getName(); if (!statisticsTreeNode.containsChild(traceName)) { same = false; break; } } if (same) { fTreeViewer.setInput(statisticsTreeNode); return; } statisticsTreeNode.reset(); } } else { statisticsTreeNode = TmfStatisticsTreeManager.addStatsTreeRoot(treeID, getStatisticData()); } fTreeViewer.setInput(statisticsTreeNode); fPieChartModel = new TmfPieChartStatisticsModel(); <START> fPieChartViewer.setModel(fPieChartModel); <END> }</code><technical_language>do instead of 2 lines above: fPieChartViewer.setModel(getPieChartModel());</technical_language>

Target:
protected void initInput() { String treeID = getTreeID(); TmfStatisticsTreeNode statisticsTreeNode; if (TmfStatisticsTreeManager.containsTreeRoot(treeID)) { statisticsTreeNode = TmfStatisticsTreeManager.getStatTreeRoot(treeID); int numNodeTraces = statisticsTreeNode.getNbChildren(); Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(fTrace); int numTraces = traces.size(); if (numTraces == numNodeTraces) { boolean same = true; for (ITmfTrace trace : traces) { String traceName = trace.getName(); if (!statisticsTreeNode.containsChild(traceName)) { same = false; break; } } if (same) { fTreeViewer.setInput(statisticsTreeNode); return; } statisticsTreeNode.reset(); } } else { statisticsTreeNode = TmfStatisticsTreeManager.addStatsTreeRoot(treeID, getStatisticData()); } fTreeViewer.setInput(statisticsTreeNode); fPieChartViewer.setInput(getPieChartModel()); }
Source:
<code>private boolean isTestExcludedFromLang(Method method) { <START> String langFromConfig = System.getProperty("language") != null ? System.getProperty("language") <END> : Configuration.getPropertyFromFile("language"); if (method.isAnnotationPresent(DontRun.class)) { String[] excludedLangs = method.getAnnotation(DontRun.class).language(); if (Arrays.stream(excludedLangs) .anyMatch(e -> Configuration.getWikiLanguage().contains(e) || langFromConfig.equals(e))) { return true; } } if (method.isAnnotationPresent(RunOnly.class)) { String[] includedLangs = method.getAnnotation(RunOnly.class).language(); if (hasOnlyDefaultValue(includedLangs)) { return false; } else if (Arrays.stream(includedLangs).anyMatch(e->Configuration.getWikiLanguage().contains(e))) { return false; } else { return true; } } return false; }</code><technical_language>![MINOR](<LINK_1> 'Severity: MINOR') Define a constant instead of duplicating this literal "language" 3 times. [![rule](<LINK_0>](http://sonar-s4/coding_rules#rule_key=squid%3AS1192)</technical_language>

Target:
private boolean isTestExcludedFromLang(Method method) { String langFromConfig = System.getProperty("language") != null ? System.getProperty("language") : Configuration.getPropertyFromFile("language"); if (method.isAnnotationPresent(DontRun.class)) { String[] excludedLangs = method.getAnnotation(DontRun.class).language(); if (Arrays.stream(excludedLangs) .anyMatch(e -> Configuration.getWikiLanguage().contains(e) || langFromConfig.equals(e))) { return true; } } if (method.isAnnotationPresent(RunOnly.class)) { String[] includedLangs = method.getAnnotation(RunOnly.class).language(); if (hasOnlyDefaultValue(includedLangs)) { return false; } return !Arrays.stream(includedLangs).anyMatch(e->Configuration.getWikiLanguage().contains(e)); } return false; }
Source:
<code>public void testUpdateSchema() { DefaultTableSchemaUpdater schemaUpdater = new DefaultTableSchemaUpdater(); Application app = mock(Application.class); <START> Mockito.when(app.getApplicationContext()).thenReturn(context); <END> TestTable testTable = new TestTable(app, DATABASE_NAME, TABLE_NAME, TABLE_VERSION, Arrays.asList(createColumn()), null, null, schemaUpdater); TestOnlineHelper onlineHelper = new TestOnlineHelper(context, null, null, TABLE_VERSION); SQLiteDatabase db = onlineHelper.getWritableDatabase(); schemaUpdater.updateSchema(db, testTable); assertEquals(true, TableExists(db)); }</code><technical_language>MockContext</technical_language>

Target:
public void testUpdateSchema() { DefaultTableSchemaUpdater schemaUpdater = new DefaultTableSchemaUpdater(); Application app = mock(Application.class); Context context = mock(Context.class); Mockito.when(app.getApplicationContext()).thenReturn(context); TestTable testTable = new TestTable(app, DATABASE_NAME, TABLE_NAME, TABLE_VERSION, Arrays.asList(createColumn()), null, null, schemaUpdater); TestOnlineHelper onlineHelper = new TestOnlineHelper(context, null, null, TABLE_VERSION); SQLiteDatabase db = onlineHelper.getWritableDatabase(); schemaUpdater.updateSchema(db, testTable); assertEquals(true, TableExists(db)); }
Source:
<code>public void requestPulse(GlowBlock block) { ItemTable itemTable = ItemTable.instance(); BlockType type = itemTable.getBlock(block.getType()); <START> if (type == null || type.getPulseTickSpeed() == null) { <END> return; } requestPulse(block, type.getPulseTickSpeed(), type.isPulseOnce()); }</code><technical_language>I meant in pulseTickMap(), store values more. memory</technical_language>

Target:
public void requestPulse(GlowBlock block) { requestPulse(block.getLocation()); }
Source:
<code>public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { if (target.startsWith("/test")) { String pkgId = target.substring(target.lastIndexOf("/") + 1); File pkgZip = new File(testStore, pkgId + ".zip"); if (pkgZip.exists()) { response.setContentLength((int) pkgZip.length()); try (ServletOutputStream os = response.getOutputStream()) { byte[] byteArray = FileUtils.readFileToByteArray(pkgZip); os.write(byteArray, 0, byteArray.length); } <START> response.setStatus(HttpServletResponse.SC_OK); <END> } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } }</code><technical_language>set status writing output stream</technical_language>

Target:
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { if (target.startsWith("/test")) { String pkgId = target.substring(target.lastIndexOf("/") + 1); File pkgZip = new File(testStore, pkgId + ".zip"); if (pkgZip.exists()) { response.setContentLength((int) pkgZip.length()); response.setStatus(HttpServletResponse.SC_OK); try (ServletOutputStream os = response.getOutputStream(); FileInputStream is = new FileInputStream(pkgZip)) { IOUtils.copy(is, os); } } else { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } }
Source:
<code>private void handleHangingStoppingRuntime(KubernetesInternalRuntime runtime) { RuntimeIdentity runtimeId = runtime.getContext().getIdentity(); try { eventPublisher.sendAbnormalStoppingEvent( runtimeId, WorkspaceStatus.STOPPING, "Workspace is not stopped in time. Trying to stop it forcibly"); runtime.internalStop(emptyMap()); runtime.markStopped(); eventPublisher.sendAbnormalStoppedEvent(runtimeId, "Workspace stop reached timeout"); LOG.info( "Runtime '{}:{}:{}' is not stopped in time. Stopped it forcibly", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId()); } catch (InfrastructureException e) { LOG.error( "Error occurred during forcibly stopping of hanging runtime '{}:{}:{}'. Error: {}", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId(), <START> e.getMessage(), <END> e); } }</code><technical_language>In this class, a single thread for workspaces in system needs tracked. Calling internalStop execute cleanup operations in thread. concerned this influence system in a case get request timeout calls k8s API waiting for deployments removal in thread long</technical_language>

Target:
private void handleHangingStoppingRuntime(KubernetesInternalRuntime runtime) { RuntimeIdentity runtimeId = runtime.getContext().getIdentity(); try { eventPublisher.sendAbnormalStoppingEvent( runtimeId, "Workspace is not stopped in time. Trying to stop it forcibly"); runtime.internalStop(emptyMap()); runtime.markStopped(); eventPublisher.sendAbnormalStoppedEvent(runtimeId, "Workspace stop reached timeout"); LOG.info( "Runtime '{}:{}:{}' is not stopped in time. Stopped it forcibly", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId()); } catch (InfrastructureException e) { LOG.error( "Error occurred during forcibly stopping of hanging runtime '{}:{}:{}'. Error: {}", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId(), e.getMessage(), e); } }
Source:
<code>private void initReader() throws IOException { if (reader != null) { reader.close(); reader = null; } if (footersIterator.hasNext()) { Footer footer = footersIterator.next(); List<BlockMetaData> blocks = footer.getParquetMetadata().getBlocks(); if (filter.isPresent() && filter.get().isRight()) { blocks = ParquetInputFormat.applyRowGroupFilters(filter.get().asRight(), footer.getParquetMetadata().getFileMetaData().getSchema(), blocks); <START> } <END> reader = new InternalParquetRecordReader<T>(readSupport, filter); reader.initialize( readContext.getRequestedSchema(), globalMetaData.getSchema(), footer.getParquetMetadata().getFileMetaData().getKeyValueMetaData(), readContext.getReadSupportMetadata(), footer.getFile(), blocks, conf); } }</code><technical_language>If need explicitly check means need improve this. Some type of filter abstraction needed. UnboundRecordFilter wrapped in a notion of Filter BlockMetadata? interface Filter { List<BlockMetaData> filterRowGroups(List<BlockMetaData> rowGroups); ... } class UnbounRecordFilter { List<BlockMetaData> filterRowGroups(List<BlockMetaData> rowGroups) { return rowGroups; } } class PredicateFilter { List<BlockMetaData> filterRowGroups(List<BlockMetaData> rowGroups) { return ParquetInputFormat.applyRowGroupFilters(this, footer.getParquetMetadata().getFileMetaData().getSchema(), rowGroups); } } lines</technical_language>

Target:
private void initReader() throws IOException { if (reader != null) { reader.close(); reader = null; } if (footersIterator.hasNext()) { Footer footer = footersIterator.next(); List<BlockMetaData> blocks = footer.getParquetMetadata().getBlocks(); List<BlockMetaData> filteredBlocks = RowGroupFilter.filterRowGroups(filter, blocks, footer.getParquetMetadata().getFileMetaData().getSchema()); reader = new InternalParquetRecordReader<T>(readSupport, filter); reader.initialize( readContext.getRequestedSchema(), globalMetaData.getSchema(), footer.getParquetMetadata().getFileMetaData().getKeyValueMetaData(), readContext.getReadSupportMetadata(), footer.getFile(), filteredBlocks, conf); } }
Source:
<code>public void peoplewiththeirFirstNameIsJames() { <START> List<Person> matches = this.personRepository.peopleWiththeirFirstNameIsJames(); <END> assertThat("1940 and 1942", matches.size(), equalTo(2)); assertThat("1940 and 1942", matches, containsInAnyOrder(hasProperty("lastname", equalTo("Cagney")), hasProperty("lastname", equalTo("Stewart")))); }</code><technical_language>their->Their</technical_language>

Target:
public void peoplewiththeirFirstNameIsJames() { List<Person> matches = this.personRepository.peopleWithTheirFirstNameIsJames(); assertThat("1940 and 1942", matches.size(), equalTo(2)); assertThat("1940 and 1942", matches, containsInAnyOrder(hasProperty("lastname", equalTo("Cagney")), hasProperty("lastname", equalTo("Stewart")))); }
Source:
<code><START> public void stop() { <END> try { jmsConnectionFactory.closeConnection(connection); jmsConnectionFactory.closeSession(session); jmsConnectionFactory.closeMessageConsumer(messageConsumer); } catch (JMSServerConnectorException e) { logger.error("Error while closing the connection, session and consumer ", e); } }</code><technical_language>Shouln't this moved unbind need stop server is undeployed</technical_language>

Target:
public void stop() throws JMSServerConnectorException { closeAll(); }
Source:
<code>public BinaryResult apply(final ProjectResource rsrc, final Input input) { return new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { PrintWriter writer = new PrintWriter( new OutputStreamWriter(out, UTF_8)) { @Override public void println() { write('\n'); } }; try { GarbageCollectionResult result = garbageCollectionFactory.create().run( Collections.singletonList(rsrc.getNameKey()), <START> true, <END> input.showProgress ? writer : null); String msg = "Garbage collection completed successfully."; if (result.hasErrors()) { for (GarbageCollectionResult.Error e : result.getErrors()) { switch (e.getType()) { case REPOSITORY_NOT_FOUND: msg = "Error: project \"" + e.getProjectName() + "\" not found."; break; case GC_ALREADY_SCHEDULED: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" was already scheduled."; break; case GC_FAILED: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" failed."; break; default: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" failed: " + e.getType() + "."; } } } writer.println(msg); } finally { writer.flush(); } } }.setContentType("text/plain") .setCharacterEncoding(UTF_8.name()) .disableGzip(); }</code><technical_language>set mode REST</technical_language>

Target:
public BinaryResult apply(final ProjectResource rsrc, final Input input) { return new BinaryResult() { @Override public void writeTo(OutputStream out) throws IOException { PrintWriter writer = new PrintWriter( new OutputStreamWriter(out, UTF_8)) { @Override public void println() { write('\n'); } }; try { GarbageCollectionResult result = garbageCollectionFactory.create().run( Collections.singletonList(rsrc.getNameKey()), input.aggressive, input.showProgress ? writer : null); String msg = "Garbage collection completed successfully."; if (result.hasErrors()) { for (GarbageCollectionResult.Error e : result.getErrors()) { switch (e.getType()) { case REPOSITORY_NOT_FOUND: msg = "Error: project \"" + e.getProjectName() + "\" not found."; break; case GC_ALREADY_SCHEDULED: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" was already scheduled."; break; case GC_FAILED: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" failed."; break; default: msg = "Error: garbage collection for project \"" + e.getProjectName() + "\" failed: " + e.getType() + "."; } } } writer.println(msg); } finally { writer.flush(); } } }.setContentType("text/plain") .setCharacterEncoding(UTF_8.name()) .disableGzip(); }
Source:
<code><START> public static RequestPath parse(RestRequest restRequest, List<String> prefixesToRemove, String clusterName) { <END> String path = restRequest.getPath(); int offset = 0; String prefixFound = ""; if (prefixesToRemove != null) { for (String prefix : prefixesToRemove) { int nextSegmentOffset = matchPathSegments(path, offset, prefix, false); if (nextSegmentOffset >= 0) { prefixFound = prefix; offset = nextSegmentOffset; break; } } } String clusterNameFound = ""; if (clusterName != null) { int nextSegmentOffset = matchPathSegments(path, offset, clusterName, true); if (nextSegmentOffset >= 0) { clusterNameFound = clusterName; offset = nextSegmentOffset; } } RestUtils.SubResource subResource = null; int lastSlashOffset = path.lastIndexOf('/'); if (lastSlashOffset > offset) { try { subResource = RestUtils.SubResource.valueOf(path.substring(lastSlashOffset + 1)); } catch (IllegalArgumentException e) { } } String operationOrBlobId = path.substring(offset, subResource == null ? path.length() : lastSlashOffset); if ((operationOrBlobId.isEmpty() || operationOrBlobId.equals("/")) && restRequest.getArgs() .containsKey(RestUtils.Headers.BLOB_ID)) { operationOrBlobId = restRequest.getArgs().get(RestUtils.Headers.BLOB_ID).toString(); } return new RequestPath(prefixFound, clusterNameFound, operationOrBlobId, subResource); }</code><technical_language>correct if I wrong, I query parameters (if in restRequest) parsed uri, extracted else</technical_language>

Target:
public static RequestPath parse(RestRequest restRequest, List<String> prefixesToRemove, String clusterName) { return parse(restRequest.getPath(), restRequest.getArgs(), prefixesToRemove, clusterName); }
Source:
<code>public TaskDefinition save(TaskDefinition taskDefinition) { taskServiceWrapper.saveTaskDefinition(taskDefinition); <START> return Context.getSchedulerService().getTaskByName(taskDefinition.getName()); <END> }</code><technical_language>do fetch task again</technical_language>

Target:
public TaskDefinition save(TaskDefinition taskDefinition) { taskServiceWrapper.saveTaskDefinition(taskDefinition); return taskDefinition; }
Source:
<code>public void testValidateStatOutput() throws Exception { ZooKeeper zk1 = createClient(); ZooKeeper zk2 = createClient(); String resp = sendRequest("stat"); BufferedReader in = new BufferedReader(new StringReader(resp)); String line; line = in.readLine(); Assert.assertTrue(Pattern.matches("^.*\\s\\d+\\.\\d+\\.\\d+-.*$", line)); Assert.assertTrue(Pattern.matches("^Clients:$", in.readLine())); int count = 0; while ((line = in.readLine()).length() > 0) { count++; Assert.assertTrue(Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+\\)$", line)); } Assert.assertTrue(count >= 2); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Latency min/avg/max: \\d+/\\d+/\\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Received: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Sent: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Connections: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Outstanding: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Zxid: 0x[\\da-fA-F]+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Mode: .*$", line)); line = in.readLine(); <START> Assert.assertTrue(Pattern.matches("^Fsync threshold exceeded: \\d+$", line)); <END> line = in.readLine(); Assert.assertTrue(Pattern.matches("^Node count: \\d+$", line)); zk1.close(); zk2.close(); }</code><technical_language>chance add this end of output? clear order in some cases existing monitoring expecting original order. Appending helps wrt b/w compat</technical_language>

Target:
public void testValidateStatOutput() throws Exception { ZooKeeper zk1 = createClient(); ZooKeeper zk2 = createClient(); String resp = sendRequest("stat"); BufferedReader in = new BufferedReader(new StringReader(resp)); String line; line = in.readLine(); Assert.assertTrue(Pattern.matches("^.*\\s\\d+\\.\\d+\\.\\d+-.*$", line)); Assert.assertTrue(Pattern.matches("^Clients:$", in.readLine())); int count = 0; while ((line = in.readLine()).length() > 0) { count++; Assert.assertTrue(Pattern.matches("^ /.*:\\d+\\[\\d+\\]\\(queued=\\d+,recved=\\d+,sent=\\d+\\)$", line)); } Assert.assertTrue(count >= 2); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Latency min/avg/max: \\d+/\\d+/\\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Received: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Sent: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Connections: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Outstanding: \\d+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Zxid: 0x[\\da-fA-F]+$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Mode: .*$", line)); line = in.readLine(); Assert.assertTrue(Pattern.matches("^Node count: \\d+$", line)); zk1.close(); zk2.close(); }
Source:
<code>public Feature decodeLoc(LineIterator lineIterator) { <START> return decodeShallow(lineIterator); <END> }</code><technical_language>This is more expensive previous decodeLoc implementation, I a pretty underused operation is a difference anywhere. I in reindexing operations</technical_language>

Target:
public Feature decodeLoc(LineIterator lineIterator) throws IOException { return decode(lineIterator, DecodeDepth.SHALLOW); }
Source:
<code>public BalancerSegmentHolder getRandomBalancerSegmentHolder(final List<ServerHolder> serverHolders) { Random rand = new Random(0); ServerHolder fromServerHolder = null; DataSegment proposalSegment = null; int numSoFar = 0; for (ServerHolder server : serverHolders) { for (DataSegment segment : server.getServer().getSegments().values()) { int randNum = rand.nextInt(numSoFar + 1); if (randNum == numSoFar) { fromServerHolder = server; proposalSegment = segment; } numSoFar++; } } <START> return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment); <END> }</code><technical_language>if fromServerHolder proposalSegment null here</technical_language>

Target:
public BalancerSegmentHolder getRandomBalancerSegmentHolder(final List<ServerHolder> serverHolders) { final Random rand = new Random(); ServerHolder fromServerHolder = null; DataSegment proposalSegment = null; int numSoFar = 0; for (ServerHolder server : serverHolders) { for (DataSegment segment : server.getServer().getSegments().values()) { int randNum = rand.nextInt(numSoFar + 1); if (randNum == numSoFar) { fromServerHolder = server; proposalSegment = segment; } numSoFar++; } } if (fromServerHolder != null) { return new BalancerSegmentHolder(fromServerHolder.getServer(), proposalSegment); } else { return null; } }
Source:
<code>public IRegion getRegion(String path) { <START> if (Strings.emptyToNull(path) == null) <END> return null; if (path.startsWith(":")) { path = path.substring(1); } String[] paths = path.split(":"); Node current = getYaml(); Node start; int pPos = 0; boolean noPath = false; do { String currentPath = paths[pPos]; start = current; if (current.getNodeId() == NodeId.mapping) { MappingNode mn = (MappingNode) current; for (NodeTuple node : mn.getValue()) { Node keyNode = node.getKeyNode(); if (keyNode.getNodeId() == NodeId.scalar) { ScalarNode scalar = (ScalarNode) keyNode; if (Objects.equals(currentPath, scalar.getValue())) { pPos++; current = node.getValueNode(); break; } } } } else if (current.getNodeId() == NodeId.sequence) { SequenceNode sq = (SequenceNode) current; if (!currentPath.startsWith("@")) { throw new IllegalStateException("Should be a sequence"); } Integer seqPos = Integer.valueOf(currentPath.substring(1)); pPos++; current = sq.getValue().get(seqPos); } if (start == current) { noPath = true; current = null; } } while (pPos < paths.length && !noPath); if (current == null) return null; try { int offset = getLineOffset(current.getStartMark().getLine()); int length = getLineOffset(current.getEndMark().getLine()); return new Region(offset, length - offset); } catch (BadLocationException e) { return null; } }</code><technical_language>Inconsistent usage of in ifs. omit here, 165-167. code is good, more difficult read</technical_language>

Target:
public IRegion getRegion(String path) { if (Strings.emptyToNull(path) == null) { return null; } if (path.startsWith(":")) { path = path.substring(1); } String[] paths = path.split(":"); Node current = getYaml(); Node start; int pPos = 0; boolean noPath = false; do { String currentPath = paths[pPos]; start = current; if (current.getNodeId() == NodeId.mapping) { MappingNode mn = (MappingNode) current; for (NodeTuple node : mn.getValue()) { Node keyNode = node.getKeyNode(); if (keyNode.getNodeId() == NodeId.scalar) { ScalarNode scalar = (ScalarNode) keyNode; if (Objects.equals(currentPath, scalar.getValue())) { pPos++; current = node.getValueNode(); break; } } } } else if (current.getNodeId() == NodeId.sequence) { SequenceNode sq = (SequenceNode) current; Integer seqPos; try { if (currentPath.startsWith("@")) { currentPath = currentPath.substring(1); } seqPos = Integer.valueOf(currentPath); } catch (Exception e) { throw new IllegalStateException("Should be a sequence"); } pPos++; current = sq.getValue().get(seqPos); } if (start == current) { noPath = true; current = null; } } while (pPos < paths.length && !noPath); if (current == null) { return null; } try { int offset = getLineOffset(current.getStartMark().getLine()); int length = getLineOffset(current.getEndMark().getLine()); return new Region(offset, length - offset); } catch (BadLocationException e) { return null; } }
Source:
<code>static void addFile(List<FileStatus> result, LocatedFileStatus lfs, long startTime, long endTime) { long timestamp = WAL.getTimestamp(lfs.getPath().getName()); if (timestamp > 0) { if (timestamp <= endTime && timestamp >= startTime) { LOG.info("Found {}", lfs.getPath()); result.add(lfs); } else { LOG.debug("Skipped {}, outside range [{}/{} - {}/{}]", lfs.getPath(), startTime, Instant.ofEpochMilli(startTime), endTime, Instant.ofEpochMilli(endTime)); } } else { <START> LOG.info("Found {}", lfs); <END> result.add(lfs); } }</code><technical_language>Nit: worth put a message line #343, in order explicitly this timestamp? this is a recovered.edit file</technical_language>

Target:
static void addFile(List<FileStatus> result, LocatedFileStatus lfs, long startTime, long endTime) { long timestamp = WAL.getTimestamp(lfs.getPath().getName()); if (timestamp > 0) { if (timestamp <= endTime && timestamp >= startTime) { LOG.info("Found {}", lfs.getPath()); result.add(lfs); } else { LOG.info("Skipped {}, outside range [{}/{} - {}/{}]", lfs.getPath(), startTime, Instant.ofEpochMilli(startTime), endTime, Instant.ofEpochMilli(endTime)); } } else { LOG.info("Found (no-timestamp!) {}", lfs); result.add(lfs); } }
Source:
<code>public int hashCode() { <START> return 0; <END> }</code><technical_language>@fanifieiev correct calculate hashCode. Please, others Cactoos classes do it</technical_language>

Target:
public int hashCode() { return new HashCode(new Unchecked<>(this.shead::get).value()).value(); }
Source:
<code>private void addExtraSets(Object xoaiItemsList, String setSpec, Date from, Date until) { List<Xitem> xoaiItems = (List<Xitem>)xoaiItemsList; List<OAIRecord> oaiRecords = recordService.findOaiRecordsNotInThisSet(setSpec, from, until); <START> if (oaiRecords == null && oaiRecords.isEmpty()) { <END> return; } int j = 0; for (int i = 0; i < xoaiItems.size(); i++) { Xitem xitem = xoaiItems.get(i); while (j < oaiRecords.size() && xitem.getIdentifier().compareTo(oaiRecords.get(j).getGlobalId()) > 0) { j++; } while (j < oaiRecords.size() && xitem.getIdentifier().equals(oaiRecords.get(j).getGlobalId())) { xoaiItems.get(i).getSets().add(new Set(oaiRecords.get(j).getSetName())); j++; } } }</code><technical_language>&& operator changed ||</technical_language>

Target:
private void addExtraSets(Object xoaiItemsList, String setSpec, Date from, Date until) { List<Xitem> xoaiItems = (List<Xitem>)xoaiItemsList; List<OAIRecord> oaiRecords = recordService.findOaiRecordsNotInThisSet(setSpec, from, until); if (oaiRecords == null || oaiRecords.isEmpty()) { return; } int j = 0; for (int i = 0; i < xoaiItems.size(); i++) { Xitem xitem = xoaiItems.get(i); while (j < oaiRecords.size() && xitem.getIdentifier().compareTo(oaiRecords.get(j).getGlobalId()) > 0) { j++; } while (j < oaiRecords.size() && xitem.getIdentifier().equals(oaiRecords.get(j).getGlobalId())) { xoaiItems.get(i).getSets().add(new Set(oaiRecords.get(j).getSetName())); j++; } } }
Source:
<code>public void testInitializeAndClock() { final int initialWorkerClock = 10; final int initialGlobalMinimumClock = 30; <START> final int numberOFClockCalls = 3; <END> final ResettingCountDownLatch countDownLatch = new ResettingCountDownLatch(numberOFClockCalls); doAnswer(invocation -> { final byte[] data = invocation.getArgumentAt(1, byte[].class); final AvroClockMsg sendMsg = codec.decode(data); if (sendMsg.getType() == ClockMsgType.RequestInitClock) { final AvroClockMsg initClockMsg = ClockManager.getReplyInitialClockMessage(initialGlobalMinimumClock, initialWorkerClock); final byte[] replyData = codec.encode(initClockMsg); final AggregationMessage aggregationMessage = getTestAggregationMessage("worker", replyData); sspWorkerClockMessageHandler.onNext(aggregationMessage); } else if (sendMsg.getType() == ClockMsgType.Tick) { countDownLatch.countDown(); } return null; }).when(mockAggregationSlave).send(anyString(), anyObject()); sspWorkerClock.initialize(); assertEquals(initialWorkerClock, sspWorkerClock.getWorkerClock()); assertEquals(initialGlobalMinimumClock, sspWorkerClock.getGlobalMinimumClock()); for (int i = 0; i < numberOFClockCalls; i++) { assertEquals(initialWorkerClock + i, sspWorkerClock.getWorkerClock()); sspWorkerClock.clock(); } countDownLatch.await(); assertEquals(initialWorkerClock + numberOFClockCalls, sspWorkerClock.getWorkerClock()); assertEquals(initialGlobalMinimumClock, sspWorkerClock.getGlobalMinimumClock()); }</code><technical_language>Of</technical_language>

Target:
public void testInitializeAndClock() { final int numberOfClockCalls = 3; final AtomicInteger numberOfTickMsgCalls = new AtomicInteger(0); doAnswer(invocation -> { final byte[] data = invocation.getArgumentAt(1, byte[].class); final AvroClockMsg sendMsg = codec.decode(data); if (sendMsg.getType() == ClockMsgType.RequestInitClockMsg) { final AvroClockMsg initClockMsg = ClockManager.getReplyInitialClockMessage(initialGlobalMinimumClock, initialWorkerClock); final byte[] replyData = codec.encode(initClockMsg); final AggregationMessage aggregationMessage = getTestAggregationMessage("worker", replyData); sspWorkerClockMessageHandler.onNext(aggregationMessage); } else if (sendMsg.getType() == ClockMsgType.TickMsg) { numberOfTickMsgCalls.incrementAndGet(); } return null; }).when(mockAggregationSlave).send(anyString(), anyObject()); sspWorkerClock.initialize(); assertEquals(initialWorkerClock, sspWorkerClock.getWorkerClock()); assertEquals(initialGlobalMinimumClock, sspWorkerClock.getGlobalMinimumClock()); for (int i = 0; i < numberOfClockCalls; i++) { assertEquals(initialWorkerClock + i, sspWorkerClock.getWorkerClock()); sspWorkerClock.clock(); } assertEquals(numberOfClockCalls, numberOfTickMsgCalls.intValue()); assertEquals(initialWorkerClock + numberOfClockCalls, sspWorkerClock.getWorkerClock()); assertEquals(initialGlobalMinimumClock, sspWorkerClock.getGlobalMinimumClock()); }
Source:
<code>private ImageMapType getCitySchemaMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setMinZoom(ZOOM_MIN); opts.setMaxZoom(ZOOM_MAX); opts.setName(MAP_TYPE_ID); opts.setTileSize(Size.newInstance(TILE_SIZE, TILE_SIZE)); opts.setTileUrl(new TileUrlCallBack() { @Override public String getTileUrl(Point point, int zoomLevel) { Point normalizedCoord = getNormalizedCoords(point, zoomLevel); if (normalizedCoord == null) { return null; } <START> return TILE_IMAGES_PATH.replace("/", PATH_SEPARATOR) + PATH_SEPARATOR <END> + (zoomLevel - 2) + PATH_SEPARATOR + + (zoomLevel - 2) + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getY() + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getX() + FILE_EXTENSION_SEPARATOR + TILE_IMAGES_FILE_EXTENSION; } }); return ImageMapType.newInstance(opts); }</code><technical_language>Do replace "/" "/"? ;)</technical_language>

Target:
private ImageMapType getCitySchemaMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setMinZoom(ZOOM_MIN); opts.setMaxZoom(ZOOM_MAX); opts.setName(MAP_TYPE_ID); opts.setTileSize(Size.newInstance(TILE_SIZE, TILE_SIZE)); opts.setTileUrl(new TileUrlCallBack() { @Override public String getTileUrl(Point point, int zoomLevel) { Point normalizedCoord = getNormalizedCoords(point, zoomLevel); if (normalizedCoord == null) { return null; } return TILE_IMAGES_PATH + PATH_SEPARATOR + (zoomLevel - 2) + PATH_SEPARATOR + + (zoomLevel - 2) + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getY() + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getX() + FILE_EXTENSION_SEPARATOR + TILE_IMAGES_FILE_EXTENSION; } }); return ImageMapType.newInstance(opts); }
Source:
<code>FrameType(int encodedType) { <START> this(encodedType, 0); <END> }</code><technical_language>suggestion this(encodedType, Flags.EMPTY);</technical_language>

Target:
FrameType(int encodedType) { this(encodedType, Flags.EMPTY); }
Source:
<code>protected Message<?> receiveMessage() { if (this.limitingSource != null) { return this.limitingSource.receive(this.maxFetchSize); } else { <START> return this.source.receive(); <END> } }</code><technical_language>Well, I if live LimitingMessageSource contract target MessageSource implementation get deal provided maxFetchSize configuration. right JdbcPollingChannelAdapter. I reason overhead SourcePollingChannelAdapter maxFetchSize logic, provide sense for that. I add maxFetchSize AbstractMessageSource all. introduce contract like: interface MaxFetchSizeAware { void setMaxFetchSize(); } or, of course, some other name. But... big height I live current solution, if open continue discussion</technical_language>

Target:
protected Message<?> receiveMessage() { return this.source.receive(); }
Source:
<code>public void create(String tableName, NewTableConfiguration ntc) throws AccumuloException, AccumuloSecurityException, TableExistsException { checkArgument(tableName != null, "tableName is null"); checkArgument(ntc != null, "ntc is null"); List<ByteBuffer> args = new ArrayList<>(); args.add(ByteBuffer.wrap(tableName.getBytes(UTF_8))); args.add(ByteBuffer.wrap(ntc.getTimeType().name().getBytes(UTF_8))); int numSplits = ntc.getSplits().size(); args.add(ByteBuffer.wrap(String.valueOf(numSplits).getBytes(UTF_8))); if (numSplits > 0) { for (Text t : ntc.getSplits()) { <START> args.add(ByteBuffer.wrap(t.toString().getBytes(UTF_8))); <END> } } Map<String,String> opts = ntc.getProperties(); try { doTableFateOperation(tableName, AccumuloException.class, FateOperation.TABLE_CREATE, args, opts); } catch (TableNotFoundException e) { throw new AssertionError(e); } }</code><technical_language>Splits binary data. Converting Text a String a ByteBuffer scramble binary data (because encodes decodes utf-8). I recommend args.add(TextUtil. getByteBuffer(t)). TextUtil properly handles edge case Text a byte array longer length</technical_language>

Target:
public void create(String tableName, NewTableConfiguration ntc) throws AccumuloException, AccumuloSecurityException, TableExistsException { checkArgument(tableName != null, "tableName is null"); checkArgument(ntc != null, "ntc is null"); List<ByteBuffer> args = new ArrayList<>(); args.add(ByteBuffer.wrap(tableName.getBytes(UTF_8))); args.add(ByteBuffer.wrap(ntc.getTimeType().name().getBytes(UTF_8))); args.add(ByteBuffer.wrap(ntc.getInitialTableState().name().getBytes(UTF_8))); int numSplits = ntc.getSplits().size(); args.add(ByteBuffer.wrap(String.valueOf(numSplits).getBytes(UTF_8))); if (numSplits > 0) { for (Text t : ntc.getSplits()) { args.add(TextUtil.getByteBuffer(t)); } } Map<String,String> opts = ntc.getProperties(); try { doTableFateOperation(tableName, AccumuloException.class, FateOperation.TABLE_CREATE, args, opts); } catch (TableNotFoundException e) { throw new AssertionError(e); } }
Source:
<code>private static JavaSymbol.MethodJavaSymbol getSamMethod(JavaType lambdaType) { for (Symbol member : lambdaType.symbol().memberSymbols()) { if (member.isMethodSymbol() && member.isAbstract()) { return (JavaSymbol.MethodJavaSymbol) member; } } <START> for (ClassJavaType type : lambdaType.symbol.superTypes()) { <END> for (Symbol member : type.symbol().memberSymbols()) { if (member.isMethodSymbol() && member.isAbstract()) { return (JavaSymbol.MethodJavaSymbol) member; } } } return null; }</code><technical_language>Nesting simplified a single call chain</technical_language>

Target:
private static JavaSymbol.MethodJavaSymbol getSamMethod(JavaType lambdaType) { for (Symbol member : lambdaType.symbol().memberSymbols()) { if (member.isMethodSymbol() && member.isAbstract()) { return (JavaSymbol.MethodJavaSymbol) member; } } for (ClassJavaType type : lambdaType.symbol.superTypes()) { JavaSymbol.MethodJavaSymbol samMethod = getSamMethod(type); if (samMethod != null) { return samMethod; } } return null; }
Source:
<code>public RegexSearchQuerySpec( @JsonProperty("pattern") String pattern ) { this.pattern = pattern; <START> compiled = Pattern.compile(pattern); <END> }</code><technical_language>this fail if pattern null</technical_language>

Target:
public RegexSearchQuerySpec( @JsonProperty("pattern") String pattern ) { this.pattern = Preconditions.checkNotNull(pattern, "pattern should not be null"); compiled = Pattern.compile(pattern); }
Source:
<code>public void updateCategories(List<String> selectedCategories) { Single<Boolean> resultSingle =reasonBuilder.getReason(media, null) <START> .flatMap((reason) -> categoryEditHelper.makeCategoryEdit(getContext(), media, selectedCategories, this)); <END> compositeDisposable.add(resultSingle .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { Timber.d("Categories are added."); onOutsideOfCategoryEditClicked(); media.setAddedCategories(selectedCategories); updateCategoryList(); })); }</code><technical_language>I understand @neslihanturan . is issue this implementation</technical_language>

Target:
public void updateCategories(List<String> selectedCategories) { compositeDisposable.add(categoryEditHelper.makeCategoryEdit(getContext(), media, selectedCategories, this) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { Timber.d("Categories are added."); onOutsideOfCategoryEditClicked(); media.setAddedCategories(selectedCategories); updateCategoryList(); })); }
Source:
<code>public Color getBackground(Object element, int columnIndex) { int category = ((MyModel) element).category; if (category == 0) { <START> return Display.getCurrent().getSystemColor(SWT.COLOR_RED); <END> } else if (category == 1) { return Display.getCurrent().getSystemColor(SWT.COLOR_GRAY); } else if (category == 2) { return Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW); } else if (category == 3) { return Display.getCurrent().getSystemColor(SWT.COLOR_BLUE); } else if (category == 4) { return Display.getCurrent().getSystemColor(SWT.COLOR_GREEN); } else if (category == 5) { return Display.getCurrent().getSystemColor(SWT.COLOR_CYAN); } else if (category == 6) { return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); } return null; }</code><technical_language>I this reads better, if extract Display.getCurrent() a local variable this block</technical_language>

Target:
public Color getBackground(Object element, int columnIndex) { int category = ((MyModel) element).getCategory(); Display display = Display.getCurrent(); if (category == 0) { return display.getSystemColor(SWT.COLOR_RED); } else if (category == 1) { return display.getSystemColor(SWT.COLOR_GRAY); } else if (category == 2) { return display.getSystemColor(SWT.COLOR_YELLOW); } else if (category == 3) { return display.getSystemColor(SWT.COLOR_BLUE); } else if (category == 4) { return display.getSystemColor(SWT.COLOR_GREEN); } else if (category == 5) { return display.getSystemColor(SWT.COLOR_CYAN); } else if (category == 6) { return display.getSystemColor(SWT.COLOR_WHITE); } return null; }
Source:
<code>public static boolean isKindEditable(Property capsulePart, CapsulePartKindEnum newKind) { boolean result = true; UMLRTCapsulePart partFacade = (capsulePart == null) ? null : UMLRTCapsulePart.getInstance(capsulePart); if (partFacade != null) { UMLRTCapsulePartKind currentKind = partFacade.getKind(); UMLRTCapsulePartKind targetKind = CapsulePartKindEnum.toFacade(newKind); if (targetKind == UMLRTCapsulePartKind.NULL) { result = false; } else if (targetKind != currentKind) { if (partFacade.isInherited()) { result = (currentKind != UMLRTCapsulePartKind.PLUG_IN) && (targetKind != UMLRTCapsulePartKind.PLUG_IN); } <START> if (completesCycle(capsulePart.getType(), capsulePart) && newKind == CapsulePartKindEnum.FIXED) { <END> result = false; } } } return result; }</code><technical_language>If this matters for fixed kind, test newKind left side of && short-circuit save effort of checking for cycles</technical_language>

Target:
public static boolean isKindEditable(Property capsulePart, CapsulePartKindEnum newKind) { boolean result = true; UMLRTCapsulePart partFacade = (capsulePart == null) ? null : UMLRTCapsulePart.getInstance(capsulePart); if (partFacade != null) { UMLRTCapsulePartKind currentKind = partFacade.getKind(); UMLRTCapsulePartKind targetKind = CapsulePartKindEnum.toFacade(newKind); if (targetKind == UMLRTCapsulePartKind.NULL) { result = false; } else if (targetKind != currentKind) { if (partFacade.isInherited()) { result = (currentKind != UMLRTCapsulePartKind.PLUG_IN) && (targetKind != UMLRTCapsulePartKind.PLUG_IN); } if (newKind == CapsulePartKindEnum.FIXED && completesCycle(capsulePart.getType(), capsulePart)) { result = false; } } } return result; }
Source:
<code>private static Set<String> extractStringInterpolationIdentifiers(PyFunctionDefTree functionTree) { return functionTree.descendants(Kind.STRING_LITERAL) .map(PyStringLiteralTree.class::cast) .flatMap(str -> str.stringElements().stream()) <START> .filter(str -> str.prefix().equals("f")) <END> .map(PyStringElementTree::trimmedQuotesValue) .flatMap(UnusedLocalVariableCheck::extractInterpolations) .collect(Collectors.toSet()); }</code><technical_language>F-strings (with a capital F)</technical_language>

Target:
private static Set<String> extractStringInterpolationIdentifiers(PyFunctionDefTree functionTree) { return functionTree.descendants(Kind.STRING_LITERAL) .map(PyStringLiteralTree.class::cast) .flatMap(str -> str.stringElements().stream()) .filter(str -> str.prefix().equalsIgnoreCase("f")) .map(PyStringElementTree::trimmedQuotesValue) .flatMap(UnusedLocalVariableCheck::extractInterpolations) .collect(Collectors.toSet()); }
Source:
<code><START> public void testProcessMessage() throws Exception { <END> RMQTestSource source = new RMQTestSource(); source.open(config); RMQDeserializationSchema.RMQCollector collector = Mockito.mock(RMQDeserializationSchema.RMQCollector.class); source.processMessage(source.mockedDelivery, collector); Mockito.verify(collector, Mockito.times(1)).collect("test"); Mockito.verify(collector, Mockito.times(1)).setMessageIdentifiers("1", messageId); source = new RMQTestSource(new CustomDeserializationSchema()); source.open(config); List<String> expectedOutput = new ArrayList<>(1); expectedOutput.add("I Love Turtles"); expectedOutput.add("Brush your teeth"); collector = Mockito.mock(RMQDeserializationSchema.RMQCollector.class); source.processMessage(source.mockedDelivery, collector); Mockito.verify(collector, Mockito.times(1)).collect(Mockito.eq(expectedOutput)); Mockito.verify(collector, Mockito.times(1)).setMessageIdentifiers("1-MESSAGE_ID", messageId); }</code><technical_language>Please fix warnings in this test. a warnings raw types</technical_language>

Target:
public void testProcessMessage() throws Exception { RMQTestSource source = new RMQTestSource(); source.open(config); RMQDeserializationSchema.RMQCollector<String> collector = Mockito.mock(RMQDeserializationSchema.RMQCollector.class); source.processMessage(source.mockedDelivery, collector); Mockito.verify(collector, Mockito.times(1)).collect("test"); Mockito.verify(collector, Mockito.times(1)).setMessageIdentifiers("0", messageId); source = new RMQTestSource(new CustomDeserializationSchema()); source.open(config); collector = Mockito.mock(RMQDeserializationSchema.RMQCollector.class); source.processMessage(source.mockedDelivery, collector); Mockito.verify(collector, Mockito.times(1)).collect(Mockito.eq("I Love Turtles")); Mockito.verify(collector, Mockito.times(1)).collect(Mockito.eq("Brush your teeth")); Mockito.verify(collector, Mockito.times(1)).setMessageIdentifiers("1", messageId - 1); Mockito.verify(collector, Mockito.times(1)).setMessageIdentifiers("2-MESSAGE_ID", messageId); }
Source:
<code>public void addRuleConfig (RuleConfig rc) { <START> this.ruleConfigs.put(rc.getKey(), rc); <END> }</code><technical_language>add new rule config file? (Parse put ruleConfigs in case,)</technical_language>

Target:
public void addRuleConfig (RuleConfig rc) { this.ruleConfigs.put(rc.getKey(), rc); if (! this.getConfig().containsKey(rc.getKey())) { this.getConfig().setProperty(rc.getKey(), rc.getValue()); } }
Source:
<code>protected String <START> getAdbPath() <END> { String adb = GlobalConfiguration.getDeviceManagerInstance().getAdbPath(); String[] getAdbPathCmd = new String[] {"which", adb}; CommandResult res = getRunUtil().runTimedCmd(CMD_TIME_OUT, getAdbPathCmd); return res.getStdout().trim(); }</code><technical_language>I check CL of bundle tool, read $PATH if --adb is specified. This means, pass adb if explicitly in TF. check via: String adb = GlobalConfiguration.getDeviceManagerInstance().getAdbPath(); if(!new File(adb).exists()) { return null } return adb; if return null, pass --adb</technical_language>

Target:
protected String getAdbPath() { String adbPath = GlobalConfiguration.getDeviceManagerInstance().getAdbPath(); if (!new File(adbPath).exists()) { return null; } return adbPath; }