auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream)); try { String line; while ((line = reader.readLine()) != null) { if (line.length() != 0) { <START> GdbDebugOptions.trace(line); <END> final String finalLine = line; if (getMITracingStream() != null) { try { String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; while (message.length() > 100) { String partial = message.substring(0, 100) + "\\\n"; message = message.substring(100); getMITracingStream().write(partial.getBytes()); } getMITracingStream().write(message.getBytes()); } catch (IOException e) { setMITracingStream(null); } } processMIOutput(line); } } } catch (IOException e) { } catch (RejectedExecutionException e) { } try { fInputStream.close(); } catch (IOException e) { } }</code><technical_language>too, print timestamp all</technical_language>

Target:
public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(fInputStream)); try { String line; while ((line = reader.readLine()) != null) { if (line.length() != 0) { if(GdbDebugOptions.DEBUG) { GdbDebugOptions.trace(String.format( "%s %s %s", GdbPlugin.getDebugTime(), MI_TRACE_IDENTIFIER, line)); } final String finalLine = line; if (getMITracingStream() != null) { try { String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; while (message.length() > 100) { String partial = message.substring(0, 100) + "\\\n"; message = message.substring(100); getMITracingStream().write(partial.getBytes()); } getMITracingStream().write(message.getBytes()); } catch (IOException e) { setMITracingStream(null); } } processMIOutput(line); } } } catch (IOException e) { } catch (RejectedExecutionException e) { } try { fInputStream.close(); } catch (IOException e) { } }
Source:
<code>public PageFilePageSource( FSDataInputStream inputStream, long start, long splitLength, long fileSize, PagesSerde pagesSerde, List<HiveColumnHandle> columns) throws IOException { this.inputStream = requireNonNull(inputStream, "inputStream is null"); PageFileFooterReader pageFileFooterReader = new PageFileFooterReader(inputStream, fileSize); <START> long[] readStartAndLength = getReadStartAndLength( <END> start, splitLength, pageFileFooterReader.getStripeOffsets()); pageReader = new PageFilePageReader( readStartAndLength[0], readStartAndLength[1], inputStream, pagesSerde); int size = requireNonNull(columns, "columns is null").size(); this.hiveColumnIndexes = new int[size]; for (int columnIndex = 0; columnIndex < size; columnIndex++) { HiveColumnHandle column = columns.get(columnIndex); hiveColumnIndexes[columnIndex] = column.getHiveColumnIndex(); } }</code><technical_language>move getReadStartAndLength</technical_language>

Target:
public PageFilePageSource( FSDataInputStream inputStream, long start, long splitLength, long fileSize, PagesSerde pagesSerde, List<HiveColumnHandle> columns) throws IOException { this.inputStream = requireNonNull(inputStream, "inputStream is null"); PageFileFooterReader pageFileFooterReader = new PageFileFooterReader(inputStream, fileSize); OffsetAndLength readStartAndLength = getReadStartAndLength( start, splitLength, pageFileFooterReader.getFooterOffset(), pageFileFooterReader.getStripeOffsets()); pageReader = new PageFilePageReader( readStartAndLength.getOffset(), readStartAndLength.getLength(), inputStream, pagesSerde); int size = requireNonNull(columns, "columns is null").size(); this.hiveColumnIndexes = new int[size]; for (int columnIndex = 0; columnIndex < size; columnIndex++) { HiveColumnHandle column = columns.get(columnIndex); hiveColumnIndexes[columnIndex] = column.getHiveColumnIndex(); } }
Source:
<code>public void testSoftDeleteFeedbackSession() throws Exception { FeedbackSessionAttributes fs = getNewFeedbackSession(); fsDb.createEntity(fs); ______TS("Success: soft delete an existing feedback session"); fsDb.softDeleteFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId()); FeedbackSessionAttributes deleted = fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()); <START> <END> assertNull(deleted); ______TS("Success: restore soft deleted course"); fsDb.restoreDeletedFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId()); FeedbackSessionAttributes restored = fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()); assertFalse(restored.isSessionDeleted()); ______TS("null parameter"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.softDeleteFeedbackSession(null, null)); assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage()); }</code><technical_language>fsDb.getSoftDeletedFeedbackSession return null</technical_language>

Target:
public void testSoftDeleteFeedbackSession() throws Exception { FeedbackSessionAttributes fs = getNewFeedbackSession(); fsDb.createEntity(fs); ______TS("Success: soft delete an existing feedback session"); fsDb.softDeleteFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId()); assertNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName())); assertNotNull(fsDb.getSoftDeletedFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName())); ______TS("Success: restore soft deleted course"); fsDb.restoreDeletedFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId()); assertNull(fsDb.getSoftDeletedFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName())); assertNotNull(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName())); assertFalse(fsDb.getFeedbackSession(fs.getCourseId(), fs.getFeedbackSessionName()).isSessionDeleted()); ______TS("null parameter"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.softDeleteFeedbackSession(null, null)); assertEquals(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getMessage()); }
Source:
<code>public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(ProguardFileType.INSTANCE, <START> "pro"); <END> }</code><technical_language>a list of constants for extensions in SdkConstants. is in a separate project, for a constant called EXT_PRO = "pro" in of new classes in this file previous file</technical_language>

Target:
public void createFileTypes(@NotNull FileTypeConsumer consumer) { consumer.consume(ProguardFileType.INSTANCE, ProguardFileType.EXT_PRO); }
Source:
<code>public Option[] config() { String basedir = System.getProperty("basedir"); if (basedir == null) { basedir = Paths.get(".").toString(); } return new Option[] { carbonDistribution( <START> Paths.get(basedir, "..", "test-distribution", "target", "wso2carbon-kernel-test-5.2.0-SNAPSHOT.zip")) }; <END> }</code><technical_language>5.2.0-SNAPSHOT, this break test case in next release, Instead derive programmatically, based current version</technical_language>

Target:
public Option[] config() { String basedir = System.getProperty("basedir"); if (basedir == null) { basedir = Paths.get(".").toString(); } return new Option[] { carbonDistribution( Paths.get(basedir, "..", "test-distribution", "target", "wso2carbon-kernel-test-" + System.getProperty("carbon.kernel.version") + ".zip")) }; }
Source:
<code>private boolean saveAllExecutions() { <START> return Boolean.getBoolean("RECORDER_SAVE_ALL"); <END> }</code><technical_language>@jglick why. stick system properties configure [systemPropertyVariables](<LINK_0> easier set IDEs configure JVM arguments a test basis - configuring ssytem environment variables is harder</technical_language>

Target:
private boolean saveAllExecutions() { return ALWAYS.equals(RECORDER_OPTION); }
Source:
<code>public Response updateContentTypeFieldById(@PathParam("typeId") final String typeId, @PathParam("fieldId") final String fieldId, final String fieldJson, @Context final HttpServletRequest req) throws DotDataException, DotSecurityException { final InitDataObject initData = this.webResource.init(null, false, req, false, null); final User user = initData.getUser(); Response response = null; try { Field field = new JsonFieldTransformer(fieldJson).from(); if (!UtilMethods.isSet(field.id())) { response = ExceptionMapperUtil.createResponse(null, "Field 'id' should be set"); } else { final Field currentField = fieldAPI.find(fieldId); if (!currentField.id().equals(field.id())) { throw new DotDataValidationException("Field id '"+ fieldId +"' does not match a field with id '"+ field.id() +"'"); <START> } else if(!currentField.variable().equals(field.variable())){ <END> throw new DotDataValidationException("Field variable can not be modified, please use the following: " + currentField.variable()); } else { field = fieldAPI.save(field, user); response = Response.ok(new ResponseEntityView(new JsonFieldTransformer(field).mapObject())).build(); } } } catch (Exception e) { response = ResponseUtil.mapExceptionResponse(e); } return response; }</code><technical_language>move this business rule api level. applies java api</technical_language>

Target:
public Response updateContentTypeFieldById(@PathParam("typeId") final String typeId, @PathParam("fieldId") final String fieldId, final String fieldJson, @Context final HttpServletRequest req) throws DotDataException, DotSecurityException { final InitDataObject initData = this.webResource.init(null, false, req, false, null); final User user = initData.getUser(); Response response = null; try { Field field = new JsonFieldTransformer(fieldJson).from(); if (!UtilMethods.isSet(field.id())) { response = ExceptionMapperUtil.createResponse(null, "Field 'id' should be set"); } else { final Field currentField = fieldAPI.find(fieldId); if (!currentField.id().equals(field.id())) { throw new DotDataValidationException("Field id '"+ field.id() +"' does not match a field with id '"+ currentField.id() +"'"); } else { field = fieldAPI.save(field, user); response = Response.ok(new ResponseEntityView(new JsonFieldTransformer(field).mapObject())).build(); } } } catch (Exception e) { response = ResponseUtil.mapExceptionResponse(e); } return response; }
Source:
<code>public WorkspaceConfigImpl devFileToWorkspaceConfig( Devfile devfile, FileContentProvider contentProvider) throws DevfileException { checkArgument(devfile != null, "Devfile must not be null"); checkArgument(contentProvider != null, "Content provider must not be null"); validateCurrentVersion(devfile); WorkspaceConfigImpl config = new WorkspaceConfigImpl(); config.setName(devfile.getName()); for (Command command : devfile.getCommands()) { config.getCommands().add(commandConverter.toWorkspaceCommand(command)); } for (Component component : devfile.getComponents()) { ComponentToWorkspaceApplier applier = componentTypeToApplier.get(component.getType()); if (applier == null) { throw new DevfileException( String.format( "Devfile contains component `%s` with type `%s` that can not be converted to workspace", component.getName(), component.getType())); } applier.apply(config, component, contentProvider); } for (Project project : devfile.getProjects()) { ProjectConfigImpl projectConfig = projectConverter.toWorkspaceProject(project); config.getProjects().add(projectConfig); } return config; <START> } <END></code><technical_language>wondering if technical reason do this change</technical_language>

Target:
public WorkspaceConfigImpl devFileToWorkspaceConfig( Devfile devfile, FileContentProvider contentProvider) throws DevfileException { checkArgument(devfile != null, "Devfile must not be null"); checkArgument(contentProvider != null, "Content provider must not be null"); validateCurrentVersion(devfile); defaultEditorProvisioner.apply(devfile); WorkspaceConfigImpl config = new WorkspaceConfigImpl(); config.setName(devfile.getName()); for (Command command : devfile.getCommands()) { config.getCommands().add(commandConverter.toWorkspaceCommand(command)); } for (Component component : devfile.getComponents()) { ComponentToWorkspaceApplier applier = componentTypeToApplier.get(component.getType()); if (applier == null) { throw new DevfileException( String.format( "Devfile contains component `%s` with type `%s` that can not be converted to workspace", component.getName(), component.getType())); } applier.apply(config, component, contentProvider); } for (Project project : devfile.getProjects()) { ProjectConfigImpl projectConfig = projectConverter.toWorkspaceProject(project); config.getProjects().add(projectConfig); } return config; }
Source:
<code>public void launch(ISelection selection, String mode) { if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); <START> if (element != null && element instanceof IResource) { <END> try { IResource selectedResource = (IResource) element; launchBower(selectedResource); } catch (CoreException e) { Activator.logError(e); } } } }</code><technical_language>Check for null is required here, (element instance of IResource) returns false for null element</technical_language>

Target:
public void launch(ISelection selection, String mode) { if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); if (element instanceof IResource) { try { IResource selectedResource = (IResource) element; launchBower(selectedResource); } catch (CoreException e) { Activator.logError(e); } } } }
Source:
<code><START> static Iterator<Double> rangeBy(BigDecimal from, BigDecimal toExclusive, BigDecimal step) { <END> if (areEqual(step, BigDecimal.ZERO)) { throw new IllegalArgumentException("step cannot be 0"); } else if (areEqual(from, toExclusive) || step.signum() == from.subtract(toExclusive).signum()) { return empty(); } else { if (step.compareTo(BigDecimal.ZERO) > 0) { return new AbstractIterator<Double>() { BigDecimal i = from; @Override public boolean hasNext() { return i.compareTo(toExclusive) < 0; } @Override public Double getNext() { final BigDecimal next = this.i; this.i = next.add(step); return next.doubleValue(); } }; } else { return new AbstractIterator<Double>() { BigDecimal i = from; @Override public boolean hasNext() { return i.compareTo(toExclusive) > 0; } @Override public Double getNext() { final BigDecimal next = this.i; this.i = next.add(step); return next.doubleValue(); } }; } } }</code><technical_language>I expect Iterator<BigDecimal> result</technical_language>

Target:
static Iterator<BigDecimal> rangeBy(BigDecimal from, BigDecimal toExclusive, BigDecimal step) { if (step.signum() == 0) { throw new IllegalArgumentException("step cannot be 0"); } else if (areEqual(from, toExclusive) || step.signum() == from.subtract(toExclusive).signum()) { return empty(); } else { if (step.signum() > 0) { return new AbstractIterator<BigDecimal>() { BigDecimal i = from; @Override public boolean hasNext() { return i.compareTo(toExclusive) < 0; } @Override public BigDecimal getNext() { final BigDecimal next = this.i; this.i = next.add(step); return next; } }; } else { return new AbstractIterator<BigDecimal>() { BigDecimal i = from; @Override public boolean hasNext() { return i.compareTo(toExclusive) > 0; } @Override public BigDecimal getNext() { final BigDecimal next = this.i; this.i = next.add(step); return next; } }; } } }
Source:
<code>private String fieldAbstractJavaType(FieldSpec field) { if (field.type() instanceof FieldType.BoolFieldType) { return "boolean"; } else if (field.type() instanceof FieldType.Int8FieldType) { return "byte"; } else if (field.type() instanceof FieldType.Int16FieldType) { return "short"; } else if (field.type() instanceof FieldType.Int32FieldType) { return "int"; } else if (field.type() instanceof FieldType.Int64FieldType) { return "long"; } else if (field.type() instanceof FieldType.UUIDFieldType) { return "UUID"; } else if (field.type().isString()) { return "String"; <START> } else if (field.type().isBytes() && field.useByteBuffer()) { <END> headerGenerator.addImport(MessageGenerator.BYTE_BUFFER_CLASS); return "ByteBuffer"; } else if (field.type().isBytes() && !field.useByteBuffer()) { return "byte[]"; } else if (field.type().isStruct()) { return MessageGenerator.capitalizeFirst(field.typeString()); } else if (field.type().isArray()) { FieldType.ArrayType arrayType = (FieldType.ArrayType) field.type(); if (structRegistry.isStructArrayWithKeys(field)) { headerGenerator.addImport(MessageGenerator.IMPLICIT_LINKED_HASH_MULTI_COLLECTION_CLASS); return collectionType(arrayType.elementType().toString()); } else { headerGenerator.addImport(MessageGenerator.LIST_CLASS); return "List<" + getBoxedJavaType(arrayType.elementType()) + ">"; } } else { throw new RuntimeException("Unknown field type " + field.type()); } }</code><technical_language>nit: nested condition field.type().isBytes()</technical_language>

Target:
private String fieldAbstractJavaType(FieldSpec field) { if (field.type() instanceof FieldType.BoolFieldType) { return "boolean"; } else if (field.type() instanceof FieldType.Int8FieldType) { return "byte"; } else if (field.type() instanceof FieldType.Int16FieldType) { return "short"; } else if (field.type() instanceof FieldType.Int32FieldType) { return "int"; } else if (field.type() instanceof FieldType.Int64FieldType) { return "long"; } else if (field.type() instanceof FieldType.UUIDFieldType) { headerGenerator.addImport(MessageGenerator.UUID_CLASS); return "UUID"; } else if (field.type().isString()) { return "String"; } else if (field.type().isBytes()) { if (field.zeroCopy()) { headerGenerator.addImport(MessageGenerator.BYTE_BUFFER_CLASS); return "ByteBuffer"; } else { return "byte[]"; } } else if (field.type().isStruct()) { return MessageGenerator.capitalizeFirst(field.typeString()); } else if (field.type().isArray()) { FieldType.ArrayType arrayType = (FieldType.ArrayType) field.type(); if (structRegistry.isStructArrayWithKeys(field)) { headerGenerator.addImport(MessageGenerator.IMPLICIT_LINKED_HASH_MULTI_COLLECTION_CLASS); return collectionType(arrayType.elementType().toString()); } else { headerGenerator.addImport(MessageGenerator.LIST_CLASS); return "List<" + getBoxedJavaType(arrayType.elementType()) + ">"; } } else { throw new RuntimeException("Unknown field type " + field.type()); } }
Source:
<code>public void advertiseId(final AnyObjectId id, final String refName) throws IOException { tmpLine.setLength(0); id.copyTo(tmpId, tmpLine); tmpLine.append(' '); tmpLine.append(refName); if (first) { first = false; if (!capablities.isEmpty()) { tmpLine.append('\0'); for (final String capName : capablities) { tmpLine.append(' '); tmpLine.append(capName); } tmpLine.append(' '); } } tmpLine.append('\n'); <START> writeOne(tmpLine.toString()); <END> }</code><technical_language>StringBuffer implements CharSequence, writeOne() method is for, toString is unnecessary here</technical_language>

Target:
public void advertiseId(final AnyObjectId id, final String refName) throws IOException { tmpLine.setLength(0); id.copyTo(tmpId, tmpLine); tmpLine.append(' '); tmpLine.append(refName); if (first) { first = false; if (!capablities.isEmpty()) { tmpLine.append('\0'); for (final String capName : capablities) { tmpLine.append(' '); tmpLine.append(capName); } tmpLine.append(' '); } } tmpLine.append('\n'); writeOne(tmpLine); }
Source:
<code>@Test void testSimplifyAndIsNotNull() { final RexNode aRef = input(tInt(true), 0); final RexNode bRef = input(tInt(true), 1); RexNode expr = and( and(lt(literal(0), aRef), lt(aRef, literal(10))), isNotNull(bRef)); final String simplified = "AND(SEARCH($0, Sarg[(0..10)]), IS NOT NULL($1))"; final String expanded = "AND(AND(>($0, 0), <($0, 10)), IS NOT NULL($1))"; <START> checkSimplify(expr, simplified) <END> .expandedSearch(expanded); }</code><technical_language>Do flatten ANDs in AND(AND(>($0, 0), <($0, 10)), IS NULL($1))? I difficult achieve efficiently</technical_language>

Target:
@Test void testSimplifyAndIsNotNull() { final RexNode aRef = input(tInt(true), 0); final RexNode bRef = input(tInt(true), 1); RexNode expr = and( and(lt(literal(0), aRef), lt(aRef, literal(10))), isNotNull(bRef)); final String simplified = "AND(SEARCH($0, Sarg[(0..10)]), IS NOT NULL($1))"; final String expanded = "AND(>($0, 0), <($0, 10), IS NOT NULL($1))"; checkSimplify(expr, simplified) .expandedSearch(expanded); }
Source:
<code>private static void refreshBorderFigure(final BorderedStyle borderedStyle, final StyledFigure styledFigure) { LineBorder lineBorder = null; if (styledFigure.getBorder() instanceof LineBorder) { lineBorder = (LineBorder) styledFigure.getBorder(); } else { lineBorder = new LineBorder(); if (styledFigure instanceof Shape) { styledFigure.setBorder(null); } else { styledFigure.setBorder(lineBorder); } } int borderSize = 0; if (borderedStyle.getBorderSize() != null) { borderSize = borderedStyle.getBorderSize().intValue(); } lineBorder.setWidth(borderSize); final RGBValues borderColor = borderedStyle.getBorderColor(); if (borderColor != null) { lineBorder.setColor(VisualBindingManager.getDefault().getColorFromRGBValues(borderColor)); } final LineStyle borderLineStyle = borderedStyle.getBorderLineStyle(); if (borderLineStyle != null) { if (styledFigure instanceof SquareFigure) { ((SquareFigure) styledFigure).setLineStyle(borderLineStyle.getValue() + 1); } else if (styledFigure instanceof DotFigure) { ((DotFigure) styledFigure).setLineStyle(borderLineStyle.getValue() + 1); } else if (styledFigure instanceof LozengeFigure) { ((LozengeFigure) styledFigure).setLineStyle(borderLineStyle.getValue() + 1); } else if (styledFigure instanceof ODesignEllipseFigure) { ((ODesignEllipseFigure) styledFigure).setLineStyle(borderLineStyle.getValue() + 1); } <START> else if (styledFigure instanceof Figure) { refreshBorderLineStyle(styledFigure, borderLineStyle); } <END> } if (borderSize == 0) { if (!(styledFigure instanceof NoteFigure)) { styledFigure.setBorder(null); } } }</code><technical_language>other kind of figure a line border</technical_language>

Target:
private static void refreshBorderFigure(final BorderedStyle borderedStyle, final StyledFigure styledFigure) { LineBorder lineBorder = null; if (styledFigure.getBorder() instanceof LineBorder) { lineBorder = (LineBorder) styledFigure.getBorder(); } else { lineBorder = new LineBorder(); if (styledFigure instanceof Shape) { styledFigure.setBorder(null); } else { styledFigure.setBorder(lineBorder); } } int borderSize = 0; if (borderedStyle.getBorderSize() != null) { borderSize = borderedStyle.getBorderSize().intValue(); } lineBorder.setWidth(borderSize); final RGBValues borderColor = borderedStyle.getBorderColor(); if (borderColor != null) { lineBorder.setColor(VisualBindingManager.getDefault().getColorFromRGBValues(borderColor)); } if (borderSize == 0) { if (!(styledFigure instanceof NoteFigure)) { styledFigure.setBorder(null); } } }
Source:
<code>private RtPeopleExtractor(Element filmElement, Film film, AdapterLog log) { this.filmElement = filmElement; this.film = film; <START> this.log = log; <END> List<Person> people = Lists.newArrayList(); }</code><technical_language>checkNotNull parameters</technical_language>

Target:
private RtPeopleExtractor(Element filmElement, Film film, AdapterLog log) { this.filmElement = checkNotNull(filmElement); this.film = checkNotNull(film); this.log = checkNotNull(log); List<Person> people = Lists.newArrayList(); }
Source:
<code>public AutoPullResponseHandler(Query query, RunResponseHandler runResponseHandler, Connection connection, MetadataExtractor metadataExtractor, PullResponseCompletionListener completionListener, long fetchSize ) { super(query, runResponseHandler, connection, metadataExtractor, completionListener ); this.fetchSize = fetchSize; if ( fetchSize == UNLIMITED_FETCH_SIZE ) { this.HIGH_RECORD_WATERMARK = Long.MAX_VALUE; <START> this.LOW_RECORD_WATERMARK = Long.MAX_VALUE; <END> } else { this.HIGH_RECORD_WATERMARK = (long) (fetchSize * 0.7); this.LOW_RECORD_WATERMARK = (long) (fetchSize * 0.3); } installRecordAndSummaryConsumers(); }</code><technical_language>vars static, do need capitalised</technical_language>

Target:
public AutoPullResponseHandler(Query query, RunResponseHandler runResponseHandler, Connection connection, MetadataExtractor metadataExtractor, PullResponseCompletionListener completionListener, long fetchSize ) { super(query, runResponseHandler, connection, metadataExtractor, completionListener ); this.fetchSize = fetchSize; if ( fetchSize == UNLIMITED_FETCH_SIZE ) { this.highRecordWatermark = Long.MAX_VALUE; this.lowRecordWatermark = Long.MAX_VALUE; } else { this.highRecordWatermark = (long) (fetchSize * 0.7); this.lowRecordWatermark = (long) (fetchSize * 0.3); } installRecordAndSummaryConsumers(); }
Source:
<code>public void testSearch() throws Exception { String[] searchTerms = {Constants.NEWS, "structuretype = 2", " And structure.inode='" + Constants.NEWS + "'"}; int totalCount = contentTypeApi.count(); List<ContentType> types = contentTypeApi.search(null, BaseContentType.ANY, "name", -1, 0); assertThat("we have at least 40 content types", types.size() > 20); <START> types = contentTypeApi.search(null, BaseContentType.ANY, "name", -1, 0); <END> assertThat("limit works and we have max five content types", types.size() < 6); for (int x = 0; x < totalCount; x = x + 5) { types = contentTypeApi.search(null, BaseContentType.ANY, "name asc", -1, 0); assertThat("we have max five content types", types.size() < 6); } for (int i = 0; i < BaseContentType.values().length; i++) { types = contentTypeApi.search(null, BaseContentType.getBaseContentType(i), "name", -1, 0); assertThat("we have content types of" + BaseContentType.getBaseContentType(i), types.size() > 0); int count = contentTypeApi.count(null, BaseContentType.getBaseContentType(i)); assertThat("Count works as well", types.size() == count); } for (int i = 0; i < searchTerms.length; i++) { types = contentTypeApi.search(searchTerms[i], BaseContentType.ANY, "mod_date desc", -1, 0); assertThat("we can search content types:" + searchTerms[i], types.size() > 0); int count = contentTypeApi.count(searchTerms[i], BaseContentType.ANY); assertThat("Count works as well", types.size() == count); } }</code><technical_language>this is testing limit 5,</technical_language>

Target:
public void testSearch() throws Exception { String[] searchTerms = {Constants.NEWS, "structuretype = 2", " And structure.inode='" + Constants.NEWS + "'"}; int totalCount = contentTypeApi.count(); List<ContentType> types = contentTypeApi.search(null, BaseContentType.ANY, "name", -1, 0); assertThat("we have at least 40 content types", types.size() > 20); types = contentTypeApi.search(null, BaseContentType.ANY, "name", 5, 0); assertThat("limit works and we have max five content types", types.size() < 6); for (int x = 0; x < totalCount; x = x + 5) { types = contentTypeApi.search(null, BaseContentType.ANY, "name asc", 5, 0); assertThat("we have max five content types", types.size() < 6); } for (int i = 0; i < BaseContentType.values().length; i++) { types = contentTypeApi.search(null, BaseContentType.getBaseContentType(i), "name", -1, 0); assertThat("we have content types of" + BaseContentType.getBaseContentType(i), types.size() > 0); int count = contentTypeApi.count(null, BaseContentType.getBaseContentType(i)); assertThat("Count works as well", types.size() == count); } for (int i = 0; i < searchTerms.length; i++) { types = contentTypeApi.search(searchTerms[i], BaseContentType.ANY, "mod_date desc", -1, 0); assertThat("we can search content types:" + searchTerms[i], types.size() > 0); int count = contentTypeApi.count(searchTerms[i], BaseContentType.ANY); assertThat("Count works as well", types.size() == count); } }
Source:
<code>private ISchedulingRule calculateSchedulingRule() { Set<IContainer> containers = new HashSet<IContainer>(); for (IPath path : paths) { IResource resource = ResourceUtil.getResourceForLocation(path); <START> if (resource != null) { <END> containers.add(resource.getParent()); } } return new MultiRule(containers.toArray(new IResource[containers.size()])); }</code><technical_language>style nit: braces single line blocks</technical_language>

Target:
private ISchedulingRule calculateSchedulingRule() { Set<IContainer> containers = new HashSet<IContainer>(); for (IPath path : paths) { IResource resource = ResourceUtil.getResourceForLocation(path); if (resource != null) containers.add(resource.getParent()); } return new MultiRule(containers.toArray(new IResource[containers.size()])); }
Source:
<code>public String getContextTemplate() { <START> if (isAPIProduct) { return apiProduct.getContextTemplate(); } else { return api.getContextTemplate(); } <END> }</code><technical_language>a ternary operator here? Lets check fix other places applicable. suggestion return isAPIProduct ? apiProduct.getContextTemplate() : api.getContextTemplate();</technical_language>

Target:
public String getContextTemplate() { return isAPIProduct ? apiProduct.getContextTemplate() : api.getContextTemplate(); }
Source:
<code>public void testLockForConfigChange() { LlapRegistryService client1 = new LlapRegistryService(false); client1.init(conf); client1.start(); LlapRegistryService client2 = new LlapRegistryService(false); client2.init(conf); client2.start(); ConfigChangeLockResult result = null; <START> assertTrue(client1.lockForConfigChange(10000).success); <END> assertTrue(client2.lockForConfigChange(30000).success); result = client1.lockForConfigChange(20000); assertFalse(result.success); assertEquals(result.nextConfigChangeTime, 30000); result = client1.lockForConfigChange(30000); assertFalse(result.success); assertEquals(result.nextConfigChangeTime, 30000); result = client1.lockForConfigChange(40000); assertTrue(result.success); assertEquals(result.nextConfigChangeTime, 40000); }</code><technical_language>Consider accessor isSuccess() instead</technical_language>

Target:
public void testLockForConfigChange() throws IOException { LlapRegistryService client1 = null; LlapRegistryService client2 = null; ConfigChangeLockResult result; try { client1 = new LlapRegistryService(false); client1.init(conf); client1.start(); client2 = new LlapRegistryService(false); client2.init(conf); client2.start(); assertTrue(client1.lockForConfigChange(10000, 20000).isSuccess()); assertTrue(client2.lockForConfigChange(30000, 40000).isSuccess()); result = client1.lockForConfigChange(20000, 30000); assertFalse(result.isSuccess()); assertEquals(result.getNextConfigChangeTime(), 40000); result = client1.lockForConfigChange(30000, 40000); assertFalse(result.isSuccess()); assertEquals(result.getNextConfigChangeTime(), 40000); result = client1.lockForConfigChange(35000, 45000); assertFalse(result.isSuccess()); assertEquals(result.getNextConfigChangeTime(), 40000); result = client1.lockForConfigChange(40000, 50000); assertTrue(result.isSuccess()); assertEquals(result.getNextConfigChangeTime(), 50000); } finally { if (client1 != null) { client1.close(); } if (client2 != null) { client2.close(); } } }
Source:
<code>protected void processArguments(LinkedList<PathData> args) throws IOException { if (args.size() < 1) { <START> throw new IOException("Target path not specified."); <END> } if (args.size() < 3) { throw new IOException("The number of source paths is less than 2."); } PathData target = args.removeFirst(); LinkedList<PathData> srcList = args; if (!target.exists || !target.stat.isFile()) { throw new IOException(String.format("Target path %s does not exist or is" + " not file.", target.path)); } Path[] srcArray = new Path[srcList.size()]; for (int i = 0; i < args.size(); i++) { PathData src = srcList.get(i); if (!src.exists || !src.stat.isFile()) { throw new IOException( String.format("%s does not exist or is not file.", src.path)); } srcArray[i] = src.path; } FileSystem fs = target.fs; if (tstFs != null) { fs = tstFs; } try { fs.concat(target.path, srcArray); } catch (UnsupportedOperationException exception) { throw new IOException("Dest filesystem '" + fs.getUri().getScheme() + "' doesn't support concat."); } }</code><technical_language>include Usage text</technical_language>

Target:
protected void processArguments(LinkedList<PathData> args) throws IOException { if (args.size() < 1) { throw new IOException("Target path not specified. " + USAGE); } if (args.size() < 3) { throw new IOException( "The number of source paths is less than 2. " + USAGE); } PathData target = args.removeFirst(); LinkedList<PathData> srcList = args; if (!target.exists || !target.stat.isFile()) { throw new FileNotFoundException(String .format("Target path %s does not exist or is" + " not file.", target.path)); } Path[] srcArray = new Path[srcList.size()]; for (int i = 0; i < args.size(); i++) { PathData src = srcList.get(i); if (!src.exists || !src.stat.isFile()) { throw new FileNotFoundException( String.format("%s does not exist or is not file.", src.path)); } srcArray[i] = src.path; } FileSystem fs = target.fs; if (testFs != null) { fs = testFs; } try { fs.concat(target.path, srcArray); } catch (UnsupportedOperationException exception) { throw new PathIOException("Dest filesystem '" + fs.getUri().getScheme() + "' doesn't support concat.", exception); } }
Source:
<code>private void runNextPushRequest() { LogIndex committedIndex = leader.getCommitted(); if (equals(txnAccepted, committedIndex) && !equals(txnCommitted, committedIndex)) { <START> pushCommitAsync(committedIndex, <END> leader.isIdle()); } if (queued.isEmpty() || !running.isEmpty() || waitingForRetry()) { return; } Map<String, ReceiveCommand> cmdMap = new HashMap<>(); for (ReplicaPushRequest req : queued) { for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); ReceiveCommand old = cmdMap.remove(name); if (old != null) { cmd = new ReceiveCommand( old.getOldId(), cmd.getNewId(), name); } cmdMap.put(name, cmd); } } queued.clear(); waiting.clear(); List<ReceiveCommand> next = new ArrayList<>(cmdMap.values()); for (ReceiveCommand cmd : next) { running.put(cmd.getRefName(), cmd); } startPush(new ReplicaPushRequest(this, next)); }</code><technical_language>This name reads unconditionally pushes commit state, batching another proposal. I of a good name pull conditionals out of pushCommitAsync() create a new boolean shouldPushUnbatchedCommit() combines 2 terms here</technical_language>

Target:
private void runNextPushRequest() { LogIndex committed = leader.getCommitted(); if (!equals(txnCommitted, committed) && shouldPushUnbatchedCommit(committed, leader.isIdle())) { pushCommitAsync(committed); } if (queued.isEmpty() || !running.isEmpty() || waitingForRetry()) { return; } Map<String, ReceiveCommand> cmdMap = new HashMap<>(); for (ReplicaPushRequest req : queued) { for (ReceiveCommand cmd : req.getCommands()) { String name = cmd.getRefName(); ReceiveCommand old = cmdMap.remove(name); if (old != null) { cmd = new ReceiveCommand( old.getOldId(), cmd.getNewId(), name); } cmdMap.put(name, cmd); } } queued.clear(); waiting.clear(); List<ReceiveCommand> next = new ArrayList<>(cmdMap.values()); for (ReceiveCommand cmd : next) { running.put(cmd.getRefName(), cmd); } startPush(new ReplicaPushRequest(this, next)); }
Source:
<code>public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_OK); LocalityModel localityModel = localityManager.readLocality(); if (request.getParameterMap().size() == 1) { String processorId = request.getParameter(PROCESSOR_ID_PARAM); HostLocality hostLocality = Optional.ofNullable(localityModel.getHostLocality(processorId)) <START> .orElse(new HostLocality(processorId, "")); <END> mapper.writeValue(response.getWriter(), hostLocality); } else { mapper.writeValue(response.getWriter(), localityModel); } }</code><technical_language>this return HTTP error (404 etc.) instead</technical_language>

Target:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_OK); LocalityModel localityModel = localityManager.readLocality(); if (request.getParameterMap().size() == 1) { String processorId = request.getParameter(PROCESSOR_ID_PARAM); ProcessorLocality processorLocality = Optional.ofNullable(localityModel.getProcessorLocality(processorId)) .orElse(new ProcessorLocality(processorId, "")); mapper.writeValue(response.getWriter(), processorLocality); } else { mapper.writeValue(response.getWriter(), localityModel); } }
Source:
<code>public int hashCode() { int result = (_success ? 1 : 0); result = 31 * result + (_nuageVspCmsId != null ? _nuageVspCmsId.hashCode() : 0); result = 31 * result + (_syncType != null ? _syncType.hashCode() : 0); return result; <START> } <END></code><technical_language>Please implement toString() provide debugging state information for debugging purposes</technical_language>

Target:
public int hashCode() { int result = super.hashCode(); result = 31 * result + (_success ? 1 : 0); result = 31 * result + (_nuageVspCmsId != null ? _nuageVspCmsId.hashCode() : 0); result = 31 * result + (_syncType != null ? _syncType.hashCode() : 0); return result; }
Source:
<code><START> public static void enableKeyserverSync(Context context) {] <END> Account account = KeychainApplication.createAccountIfNecessary(context); if (account == null) { return; } ContentResolver.setIsSyncable(account, Constants.PROVIDER_AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, Constants.PROVIDER_AUTHORITY, true); ContentResolver.addPeriodicSync( account, Constants.PROVIDER_AUTHORITY, new Bundle(), SYNC_INTERVAL ); }</code><technical_language>A curious compile errors sneaking in commits</technical_language>

Target:
public static void enableKeyserverSync(Context context) { Account account = KeychainApplication.createAccountIfNecessary(context); if (account == null) { return; } ContentResolver.setIsSyncable(account, Constants.PROVIDER_AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, Constants.PROVIDER_AUTHORITY, true); ContentResolver.addPeriodicSync( account, Constants.PROVIDER_AUTHORITY, new Bundle(), SYNC_INTERVAL ); }
Source:
<code>public static void testEventsTable(SWTWorkbenchBot bot, String editorName, long nbEvents, String firstEventStr) { SWTBotEditor editor = SWTBotUtils.activeEventsEditor(bot, editorName); bot.waitUntil(ConditionHelpers.numberOfEventsInTrace(TmfTraceManager.getInstance().getActiveTrace(), nbEvents)); if (nbEvents == 0 || firstEventStr == null || firstEventStr.isEmpty()) { return; } SWTBotTable table = editor.bot().table(); bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { <START> return table.rowCount() > 1; <END> } @Override public String getFailureMessage() { return "No items in table"; } }); table.getTableItem(1).select(); editor.bot().waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { SWTBotTable curTable = editor.bot().table(); boolean ret = curTable.selection().rowCount() == 1 && curTable.selection().get(0).toString().contains(firstEventStr); if (!ret) { curTable.getTableItem(1).select(); } return ret; } @Override public String getFailureMessage() { return "First event not selected."; } }); }</code><technical_language>this editor.bot.table()</technical_language>

Target:
public static void testEventsTable(SWTWorkbenchBot bot, String editorName, long nbEvents, String firstEventStr) { SWTBotEditor editor = SWTBotUtils.activeEventsEditor(bot, editorName); bot.waitUntil(ConditionHelpers.numberOfEventsInTrace(TmfTraceManager.getInstance().getActiveTrace(), nbEvents)); if (nbEvents == 0 || firstEventStr == null || firstEventStr.isEmpty()) { return; } bot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { SWTBotTable table = editor.bot().table(); return table.rowCount() > 1; } @Override public String getFailureMessage() { return "No items in table"; } }); SWTBotTable table = editor.bot().table(); table.getTableItem(1).select(); editor.bot().waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { SWTBotTable curTable = editor.bot().table(); boolean ret = curTable.selection().rowCount() == 1 && curTable.selection().get(0).toString().contains(firstEventStr); if (!ret) { curTable.getTableItem(1).select(); } return ret; } @Override public String getFailureMessage() { return "First event not selected."; } }); }
Source:
<code>public Channel createChannel(String id) throws Exception { JGroupsLogger.ROOT_LOGGER.debugf("Creating fork channel %s from channel %s", id, this.channel.getClusterName()); String stackName = this.protocols.isEmpty() ? this.channel.getClusterName() : id; return new ForkChannel(this.channel, stackName, id, this.protocols.stream().map(protocolConfiguration -> { Protocol protocol = protocolConfiguration.createProtocol(); <START> protocol.enableStats(protocolConfiguration.isStatisticsEnabled() != null ? protocolConfiguration.isStatisticsEnabled() : this.parentFactory.getProtocolStackConfiguration().isStatisticsEnabled()); <END> return protocol; }).toArray(Protocol[]::new)); }</code><technical_language>a separate .map(...) function</technical_language>

Target:
public Channel createChannel(String id) throws Exception { JGroupsLogger.ROOT_LOGGER.debugf("Creating fork channel %s from channel %s", id, this.channel.getClusterName()); String stackName = this.protocols.isEmpty() ? this.channel.getClusterName() : id; return new ForkChannel(this.channel, stackName, id, this.protocols.stream().map(pc -> pc.createProtocol(this.parentFactory.getProtocolStackConfiguration())).toArray(Protocol[]::new)); }
Source:
<code>public void addServiceEventListener(Object listener, Filter filter) { assert getExecutor().isInExecutorThread(); ListenerEntry entry = new ListenerEntry(listener, filter); <START> if (DsfDebugOptions.DEBUG && DsfDebugOptions.DEBUG_SESSION && DsfDebugOptions.DEBUG_SESSION_LISTENERS) { <END> String msg = new Formatter().format( "%s %s added as a service listener to %s (id=%s)", DsfPlugin.getDebugTime(), LoggingUtils.toString(listener), LoggingUtils.toString(this), getId() ).toString(); DsfDebugOptions.trace(msg); } fListeners.put(entry, getEventHandlerMethods(listener)); }</code><technical_language>DsfDebugOptions.DEBUG_SESSION_LISTENERS include others in DsfDebugOptions</technical_language>

Target:
public void addServiceEventListener(Object listener, Filter filter) { assert getExecutor().isInExecutorThread(); ListenerEntry entry = new ListenerEntry(listener, filter); if (DsfDebugOptions.DEBUG_SESSION_LISTENERS) { String msg = new Formatter().format( "%s %s added as a service listener to %s (id=%s)", DsfPlugin.getDebugTime(), LoggingUtils.toString(listener), LoggingUtils.toString(this), getId() ).toString(); DsfDebugOptions.trace(msg); } fListeners.put(entry, getEventHandlerMethods(listener)); }
Source:
<code>public InterceptorHandler handlerFor(Class<?> type) { if (type.isAnnotationPresent(Lazy.class)) { InterceptorHandler handler = cachedHandlers.get(type); if (handler == null) { LazyInterceptorHandler value = new LazyInterceptorHandler(container, type); cachedHandlers.putIfAbsent(type, value); return value; } else { return handler; } } else{ List<Class<?>> interfaces = Arrays.asList(type.getInterfaces()); boolean isInterceptorWithInterface = false; for (Class<?> interfacee : interfaces) { if(Interceptor.class.isAssignableFrom(interfacee)){ isInterceptorWithInterface = true; break; } <START> } <END> if(type.isAnnotationPresent(Intercepts.class) && !isInterceptorWithInterface){ System.out.println("AspectStyle => "+type); return new AspectStyleInterceptorHandler(type, new StepInvoker(), container); } } return new ToInstantiateInterceptorHandler(container, type); }</code><technical_language>Interceptor.class.isAssignableFrom(type)</technical_language>

Target:
public InterceptorHandler handlerFor(Class<?> type) { if (type.isAnnotationPresent(Lazy.class)) { InterceptorHandler handler = cachedHandlers.get(type); if (handler == null) { LazyInterceptorHandler value = new LazyInterceptorHandler(container, type); cachedHandlers.putIfAbsent(type, value); return value; } else { return handler; } } else{ if(type.isAnnotationPresent(Intercepts.class) && !Interceptor.class.isAssignableFrom(type)){ return new AspectStyleInterceptorHandler(type, new StepInvoker(), container); } } return new ToInstantiateInterceptorHandler(container, type); }
Source:
<code>private void writeTarget() throws TransferException { OutputStream out = null; if ( response != null ) { InputStream in = null; try { final HttpEntity entity = response.getEntity(); in = entity.getContent(); out = target.openOutputStream( TransferOperation.DOWNLOAD, true, eventMetadata, deleteFilesOnPath ); copy( in, out ); logger.info( "Ensuring all HTTP data is consumed..." ); EntityUtils.consume( entity ); logger.info( "All HTTP data was consumed." ); } catch ( final IOException e ) { ConcreteResource resource = null; <START> if ( target.exists() ) <END> { try { resource = target.getResource(); target.delete(); } catch ( IOException e1 ) { throw new TransferException( "Failed to write to local proxy store: {}\nOriginal URL: {}. Reason: {}", e1, target, url, e1.getMessage() ); } } throw new TransferContentException( resource, "Failed to write to local proxy store: {}\nOriginal URL: {}. Reason: {}", e, target, url, e.getMessage() ); } finally { closeQuietly( in ); logger.info( "Closing output stream: {}", out ); closeQuietly( out ); } } }</code><technical_language>I avoid checking if exists delete it. first, IOUtils.closeQuietly(out) ensure file deleted</technical_language>

Target:
private void writeTarget() throws TransferException { OutputStream out = null; if ( response != null ) { InputStream in = null; try { final HttpEntity entity = response.getEntity(); in = entity.getContent(); out = target.openOutputStream( TransferOperation.DOWNLOAD, true, eventMetadata, deleteFilesOnPath ); copy( in, out ); logger.info( "Ensuring all HTTP data is consumed..." ); EntityUtils.consume( entity ); logger.info( "All HTTP data was consumed." ); } catch ( final IOException e ) { closeQuietly( in ); closeQuietly( out ); ConcreteResource resource = target.getResource(); try { logger.debug( "Failed to write to local proxy store :{} so delete target:{}",e,target.getPath() ); target.delete(); } catch ( IOException e1 ) { logger.error( "Failed to delete target file: {}\nOriginal URL: {}. Reason: {}", e1, target, url, e1.getMessage() ); throw new TransferException( "Failed to delete target file: {}\nOriginal URL: {}. Reason: {}", e1, target, url, e1.getMessage() ); } logger.error( "Failed to write to local proxy store: {}\nOriginal URL: {}. Reason: {}", e, target, url, e.getMessage() ); throw new TransferContentException( resource, "Failed to write to local proxy store: {}\nOriginal URL: {}. Reason: {}", e, target, url, e.getMessage() ); } finally { closeQuietly( in ); logger.info( "Closing output stream: {}", out ); closeQuietly( out ); } } }
Source:
<code>public void make() { size = ScreenSize.getInstance(); size.calculate(); MenuBarView menuBarView = new MenuBarView(this); setMenuBar(menuBarView.getPanel()); WindowController windowController = new WindowController(this); addWindowListener(windowController); loadingObservers.add(new LoadingMouse(this)); <START> this.setMinimumSize(new Dimension(800, 600)); <END> this.setFocusable(true); this.setVisible(true); }</code><technical_language>Add some constants for this</technical_language>

Target:
public void make() { size = ScreenSize.getInstance(); size.calculate(); MenuBarView menuBarView = new MenuBarView(this); setMenuBar(menuBarView.getPanel()); WindowController windowController = new WindowController(this); addWindowListener(windowController); loadingObservers.add(new LoadingMouse(this)); this.setMinimumSize(new Dimension(size.getMinimumWidth(), size.getMinimumHeight())); this.setFocusable(true); this.setVisible(true); }