auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private Number getImpact() { Score<?> zero = getParentConstraintVerifier().getConstraintStreamScoreDirectorFactory() .getScoreDefinition() .getZeroScore(); if (constraintMatchTotalMap.isEmpty()) { return zero.toLevelNumbers()[0]; } Score<?> totalMatchWeightedScore = constraintMatchTotalMap.values().stream() <START> .map(s -> s.getScore().divide(s.getConstraintWeight())) <END> .reduce(zero, Score::add); List<Number> matchWeightsFound = Arrays.stream(totalMatchWeightedScore.toLevelNumbers()) .distinct() .collect(Collectors.toList()); if (matchWeightsFound.size() != 1) { throw new IllegalStateException("Programming error: only one match weight should have been found (" + matchWeightsFound + ")."); } return matchWeightsFound.get(0); }</code><technical_language>s is a ConstraintMatchTotal variable name a bit arbitrary. Is a mistake</technical_language>

Target:
private Number getImpact() { ScoreDefinition scoreDefinition = getParentConstraintVerifier().getConstraintStreamScoreDirectorFactory() .getScoreDefinition(); Score zeroScore = scoreDefinition.getZeroScore(); Number zero = zeroScore.toLevelNumbers()[0]; if (constraintMatchTotalMap.isEmpty()) { return zero; } Score totalMatchWeightedScore = constraintMatchTotalMap.values().stream() .map(matchScore -> scoreDefinition.divideBySanitizedDivisor(matchScore.getScore(), matchScore.getConstraintWeight())) .reduce(zeroScore, Score::add); List<Number> matchWeightsFound = Arrays.stream(totalMatchWeightedScore.toLevelNumbers()) .distinct() .filter(matchWeight -> !Objects.equals(matchWeight, zero)) .collect(Collectors.toList()); if (matchWeightsFound.isEmpty()) { return 0; } else if (matchWeightsFound.size() != 1) { throw new IllegalStateException("Impossible state: expecting at most one match weight," + " but got matchWeightsFound (" + matchWeightsFound + ") instead."); } return matchWeightsFound.get(0); }
Source:
<code>public void testCyclicReferenceWithGroup() { try { new FormParseInit("/xform_tests/group_cyclic_reference.xml"); } catch (XFormParseException e) { String detailMessage = e.getMessage(); assert detailMessage.contains("Shortest Cycle"); int newlineCount = detailMessage.length() - detailMessage.replace("\n", "").length(); <START> assert newlineCount == 3; <END> return; } fail("Cyclical reference did not throw XFormParseException"); }</code><technical_language>this syntax in tests before; result in sort of test failure error message Assert.assertEquals(expected, actual)</technical_language>

Target:
public void testCyclicReferenceWithGroup() { try { new FormParseInit("/xform_tests/group_cyclic_reference.xml"); } catch (XFormParseException e) { String detailMessage = e.getMessage(); assertTrue(detailMessage.contains("Shortest Cycle")); int newlineCount = detailMessage.length() - detailMessage.replace("\n", "").length(); assertTrue(newlineCount == 3); return; } fail("Cyclical reference did not throw XFormParseException"); }
Source:
<code>public ShowProgress() { <START> start = last = System.nanoTime(); <END> }</code><technical_language>rename start startNs, lastNs</technical_language>

Target:
public ShowProgress() { startNs = lastNs = System.nanoTime(); }
Source:
<code>public void seek( long pos ) throws IOException { long newPageId = pageId( pos ); int newOffset = pageOffset( pos ); if ( isEOF( newPageId, newOffset ) ) { throw newEOFException( String.format( "seek EOF check failed for { pos: %d, pageId: %d, offsetInPage: %d }", pos, <START> newPageId, newOffset ) ); <END> } currentPageId = newPageId; currentPageOffset = newOffset; }</code><technical_language>exceptions, try extracting of exception construction a separate method. For instance in this case extract a newSeekEofException( pos, newPageId, newOffset ). reduce amount of bytecode in method, give JIT inliner more material work with</technical_language>

Target:
public void seek( long pos ) throws IOException { long newPageId = pageId( pos ); int newOffset = pageOffset( pos ); if ( isEOF( newPageId, newOffset ) ) { throw newSeekEOFException( pos, newPageId, newOffset ); } currentPageId = newPageId; currentPageOffset = newOffset; }
Source:
<code>private void removeCache(final String alias, final boolean removeFromConfig) { statusTransitioner.checkAvailable(); final CacheHolder cacheHolder = caches.remove(alias); if(cacheHolder != null) { <START> final Cache<?, ?> ehcache = cacheHolder.retrieve(cacheHolder.keyType, cacheHolder.valueType); <END> if(!statusTransitioner.isTransitioning()) { for (CacheManagerListener listener : listeners) { listener.cacheRemoved(alias, ehcache); } } closeCache(alias, ehcache); if (removeFromConfig) { configuration.removeCacheConfiguration(alias); } this.getLogger().info("Cache '{}' is removed from {}.", alias, simpleName); } }</code><technical_language>InternalCache clean a lot of casts</technical_language>

Target:
private void removeCache(final String alias, final boolean removeFromConfig) { statusTransitioner.checkAvailable(); final CacheHolder cacheHolder = caches.remove(alias); if(cacheHolder != null) { final InternalCache<?, ?> ehcache = cacheHolder.retrieve(cacheHolder.keyType, cacheHolder.valueType); if(!statusTransitioner.isTransitioning()) { for (CacheManagerListener listener : listeners) { listener.cacheRemoved(alias, ehcache); } } closeCache(alias, ehcache); if (removeFromConfig) { configuration.removeCacheConfiguration(alias); } this.getLogger().info("Cache '{}' is removed from {}.", alias, simpleName); } }
Source:
<code>public static String inflateMessage(byte[] data) throws SAMLException { try{ byte[] out = data; int length = data.length; try { Inflater inflater = new Inflater(true); inflater.setInput(data); byte[] xmlMessageBytes = new byte[MAX_INFLATED_SIZE]; int inflatedLength = inflater.inflate(xmlMessageBytes); if (!inflater.finished()) { throw new SAMLException("Out of space allocated for inflated data ("+(MAX_INFLATED_SIZE/1000)+"kb)"); } inflater.end(); out = xmlMessageBytes; length = inflatedLength; } catch (DataFormatException e) { <START> log.warn("inflate SAML message failed - Invalid data format", e); <END> } return new String(out,0,length, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new SAMLException("Data is not in valid encoding format", e); } }</code><technical_language>Is worth quoting a URL here? message start a leading cap</technical_language>

Target:
public static String inflateMessage(byte[] data) throws SAMLException { try{ byte[] out = data; int length = data.length; try { Inflater inflater = new Inflater(true); inflater.setInput(data); byte[] xmlMessageBytes = new byte[MAX_INFLATED_SIZE]; int inflatedLength = inflater.inflate(xmlMessageBytes); if (!inflater.finished()) { throw new SAMLException("Out of space allocated for inflated data ("+(MAX_INFLATED_SIZE/1000)+"kb)"); } inflater.end(); out = xmlMessageBytes; length = inflatedLength; } catch (DataFormatException e) { log.debug("Inflate SAML message failed - Invalid data format", e); } return new String(out,0,length, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new SAMLException("Data is not in valid encoding format", e); } }
Source:
<code>public Response getPageData(@Context HttpHeaders headers, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language, @PathParam("sitemapname") @ApiParam(value = "sitemap name") String sitemapname, @PathParam("pageid") @ApiParam(value = "page id") String pageId, @QueryParam("subscriptionid") @ApiParam(value = "subscriptionid", required = false) String subscriptionId) { final Locale locale = LocaleUtil.getLocale(language); logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath()); if (subscriptionId != null) { try { subscriptions.setPageId(subscriptionId, sitemapname, pageId); } catch (IllegalArgumentException e) { return JSONResponse.createErrorResponse(Response.Status.BAD_REQUEST, e.getMessage()); } } boolean timeout = false; if (headers.getRequestHeader("X-Atmosphere-Transport") != null) { timeout = blockUnlessChangeOccurs(sitemapname, pageId); } PageDTO responseObject = getPageBean(sitemapname, pageId, uriInfo.getBaseUriBuilder().build(), locale); <START> responseObject.timeout = timeout; <END> return Response.ok(responseObject).build(); }</code><technical_language>Imho cleaner add timeout a new parameter getPageBean - this safe is a a private method</technical_language>

Target:
public Response getPageData(@Context HttpHeaders headers, @HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language, @PathParam("sitemapname") @ApiParam(value = "sitemap name") String sitemapname, @PathParam("pageid") @ApiParam(value = "page id") String pageId, @QueryParam("subscriptionid") @ApiParam(value = "subscriptionid", required = false) String subscriptionId) { final Locale locale = LocaleUtil.getLocale(language); logger.debug("Received HTTP GET request at '{}'", uriInfo.getPath()); if (subscriptionId != null) { try { subscriptions.setPageId(subscriptionId, sitemapname, pageId); } catch (IllegalArgumentException e) { return JSONResponse.createErrorResponse(Response.Status.BAD_REQUEST, e.getMessage()); } } boolean timeout = false; if (headers.getRequestHeader("X-Atmosphere-Transport") != null) { timeout = blockUnlessChangeOccurs(sitemapname, pageId); } PageDTO responseObject = getPageBean(sitemapname, pageId, uriInfo.getBaseUriBuilder().build(), locale, timeout); return Response.ok(responseObject).build(); }
Source:
<code>public Object caseViewpoint(Viewpoint object) { DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription(); diagramDescription.setDefaultLayer(DescriptionFactory.eINSTANCE.createLayer()); <START> newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATIONS, diagramDescription)); <END> newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATIONS, DescriptionFactory.eINSTANCE.createDiagramImportDescription())); newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATION_EXTENSIONS, DescriptionFactory.eINSTANCE.createDiagramExtensionDescription())); return null; }</code><technical_language>configure layer name in factory. org.eclipse.sirius.diagram.description.impl.DescriptionFactoryImpl.createLayer()</technical_language>

Target:
public Object caseViewpoint(Viewpoint object) { DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription(); Layer layer = DescriptionFactory.eINSTANCE.createLayer(); layer.setName("Default"); diagramDescription.setDefaultLayer(layer); newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATIONS, diagramDescription)); newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATIONS, DescriptionFactory.eINSTANCE.createDiagramImportDescription())); newChildDescriptors.add(createChildParameter(DescriptionPackage.Literals.VIEWPOINT__OWNED_REPRESENTATION_EXTENSIONS, DescriptionFactory.eINSTANCE.createDiagramExtensionDescription())); return null; }
Source:
<code>public void testSetBrightness() { <START> Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, 0, UserHandle.myUserId()); <END> testSetBrightnessWithValue(TEST_BRIGHTNESS_1); testSetBrightnessWithValue(TEST_BRIGHTNESS_2); }</code><technical_language>set auto brightness via: mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT, Settings.System.SCREEN_BRIGHTNESS_MODE, 0);</technical_language>

Target:
public void testSetBrightness() { mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT, Settings.System.SCREEN_BRIGHTNESS_MODE, "0"); testSetBrightnessWithValue(TEST_BRIGHTNESS_1); testSetBrightnessWithValue(TEST_BRIGHTNESS_2); }
Source:
<code>public TaskBatchExecutionListenerFactoryBean taskBatchExecutionListener(TaskExplorer taskExplorer) { <START> TaskConfigurer taskConfigurer = context.getBean(TaskConfigurer.class); <END> if(taskConfigurer.getTaskDataSource() != null) { return new TaskBatchExecutionListenerFactoryBean( taskConfigurer.getTaskDataSource(), taskExplorer); } else { return new TaskBatchExecutionListenerFactoryBean(null, taskExplorer); } }</code><technical_language>defensive confirm is a TaskConfigurer exists in place BeanFactory#getBean throws exception if there..</technical_language>

Target:
public TaskBatchExecutionListenerFactoryBean taskBatchExecutionListener(TaskExplorer taskExplorer) { TaskConfigurer taskConfigurer = null; if(!context.getBeansOfType(TaskConfigurer.class).isEmpty()) { taskConfigurer = context.getBean(TaskConfigurer.class); } if(taskConfigurer != null && taskConfigurer.getTaskDataSource() != null) { return new TaskBatchExecutionListenerFactoryBean( taskConfigurer.getTaskDataSource(), taskExplorer); } else { return new TaskBatchExecutionListenerFactoryBean(null, taskExplorer); } }
Source:
<code>long estimateSize(Path directoryPath) { <START> final AtomicLong size = new AtomicLong(0); <END> try { Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { size.addAndGet(attrs.size()); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { log.error("skipped: {}", file, exc); return FileVisitResult.CONTINUE; } }); return size.get(); } catch (IOException ioe) { throw new IllegalStateException(ioe); } }</code><technical_language>AtomicLong</technical_language>

Target:
static long estimateSize(Path directoryPath) { final AtomicLong size = new AtomicLong(0); try { Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { size.addAndGet(attrs.size()); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { log.error("skipped: {}", file, exc); return FileVisitResult.CONTINUE; } }); return size.get(); } catch (IOException ioe) { throw new IllegalStateException(ioe); } }
Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.log_activity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState != null) { <START> syncthingLog = savedInstanceState.getBoolean("syncthingLog"); <END> } mLog = (TextView) findViewById(R.id.log); mScrollView = (ScrollView) findViewById(R.id.scroller); updateLog(); }</code><technical_language>need update text of menu button here</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.log_activity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState != null) { mSyncthingLog = savedInstanceState.getBoolean("syncthingLog"); invalidateOptionsMenu(); } mLog = (TextView) findViewById(R.id.log); mScrollView = (ScrollView) findViewById(R.id.scroller); updateLog(); }
Source:
<code>public void setNearClip(float nearClipIn) { <START> nearClip = nearClipIn; <END> }</code><technical_language>write: this.nearClip = nearClip in method. get a checkstyle warning it</technical_language>

Target:
public void setNearClip(float nearClipIn) { this.nearClip = nearClipIn; }
Source:
<code>static OperationDefinition getOperationDefinition(String name, AttributeDefinition ... additional) { AttributeDefinition[] atrs = new AttributeDefinition[2 + additional.length]; atrs[0] = SERVER; atrs[1] = BLOCKING; System.arraycopy(additional, 0, atrs, 2, additional.length); return new SimpleOperationDefinitionBuilder(name, HostResolver.getResolver("host.server")) <START> .setParameters(atrs) <END> .setReplyType(ModelType.STRING) .setRuntimeOnly() .withFlag(OperationEntry.Flag.HOST_CONTROLLER_ONLY) .build(); }</code><technical_language>call setParameters(additional).addParameter(SERVER).addParameter(BLOCKING) need copy array manually</technical_language>

Target:
static OperationDefinition getOperationDefinition(String name, AttributeDefinition... additional) { SimpleOperationDefinitionBuilder builder = new SimpleOperationDefinitionBuilder(name, HostResolver.getResolver("host.server")) .setParameters(SERVER, BLOCKING) .setReplyType(ModelType.STRING) .setRuntimeOnly() .withFlag(OperationEntry.Flag.HOST_CONTROLLER_ONLY); for (AttributeDefinition param : additional) { builder.addParameter(param); } return builder.build(); }
Source:
<code>public static DBI create(ConnectionFactory connectionFactory) { DBI dbi = new DBI(connectionFactory); <START> dbi.installPlugins(); <END> return dbi; }</code><technical_language>This is I object to. a fan of Spring-style magic--by I stuff a JAR is classpath (or next year, in Java 9 module graph). JDBI done a great job of keeping magic "visible." I force users a single call DBI.installPlugins() ServiceLoader stuff is opt-in</technical_language>

Target:
public static DBI create(ConnectionFactory connectionFactory) { return new DBI(connectionFactory); }
Source:
<code>public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { String action = null; <START> Console.Type type = (Console.Type) postParams.get("type"); <END> switch (type) { case NOVNC: case XVPVNC: action = "os-getVNCConsole"; break; case SPICE_HTML5: action = "os-getSPICEConsole"; break; case RDP_HTML5: action = "os-getRDPConsole"; break; default: throw new IllegalArgumentException("Invalid type: " + type); } return bindToRequest(request, (Object) ImmutableMap.of(action, ImmutableSortedMap.copyOf(postParams))); }</code><technical_language>Is this needed? fromValue in enumType in conjunction toString ensure GSON mapping automatically <LINK_0> I missing something? > > Ok, this is in getConsole. sense</technical_language>

Target:
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { String action; Console.Type type = (Console.Type) postParams.get("type"); switch (type) { case NOVNC: case XVPVNC: action = "os-getVNCConsole"; break; case SPICE_HTML5: action = "os-getSPICEConsole"; break; case RDP_HTML5: action = "os-getRDPConsole"; break; default: throw new IllegalArgumentException("Invalid type: " + type); } return bindToRequest(request, ImmutableMap.of(action, ImmutableSortedMap.copyOf(postParams))); }
Source:
<code>public final void test1() throws InterruptedException { <START> Thread.sleep(5); <END> }</code><technical_language>Please follow strategy employed in ParallelExecutionIntegrationTests tests faster</technical_language>

Target:
public final void test1() { }
Source:
<code>public void jobScriptWithJobTypeTest() { <START> System.out.println("JobScriptWithJobTypeTest"); <END> }</code><technical_language>Please remove system.out.println add assertion</technical_language>

Target:
public void jobScriptWithJobTypeTest() { BlockUtils.sleep(1000L); assertTrue(regCenter.isExisted("/" + scriptJobName + "/sharding")); }
Source:
<code>public IndexedFastaSequenceFile(final Path path, final FastaSequenceIndex index) { super(path, index); try (final InputStream stream = IOUtil.maybeBufferInputStream(Files.newInputStream(path))) { if (BlockCompressedInputStream.isValidFile(stream)) { <START> throw new SAMException("Indexed block-compressed FASTA file cannot be handle: " + path); <END> } this.channel = Files.newByteChannel(path); } catch (IOException e) { throw new SAMException("FASTA file should be readable but is not: " + path, e); } }</code><technical_language>typo handle -> handled</technical_language>

Target:
public IndexedFastaSequenceFile(final Path path, final FastaSequenceIndex index) { super(path, index); try (final InputStream stream = IOUtil.maybeBufferInputStream(Files.newInputStream(path))) { if (BlockCompressedInputStream.isValidFile(stream)) { throw new SAMException("Indexed block-compressed FASTA file cannot be handled: " + path); } this.channel = Files.newByteChannel(path); } catch (IOException e) { throw new SAMException("FASTA file should be readable but is not: " + path, e); } }
Source:
<code>public void testUnmarshallSubprocessLevelEventWithEdgesEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateSignalEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_WITH_OUTGOING_EDGE_SUBPROCESS_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); <START> assertSignalEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, NON_CANCELLING, ""); <END> assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); }</code><technical_language>suggestion assertSignalEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, NON_CANCELLING, EMPTY_VALUE);</technical_language>

Target:
public void testUnmarshallSubprocessLevelEventWithEdgesEmptyProperties() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(marshaller, BPMN_CATCHING_INTERMEDIATE_EVENT_FILE_PATH); assertDiagram(diagram, AMOUNT_OF_NODES_IN_DIAGRAM); IntermediateSignalEventCatching emptySubprocessEvent = getCatchingIntermediateNodeById(diagram, EMPTY_WITH_OUTGOING_EDGE_SUBPROCESS_LEVEL_EVENT_ID, HAS_NO_INCOME_EDGE, HAS_OUTGOING_EDGE); assertGeneralSet(emptySubprocessEvent.getGeneral(), EMPTY_VALUE, EMPTY_VALUE); assertSignalEventExecutionSet(emptySubprocessEvent.getExecutionSet(), EMPTY_VALUE, NON_CANCELLING, EMPTY_VALUE); assertDataIOSet(emptySubprocessEvent.getDataIOSet(), EMPTY_VALUE); }
Source:
<code>public void testRebaseWithUnstagedMasterChange() throws Exception { writeTrashFile(FILE1, "file1"); git.add().addFilepattern(FILE1).call(); RevCommit commit = git.commit().setMessage("commit1").call(); createBranch(commit, "refs/heads/topic"); checkoutBranch("refs/heads/topic"); writeTrashFile("file2", "file2"); git.add().addFilepattern("file2").call(); git.commit().setMessage("commit2").call(); checkoutBranch("refs/heads/master"); writeTrashFile(FILE1, "modified file1"); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("commit3").call(); checkoutBranch("refs/heads/topic"); writeTrashFile(FILE1, "unstaged modified file1"); RebaseResult result = git.rebase().setUpstream("refs/heads/master") .call(); assertEquals(result.getStatus(), Status.CONFLICTS); assertEquals(result.getConflicts().size(), 1); <START> assertEquals(result.getConflicts().get(0), FILE1); <END> }</code><technical_language>assertEquals(excpected, actual)</technical_language>

Target:
public void testRebaseWithUnstagedMasterChange() throws Exception { writeTrashFile(FILE1, "file1"); git.add().addFilepattern(FILE1).call(); RevCommit commit = git.commit().setMessage("commit1").call(); createBranch(commit, "refs/heads/topic"); checkoutBranch("refs/heads/topic"); writeTrashFile("file2", "file2"); git.add().addFilepattern("file2").call(); git.commit().setMessage("commit2").call(); checkoutBranch("refs/heads/master"); writeTrashFile(FILE1, "modified file1"); git.add().addFilepattern(FILE1).call(); git.commit().setMessage("commit3").call(); checkoutBranch("refs/heads/topic"); writeTrashFile(FILE1, "unstaged modified file1"); RebaseResult result = git.rebase().setUpstream("refs/heads/master") .call(); assertEquals(Status.CONFLICTS, result.getStatus()); assertEquals(1, result.getConflicts().size()); assertEquals(FILE1, result.getConflicts().get(0)); }
Source:
<code>protected boolean canDoAction() { boolean returnValue = true; if (getVm().getstatus() == VMStatus.Up) { setVdsId(getVm().getrun_on_vds().getValue()); returnValue = isHotPlugSupported() && isOSSupportingHotPlug(); vmDevice = vmDeviceDao.get(new VmDeviceId(getParameters().getNicId(), getParameters().getVmId())); <START> } <END> if (vmDevice == null) { returnValue = false; addCanDoActionMessage(VdcBllMessages.VM_INTERFACE_NOT_EXIST); } return returnValue; }</code><technical_language>returnValue && vmDevice == null</technical_language>

Target:
protected boolean canDoAction() { boolean returnValue = true; if (getVm().getstatus() == VMStatus.Up) { setVdsId(getVm().getrun_on_vds().getValue()); vmDevice = getVmDeviceDao().get(new VmDeviceId(getParameters().getNicId(), getParameters().getVmId())); if (vmDevice == null) { returnValue = false; addCanDoActionMessage(VdcBllMessages.VM_INTERFACE_NOT_EXIST); } else { returnValue = isHotPlugSupported() && isOSSupportingHotPlug(); } } return returnValue; }
Source:
<code>private void updateCopyAndMoveCommandAvailability(List<Disk> disks) { <START> boolean isMoveAllowed = true; <END> boolean isCopyAllowed = true; if (disks == null || disks.isEmpty() || disks.get(0).getDiskStorageType() != DiskStorageType.IMAGE) { disableMoveAndCopyCommands(); return; } Guid datacenterId = ((DiskImage) disks.get(0)).getStoragePoolId(); boolean foundTemplateDisk = false; boolean foundVmDisk = false; boolean foundUnattachedDisk = false; for (Disk disk : disks) { if ((!isCopyAllowed && !isMoveAllowed) || disk.getDiskStorageType() != DiskStorageType.IMAGE) { disableMoveAndCopyCommands(); return; } DiskImage diskImage = (DiskImage) disk; if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || diskImage.isOvfStore()) { disableMoveAndCopyCommands(); return; } VmEntityType vmEntityType = disk.getVmEntityType(); if (vmEntityType == null) { foundUnattachedDisk = true; } else if (vmEntityType.isTemplateType()) { foundTemplateDisk = true; } else if (vmEntityType.isVmType()) { foundVmDisk = true; } if (foundTemplateDisk && (foundUnattachedDisk || foundVmDisk)) { isCopyAllowed = false; } if (vmEntityType != null && vmEntityType.isTemplateType()) { isMoveAllowed = false; } } getCopyCommand().setIsExecutionAllowed(isCopyAllowed); getMoveCommand().setIsExecutionAllowed(isMoveAllowed); }</code><technical_language>This change is redundant say.</technical_language>

Target:
private void updateCopyAndMoveCommandAvailability(List<Disk> disks) { boolean isCopyAllowed = true; boolean isMoveAllowed = true; if (disks == null || disks.isEmpty() || disks.get(0).getDiskStorageType() != DiskStorageType.IMAGE) { disableMoveAndCopyCommands(); return; } Guid datacenterId = ((DiskImage) disks.get(0)).getStoragePoolId(); boolean foundTemplateDisk = false; boolean foundVmDisk = false; boolean foundUnattachedDisk = false; for (Disk disk : disks) { if ((!isCopyAllowed && !isMoveAllowed) || disk.getDiskStorageType() != DiskStorageType.IMAGE) { disableMoveAndCopyCommands(); return; } DiskImage diskImage = (DiskImage) disk; if (diskImage.getImageStatus() != ImageStatus.OK || !datacenterId.equals(diskImage.getStoragePoolId()) || diskImage.isOvfStore()) { disableMoveAndCopyCommands(); return; } VmEntityType vmEntityType = disk.getVmEntityType(); if (vmEntityType == null) { foundUnattachedDisk = true; } else if (vmEntityType.isTemplateType()) { foundTemplateDisk = true; } else if (vmEntityType.isVmType()) { foundVmDisk = true; } if (foundTemplateDisk && (foundUnattachedDisk || foundVmDisk)) { isCopyAllowed = false; } if (vmEntityType != null && vmEntityType.isTemplateType()) { isMoveAllowed = false; } } getCopyCommand().setIsExecutionAllowed(isCopyAllowed); getMoveCommand().setIsExecutionAllowed(isMoveAllowed); }
Source:
<code>public LabelCanvas draw(Driver driver, Barcodable barcodable) { LabelCanvas label = driver.start(14, 4.666); <START> label.multilineText(10.7, 2.3, 0.5, 8, 2, Stream.of(new Pair<>(FontStyle.REGULAR, barcodable.getAlias()))); <END> label.multilineText(1, 1.375, .8, 18, 2, Stream.of( new Pair<>(FontStyle.BOLD, barcodable.getAlias()))); label.multilineText(1, 3.375, .8, 12, 2, Stream.of( new Pair<>(FontStyle.REGULAR, LimsUtils.formatDate(barcodable.getBarcodeDate())), new Pair<>(FontStyle.REGULAR, unescapeHtml(barcodable.getBarcodeExtraInfo())))); label.barcode2d(6.78, 4, 0.1, barcodable.getAlias()); return label; }</code><technical_language>This prints PCSI_088 0_Pa_P... Is intended? I expected breaking 9th char friendlier, leading PCSI_0880 _Pa_P..</technical_language>

Target:
public LabelCanvas draw(Driver driver, Barcodable barcodable) { LabelCanvas label = driver.start(8.3, 7.7); label.textClipped(2.4, 7.125, .8, 15, barcodable.getAlias()); if (barcodable.getBarcodeDate() != null) { label.text(0.5, 7.125, .8, LimsUtils.formatDate(barcodable.getBarcodeDate())); } label.barcode2d(1.75, 1.75, 0.125, getBarcode(barcodable)); label.textClipped(0.666, 4.666, .8, 15, unescapeHtml(barcodable.getBarcodeExtraInfo())); return label; }
Source:
<code>private void retrievePreferences() { this.preference = "CHOICE_BEHAVIOR"; this.type = null; IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_ASYNCH_EDGE.getSemanticHint())) { this.preference = store.getString(CustomMessages.PREF_EXECUTION_SPECIFICATION_ASYNC_MSG); } if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_SYNCH_EDGE.getSemanticHint())) { this.preference = store.getString(CustomMessages.PREF_EXECUTION_SPECIFICATION_SYNC_MSG); } <START> if (preference == "CHOICE_BEHAVIOR") { <END> this.type = UMLDIElementTypes.BEHAVIOR_EXECUTION_SPECIFICATION_SHAPE; } if (preference == "CHOICE_ACTION") { this.type = UMLDIElementTypes.ACTION_EXECUTION_SPECIFICATION_SHAPE; } }</code><technical_language>equals "==" for string this is a bad friend in java</technical_language>

Target:
private void retrievePreferences() { this.preference = "CHOICE_BEHAVIOR"; this.type = null; IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_ASYNCH_EDGE.getSemanticHint())) { this.preference = store.getString(CustomMessages.PREF_EXECUTION_SPECIFICATION_ASYNC_MSG); } if (request.getConnectionViewAndElementDescriptor().getSemanticHint().equals(UMLDIElementTypes.MESSAGE_SYNCH_EDGE.getSemanticHint())) { this.preference = store.getString(CustomMessages.PREF_EXECUTION_SPECIFICATION_SYNC_MSG); } if ("CHOICE_BEHAVIOR".equals(preference)) { this.type = UMLDIElementTypes.BEHAVIOR_EXECUTION_SPECIFICATION_SHAPE; } if ("CHOICE_ACTION".equals(preference)) { this.type = UMLDIElementTypes.ACTION_EXECUTION_SPECIFICATION_SHAPE; } }
Source:
<code>private SearchResult parseToSearchResult(@Nonnull final IMAPResponse[] ir) throws ImapAsyncClientException { if (ir.length < 1) { throw new ImapAsyncClientException(FailureType.INVALID_INPUT); } final Response taggedResponse = ir[ir.length - 1]; if (!taggedResponse.isOK()) { throw new ImapAsyncClientException(FailureType.INVALID_INPUT); } final List<Long> v = new ArrayList<Long>(); Long modSeq = null; long num; for (final IMAPResponse sr : ir) { if (sr.keyEquals("SEARCH")) { while ((num = sr.readLong()) != -1) { <START> v.add(Long.valueOf(num)); <END> } if (sr.readByte() == '(') { final String s = sr.readAtom(); if (s.equalsIgnoreCase("MODSEQ")) { modSeq = sr.readLong(); } } } } return new SearchResult(v, modSeq); }</code><technical_language>num is long, need do Long.valueOf</technical_language>

Target:
private SearchResult parseToSearchResult(@Nonnull final IMAPResponse[] ir) throws ImapAsyncClientException { if (ir.length < 1) { throw new ImapAsyncClientException(FailureType.INVALID_INPUT); } final Response taggedResponse = ir[ir.length - 1]; if (!taggedResponse.isOK()) { throw new ImapAsyncClientException(FailureType.INVALID_INPUT); } final List<Long> v = new ArrayList<Long>(); Long modSeq = null; long num; for (final IMAPResponse sr : ir) { if (sr.keyEquals("SEARCH")) { while ((num = sr.readLong()) != -1) { v.add(num); } if (sr.readByte() == '(') { final String s = sr.readAtom(); if (s.equalsIgnoreCase("MODSEQ")) { modSeq = sr.readLong(); } } } } return new SearchResult(v, modSeq); }
Source:
<code>public EngineDialog(Shell parentShell) { super(parentShell, ENGINE_DIALOG_HEADER, null, "", INFORMATION, new String[] {webkitOption, xulrunnerOption}, 0); <START> message = "Do you prefer to have good JSF support (use xulrunner) or HTML5 support (use webkit)?"; END> }</code><technical_language>Move message NLS bundle. text... discuss @maxandersen</technical_language>

Target:
public EngineDialog(Shell parentShell) { super(parentShell, ENGINE_DIALOG_HEADER, null, "", INFORMATION, new String[] {webkitOption, xulrunnerOption}, webkitIsUsed ? 0 : 1); message = Messages.EngineDialog_MESSAGE; }
Source:
<code>@Override public String toString() { List<Object> extra = effectiveExtra(); StringBuilder result = new StringBuilder(); result.append(value.getClass().getSimpleName()).append('=').append(value); <START> result.setCharAt(0, Character.toLowerCase(result.charAt(0))); END> if (type != 3) { String flagsString = SamplingFlags.toString(value.flags); if (!flagsString.isEmpty()) result.append(", samplingFlags=").append(flagsString); } if (!extra.isEmpty()) result.append(", extra=").append(extra); return result.insert(0, "Extracted{").append('}').toString(); }</code><technical_language>extra line a bit simpler lowercase append 0's result.append("Extracted{") String valueClass = value.getClass().getSimpleName(); // Lowercase char of class name result.append(Character.toLowerCase(valueClass.charAt(0)); result.append(valueClass, 1, valueClass.length());</technical_language>

Target:
@Override public String toString() { List<Object> extra = effectiveExtra(); StringBuilder result = new StringBuilder("Extracted{"); String valueClass = value.getClass().getSimpleName(); result.append(Character.toLowerCase(valueClass.charAt(0))); result.append(valueClass, 1, valueClass.length()).append('=').append(value); if (type != 3) { String flagsString = SamplingFlags.toString(value.flags); if (!flagsString.isEmpty()) result.append(", samplingFlags=").append(flagsString); } if (!extra.isEmpty()) result.append(", extra=").append(extra); return result.append('}').toString(); }
Source:
<code><START> private static boolean paramsMatch(Class<?>[] types, Object[] params) { <END> if (params.length != types.length) { return false; } for (int i = 0; i < params.length; i++) { if (!types[i].isInstance(params[i])) { return false; } } return true; }</code><technical_language>I if this alogrithm works expected. JVM choose specific constructor, choose matching. This some trouble is hard detect. Assume String arguments get constructor's in this order: 1. MyClass(Object a, Object b) 2. MyClass(String a, String b) String is instance of Object choose constructor, JVM choose second. This fixed</technical_language>

Target:
private static boolean paramsMatch(Class<?>[] types, Object[] params) { if (params.length != types.length) { return false; } for (int i = 0; i < params.length; i++) { if (params[i] == null) { if (types[i].isPrimitive()) { return false; } } else if ((!types[i].isPrimitive() && !types[i].isInstance(params[i])) || (types[i].isPrimitive() && !types[i].equals(Primitives.primitiveTypeOf(params[i].getClass())))) { return false; } } return true; }
Source:
<code>public void setProperties(Map<String, String> map) throws Exception { synchronized (this) { configuration = Converter.cnv(PomConfiguration.class, map); if (configuration.name() == null) throw new IllegalArgumentException("Must get a name"); this.name = configuration.name(); if (configuration.pom() != null) { pomFiles = Strings.split(configuration.pom()) .stream() .map(part -> { File f = IO.getFile(part); return f.isFile() ? f.toURI() : URI.create(part); }) .collect(toList()); if (pomFiles.isEmpty()) { status("Pom is neither a file nor a revision " + configuration.pom()); } } else if (configuration.revision() != null) { revisions = Strings.split(configuration.revision()) .stream() .map(Revision::valueOf) .filter(Objects::nonNull) .collect(toList()); if (revisions.isEmpty()) { status("Revision is neither a file nor a revision " + configuration.revision()); } } else if (configuration.query() != null) { this.query = configuration.query(); this.queryUrl = configuration.queryUrl("<LINK_0>"); } else { status("Neither pom, revision nor query property are set"); } <START> inited = false; <END> } }</code><technical_language>need do this. setProperties is called</technical_language>

Target:
public void setProperties(Map<String, String> map) throws Exception { configuration = Converter.cnv(PomConfiguration.class, map); }
Source:
<code>public boolean serializeField( JsonSerializerInternal serializer, Object parent, FieldAccess fieldAccess, CharBuf builder) { Field field = fieldAccess.getField(); String name = field.getName(); boolean shouldManuallySerialize = <START> (name.equals("value") || name.equals("defaultValue")) <END> && field.getType().equals(String.class); if (!shouldManuallySerialize) { return false; } String fieldValue = null; try { fieldValue = (String) field.get(parent); } catch (IllegalAccessException e) { throw new UncheckedIllegalAccessException( "Access denied for field 'value' on FilterLeafNode", e); } if (fieldValue == null) { return false; } builder.addJsonFieldName(name); Integer i = Ints.tryParse(fieldValue); if (i != null) { builder.addInt(i); return true; } Double d = Doubles.tryParse(fieldValue); if (d != null) { builder.addDouble(d); return true; } if (fieldValue.equalsIgnoreCase("true")) { builder.addBoolean(true); return true; } if (fieldValue.equalsIgnoreCase("false")) { builder.addBoolean(false); return true; } builder.addQuoted(fieldValue); return true; }</code><technical_language>name null? logic switched if so; "value".equals(name)</technical_language>

Target:
public boolean serializeField( JsonSerializerInternal serializer, Object parent, FieldAccess fieldAccess, CharBuf builder) { Field field = fieldAccess.getField(); String name = field.getName(); boolean shouldManuallySerialize = ("value".equals(name) || "defaultValue".equals(name)) && field.getType().equals(String.class); if (!shouldManuallySerialize) { LOGGER.trace("Special serialization is not needed for field '{}'", name); return false; } String fieldValue = null; try { fieldValue = (String) field.get(parent); } catch (IllegalAccessException e) { throw new UncheckedIllegalAccessException( "Access denied for field 'value' on FilterLeafNode", e); } if (fieldValue == null) { LOGGER.debug("Field '{}' held a null value, no special serialization needed", name); return false; } builder.addJsonFieldName(name); Integer i = Ints.tryParse(fieldValue); if (i != null) { LOGGER.debug("Found Integer '{}' on field '{}', serializing appropriately", i, name); builder.addInt(i); return true; } Double d = Doubles.tryParse(fieldValue); if (d != null) { LOGGER.debug("Found Double '{}' on field '{}', serializing appropriately", d, name); builder.addDouble(d); return true; } if (fieldValue.equalsIgnoreCase("true")) { LOGGER.debug("Found Boolean '{}' on field '{}', serializing appropriately", fieldValue, name); builder.addBoolean(true); return true; } if (fieldValue.equalsIgnoreCase("false")) { LOGGER.debug("Found Boolean '{}' on field '{}', serializing appropriately", fieldValue, name); builder.addBoolean(false); return true; } LOGGER.debug("Found String '{}' on field '{}', serializing appropriately", fieldValue, name); builder.addQuoted(fieldValue); return true; }
Source:
<code>public static Props fromJSONString(String json) { try { Map<String, String> obj = (Map<String, String>) JSONUtils.parseJSONFromString(json); Props props = new Props(null, obj); return props; } catch (IOException e) { logger.error("Encountered error during parsing project properties json."); <START> e.printStackTrace(); <END> return null; } }</code><technical_language>Log logger</technical_language>

Target:
public static Props fromJSONString(String json) { try { Map<String, String> obj = (Map<String, String>) JSONUtils.parseJSONFromString(json); Props props = new Props(null, obj); return props; } catch (IOException e) { logger.error("Encountered error during parsing project properties json. ", e); return null; } }
Source:
<code>public static void afterClass() throws InterruptedException, TimeoutException, IOException, OperationException { operations.removeIfExists(FORMATTER_ADDRESS); <START> administration.reloadIfRequired(); <END> operations.removeIfExists(FORMATTER_ADDRESS_TO_BE_REMOVED); administration.reloadIfRequired(); }</code><technical_language>consecutive reloads necessary reload end sufficient</technical_language>

Target:
public static void afterClass() throws InterruptedException, TimeoutException, IOException, OperationException { operations.removeIfExists(FORMATTER_ADDRESS); operations.removeIfExists(FORMATTER_ADDRESS_TO_BE_REMOVED); administration.reloadIfRequired(); }
Source:
<code>protected void filter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws Exception { <START> try { <END> response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin")); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me"); } catch (Exception e) { log.error("Specified Origin '{}' is not allowed: {}", request.getHeader("Origin"), e.getMessage(), e); } chain.doFilter(request, response); }</code><technical_language>Origin is checked, original ticket talks implementing CORS preflight is SPA frameworks angular, do OPTIONS request in case request continue filter chain needs respond CORS headers</technical_language>

Target:
protected void filter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws Exception { try { if (request.getHeader(ORIGIN) != null) { originRequestAuthorizer.assertAuthorized(request, response); boolean preFlight = isPreFlight(request); if (preFlight && !Strings.hasText(request.getHeader(ACCESS_CONTROL_REQUEST_METHOD))) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } response.setHeader(ACCESS_CONTROL_ALLOW_ORIGIN, request.getHeader(ORIGIN)); response.setHeader(ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); response.setHeader(ACCESS_CONTROL_ALLOW_METHODS, "POST, GET, OPTIONS, DELETE"); response.setHeader(ACCESS_CONTROL_MAX_AGE, "3600"); response.setHeader(ACCESS_CONTROL_ALLOW_HEADERS, "Content-Type, Accept, X-Requested-With, remember-me"); if (!preFlight) { chain.doFilter(request, response); } } } catch (RuntimeException e) { log.error("Specified Origin '{}' is not allowed: {}", request.getHeader("Origin"), e.getMessage(), e); response.setStatus(HttpServletResponse.SC_FORBIDDEN); } }
Source:
<code>public boolean equals( Object obj ) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ValueReference other = (ValueReference)obj; if (owningNodeUuid == null) { if (other.owningNodeUuid != null) return false; } else if (!owningNodeUuid.equals(other.owningNodeUuid)) return false; if (workspaceName == null) { if (other.workspaceName != null) return false; } else if (!workspaceName.equals(other.workspaceName)) return false; return true; <START> } <END></code><technical_language>I written this method this way: if ( this == obj ) return true; if ( obj instanceof ValueReference ) { ValueReference other = (ValueReference)obj; return ObjectUtil.isEqualsWithNulls(this.owningNodeUuid,that.owningNodeUuid) && ObjectUtil.isEqualsWithNulls(this.workspaceName,that.workspaceName); } return false; a shorter error prone (though get logic right here)</technical_language>

Target:
public boolean equals( Object obj ) { if (this == obj) return true; if (obj instanceof ValueReference) { ValueReference other = (ValueReference)obj; return ObjectUtil.isEqualWithNulls(this.owningNodeUuid, other.owningNodeUuid) && ObjectUtil.isEqualWithNulls(this.workspaceName, other.workspaceName); } return false; }
Source:
<code>private static C_Type createType(final String type, final boolean isArray, final ImmutableSet<String> enumNames) { final String ds3TypeName = StructHelper.getDs3TypeName(type); if (enumNames.contains(ds3TypeName)) { return new PrimitiveType(ds3TypeName, isArray); } switch (type) { case "java.lang.Boolean": case "boolean": return new PrimitiveType("ds3_bool", isArray); <START> case "java.lang.Double": <END> case "java.lang.Long": case "double": case "long": return new PrimitiveType("uint64_t", isArray); case "java.lang.Integer": case "int": return new PrimitiveType("int", isArray); case "java.lang.String": case "java.util.Date": case "java.util.UUID": return new FreeableType("ds3_str", isArray); default: return new FreeableType(StructHelper.getResponseTypeName(type), isArray); } }</code><technical_language>is a Double treated a uint64_t? this treated a float instead</technical_language>

Target:
private static C_Type createType(final String type, final boolean isArray, final ImmutableSet<String> enumNames) { final String ds3TypeName = StructHelper.getDs3TypeName(type); if (enumNames.contains(ds3TypeName)) { return new PrimitiveType(ds3TypeName, isArray); } switch (type) { case "java.lang.Boolean": case "boolean": return new PrimitiveType("ds3_bool", isArray); case "java.lang.Integer": case "int": return new PrimitiveType("int", isArray); case "java.lang.Long": case "long": return new PrimitiveType("uint64_t", isArray); case "java.lang.Double": case "double": return new PrimitiveType("float", isArray); case "java.lang.Object": case "java.lang.String": case "java.util.Date": case "java.util.UUID": return new FreeableType("ds3_str", isArray); default: return new FreeableType(StructHelper.getResponseTypeName(type), isArray); } }
Source:
<code>private long getCachedEndIndex(Path path) { Long endIndexForFile = endIndexMap.get(path); if (endIndexForFile == null) { try { final long bufferSectionSize = 1024; long bufferSectionEnd = path.getFileSystem(conf).getFileStatus(path).getLen(); long bufferSectionStart = Math.max(0, bufferSectionEnd - bufferSectionSize); <START> Queue<Long> lineEndBuffer = new ArrayDeque<Long>(headerCount + 1); <END> FSDataInputStream fis = path.getFileSystem(conf).open(path); fis.seek(bufferSectionStart); while (bufferSectionEnd > bufferSectionStart) { fis.seek(bufferSectionStart); long pos = fis.getPos(); while (pos < bufferSectionEnd) { fis.readLine(); pos = fis.getPos(); if (pos <= bufferSectionEnd) { if (lineEndBuffer.size() > footerCount) { lineEndBuffer.poll(); } lineEndBuffer.add(pos); } } if (lineEndBuffer.size() > footerCount) { break; } else { bufferSectionEnd = bufferSectionStart; bufferSectionStart = Math.max(0, bufferSectionEnd - bufferSectionSize); } } if (lineEndBuffer.size() > footerCount) { endIndexForFile = lineEndBuffer.poll(); } else { endIndexForFile = -1L; } } catch (IOException e) { endIndexForFile = -1L; } endIndexMap.put(path, endIndexForFile); } return endIndexForFile - 1; }</code><technical_language>footerCount + 1</technical_language>

Target:
private long getCachedEndIndex(Path path) throws IOException { Long endIndexForFile = endIndexMap.get(path); if (endIndexForFile == null) { final long bufferSectionSize = 5 * 1024; FileSystem fileSystem = path.getFileSystem(conf); long endOfFile = fileSystem.getFileStatus(path).getLen(); if (footerCount == 0) { endIndexForFile = endOfFile; } else { long bufferSectionEnd = endOfFile; long bufferSectionStart = Math.max(0, bufferSectionEnd - bufferSectionSize); LineBuffer buffer = new LineBuffer(footerCount + 1); FSDataInputStream fis = null; try { fis = fileSystem.open(path); while (bufferSectionEnd > bufferSectionStart) { fis.seek(bufferSectionStart); long pos = fis.getPos(); while (pos < bufferSectionEnd) { if (fis.readLine() == null) { break; } pos = fis.getPos(); buffer.consume(pos, bufferSectionEnd); } if (buffer.getRemainingLineCount() == 0) { break; } else { bufferSectionEnd = bufferSectionStart; bufferSectionStart = Math.max(0, bufferSectionEnd - bufferSectionSize); } } if (buffer.getRemainingLineCount() == 0) { endIndexForFile = buffer.getFirstLineStart() - 1; } else { endIndexForFile = Long.MIN_VALUE; } } finally { if (fis != null) { fis.close(); } } } endIndexMap.put(path, endIndexForFile); } return endIndexForFile; }