auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void init(FilterConfig filterConfig) throws ServletException { boolean enabled = loadBooleanParam("enabled", filterConfig, true); int requestDurationThresholdInSeconds = loadIntParam("request-duration-threshold-in-seconds", filterConfig, <START> 20); <END> int timeBucketCapacityInSeconds = loadIntParam("time-bucket-capacity-in-seconds", filterConfig, 40); int timeBucketRefillAmountInSeconds = loadIntParam("time-bucket-refill-amount-in-seconds", filterConfig, 1000000); int timeBucketRefillPeriodInMinutes = loadIntParam("time-bucket-refill-period-in-minutes", filterConfig, 1); int errorBucketCapacity = loadIntParam("error-bucket-capacity", filterConfig, 10); int errorBucketRefillAmount = loadIntParam("error-bucket-refill-amount", filterConfig, 100); int errorBucketRefillPeriodInMinutes = loadIntParam("error-bucket-refill-period-in-minutes", filterConfig, 1); int maxStateSize = loadIntParam("max-state-size", filterConfig, 10000); int stateExpirationInSeconds = loadIntParam("state-expiration-in-seconds", filterConfig, 15); this.enabled = enabled; throttler = new Throttler<>( Duration.of(requestDurationThresholdInSeconds, SECONDS), new UserAgentIpAddressBucketting(), createThrottlingState( timeBucketCapacityInSeconds, timeBucketRefillAmountInSeconds, timeBucketRefillPeriodInMinutes, errorBucketCapacity, errorBucketRefillAmount, errorBucketRefillPeriodInMinutes), CacheBuilder.newBuilder() .maximumSize(maxStateSize) .expireAfterAccess(stateExpirationInSeconds, TimeUnit.MINUTES) .build()); }</code><technical_language>10 a good default</technical_language>

Target:
public void init(FilterConfig filterConfig) throws ServletException { int requestDurationThresholdInSeconds = loadIntParam("request-duration-threshold-in-seconds", filterConfig, 10); int timeBucketCapacityInSeconds = loadIntParam("time-bucket-capacity-in-seconds", filterConfig, 60); int timeBucketRefillAmountInSeconds = loadIntParam("time-bucket-refill-amount-in-seconds", filterConfig, 60); int timeBucketRefillPeriodInMinutes = loadIntParam("time-bucket-refill-period-in-minutes", filterConfig, 1); int errorBucketCapacity = loadIntParam("error-bucket-capacity", filterConfig, 10); int errorBucketRefillAmount = loadIntParam("error-bucket-refill-amount", filterConfig, 100); int errorBucketRefillPeriodInMinutes = loadIntParam("error-bucket-refill-period-in-minutes", filterConfig, 1); int maxStateSize = loadIntParam("max-state-size", filterConfig, 10000); int stateExpirationInMinutes = loadIntParam("state-expiration-in-minutes", filterConfig, 15); this.enabled = loadBooleanParam("enabled", filterConfig, true); throttler = new Throttler<>( Duration.of(requestDurationThresholdInSeconds, SECONDS), new UserAgentIpAddressBucketing(), createThrottlingState( timeBucketCapacityInSeconds, timeBucketRefillAmountInSeconds, timeBucketRefillPeriodInMinutes, errorBucketCapacity, errorBucketRefillAmount, errorBucketRefillPeriodInMinutes), CacheBuilder.newBuilder() .maximumSize(maxStateSize) .expireAfterAccess(stateExpirationInMinutes, TimeUnit.MINUTES) .build()); }
Source:
<code>public void testStructureContainment() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("structure-containtment.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("<LINK_0>", "structure-containtment"); assertThat(dmnModel, notNullValue()); assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false)); final DMNContext context = DMNFactory.newContext(); context.set("an employee", prototype(entry("age", 50))); final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context); assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false)); final DMNContext result = dmnResult.getContext(); <START> assertThat(result.get("is there"), is("true")); <END> }</code><technical_language>@jomarko asserting result string literal "true". actual result is literal boolean true. "true" true</technical_language>

Target:
public void testStructureContainment() { final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("structure-containtment.dmn", this.getClass()); final DMNModel dmnModel = runtime.getModel("<LINK_0>", "structure-containtment"); assertThat(dmnModel, notNullValue()); assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false)); final DMNContext context = DMNFactory.newContext(); context.set("an employee", prototype(entry("age", BigDecimal.valueOf(50)))); final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context); assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false)); final DMNContext result = dmnResult.getContext(); assertThat(result.get("is there"), is(true)); }
Source:
<code>private Entity event(Entity entity) { String kind = entity.getKey().getKind(); final EventTypes eventTypes = EventUtils .getEventAndActionType(kind); if (eventTypes != null) { Map<String, Object> event = updateOrCreateEvent(entity, eventTypes); try { return EventUtils.createEventLogEntity(event, new Date()); } catch (IOException e) { throw new RuntimeException(e); } } <START> return entity; <END> }</code><technical_language>this if event type is entity get stored is in event queue</technical_language>

Target:
private Entity event(Entity entity) { String kind = entity.getKey().getKind(); final EventTypes eventTypes = EventUtils .getEventAndActionType(kind); if (eventTypes == null) { return null; } else { Map<String, Object> event = updateOrCreateEvent(entity, eventTypes); try { return EventUtils.createEventLogEntity(event, new Date()); } catch (IOException e) { throw new RuntimeException(e); } } }
Source:
<code>private Object readResolve() { if (loggers == null) { loggers = new ArrayList<>(); } <START> if (!targets.isEmpty()) { <END> loggers.addAll(targets.getView()); } if (!loggers.isEmpty()) { targets.addAll(loggers); } return this; }</code><technical_language>is true for targets, this null a null point exception. suggestion if (targets != null && !targets.isEmpty()) {</technical_language>

Target:
private Object readResolve() { if (loggers == null) { loggers = new ArrayList<>(); } if (targets != null && !targets.isEmpty()) { loggers.addAll(targets.getView()); } if (!loggers.isEmpty()) { targets.addAll(loggers); } return this; }
Source:
<code>public String getTranscoding() { if <START> (getTranscodingClassification() == <END> TranscodingClassification.TRANSCODED_TO_IMAGE) { if (width == null) return "image"; else if (width <= 199) return "image_0_199"; else if (width >= 200 && width <= 399 ) return "image_200_399"; else if (width >= 400 && width <= 599 ) return "image_400_599"; else if (width >= 600 && width <= 799 ) return "image_600_799"; else if (width >= 800 && width <= 999 ) return "image_800_999"; else if (width >= 1000) return "image_1000"; } else if (getTranscodingClassification() == TranscodingClassification.TRANSCODED_TO_MOVIE) { if (height == null) return "movie"; else if (height <= 239) return "movie_0_239"; else if (height >= 240 || height <= 479 ) return "movie_240_479"; else if (height >= 480 ) return "movie_480"; } else if (getTranscodingClassification() == TranscodingClassification.ORIGINAL) { return "original"; } else if (getTranscodingClassification() == TranscodingClassification.TRANSCODED_TO_AUDIO) { return "audio"; } return null; }</code><technical_language>this is executed a fair amount of times, factor calls out if store result in a var, no</technical_language>

Target:
public String getTranscoding() { if (transcodingClassification == TranscodingClassification.TRANSCODED_TO_IMAGE) { if (width == null) return "image"; else if (width <= 199) return "image_0_199"; else if (width >= 200 && width <= 399 ) return "image_200_399"; else if (width >= 400 && width <= 599 ) return "image_400_599"; else if (width >= 600 && width <= 799 ) return "image_600_799"; else if (width >= 800 && width <= 999 ) return "image_800_999"; else if (width >= 1000) return "image_1000"; } else if (transcodingClassification == TranscodingClassification.TRANSCODED_TO_MOVIE) { if (height == null) return "movie"; else if (height <= 239) return "movie_0_239"; else if (height >= 240 || height <= 479 ) return "movie_240_479"; else if (height >= 480 ) return "movie_480"; } else if (transcodingClassification == TranscodingClassification.ORIGINAL) { return "original"; } else if (transcodingClassification == TranscodingClassification.TRANSCODED_TO_AUDIO) { return "audio"; } return null; }
Source:
<code>CancellationTokenRegistration register(Runnable action) { CancellationTokenRegistration ctr; synchronized (lock) { throwIfClosed(); ctr = new CancellationTokenRegistration(this, action); if (cancellationRequested) { <START> action.run(); <END> } else { registrations.add(ctr); } } return ctr; }</code><technical_language>consistent ctr.runAction()</technical_language>

Target:
CancellationTokenRegistration register(Runnable action) { CancellationTokenRegistration ctr; synchronized (lock) { throwIfClosed(); ctr = new CancellationTokenRegistration(this, action); if (cancellationRequested) { ctr.runAction(); } else { registrations.add(ctr); } } return ctr; }
Source:
<code><START> private void setTableManipulation(JdbcStringBasedStoreConfigurationBuilder storeBuilder) { <END> buildTableManipulation(storeBuilder.table()); }</code><technical_language>this method is private, I understand adds</technical_language>

Target:
protected void setTableManipulation(JdbcStringBasedStoreConfigurationBuilder storeBuilder) { buildTableManipulation(storeBuilder.table()); }
Source:
<code>private void setNodeIdForVertex(GraphMLVertex vertex) { <START> if (Objects.isNull(vertex)) { <END> return; } if (Objects.isNull(vertex.getNodeID())) { String foreignSource = (String) vertex.getProperties().get(GraphMLProperties.FOREIGN_SOURCE); String foreignId = (String) vertex.getProperties().get(GraphMLProperties.FOREIGN_ID); if (!Strings.isNullOrEmpty(foreignSource) && !Strings.isNullOrEmpty(foreignId)) { OnmsNode onmsNode = m_serviceAccessor.getNodeDao().findByForeignId(foreignSource, foreignId); if (onmsNode != null) { vertex.setNodeID(onmsNode.getId()); } else { LOG.warn("no node found for the given foreignSource ({}) and foreignId ({})", foreignSource, foreignId); } } else { LOG.warn("nodeId is null, foreignSource ({}) and foreignId ({}) must be set both", foreignSource, foreignId); } } }</code><technical_language>Is a reason Objects.isNull() instead of verifiing if vertex == null</technical_language>

Target:
private void setNodeIdForVertex(GraphMLVertex vertex) { if (vertex == null) { return; } if (vertex.getNodeID() == null) { String foreignSource = (String) vertex.getProperties().get(GraphMLProperties.FOREIGN_SOURCE); String foreignId = (String) vertex.getProperties().get(GraphMLProperties.FOREIGN_ID); if (!Strings.isNullOrEmpty(foreignSource) && !Strings.isNullOrEmpty(foreignId)) { OnmsNode onmsNode = m_serviceAccessor.getNodeDao().findByForeignId(foreignSource, foreignId); if (onmsNode != null) { vertex.setNodeID(onmsNode.getId()); } else { LOG.warn("No node found for the given foreignSource ({}) and foreignId ({}).", foreignSource, foreignId); } } else { LOG.warn("The given nodeId is null. In order to resolve the nodeId a foreignSource ({}) and foreignId ({}) must be set.", foreignSource, foreignId); } } }
Source:
<code>public void onMessage(Message message) { try { URLNotification notification = URLNotificationJSONConverter.parseJSON(new ByteArrayInputStream(message.getData())); receiveNotification(notification); if (!exceptionThrown || updateSequenceAfterException) { sequence = message.getSequence(); writeTrackingFile(); } } catch (Exception e) { exceptionThrown = true; <START> LOGGER.log(Level.WARNING, "[" + getName() + "] exception handling NATSStreaming message." + <END> (!updateSequenceAfterException ? " Will no longer update sequence; restart PDL to reprocess":"")); } }</code><technical_language>Output message caused exception, possibly FINE log level. include exception parameter a stack trace</technical_language>

Target:
public void onMessage(Message message) { try { URLNotification notification = URLNotificationJSONConverter.parseJSON(new ByteArrayInputStream(message.getData())); receiveNotification(notification); if (!exceptionThrown || updateSequenceAfterException) { sequence = message.getSequence(); writeTrackingFile(); } } catch (Exception e) { exceptionThrown = true; LOGGER.log(Level.WARNING, "[" + getName() + "] exception handling NATSStreaming message." + (!updateSequenceAfterException ? " Will no longer update sequence; restart PDL to reprocess.":"") + " Stack Trace: " + e); LOGGER.log(Level.FINE, "[" + getName() + "] Message: " + message.getData()); } }
Source:
<code>private VariantContext calculateGenotypes(VariantContext vc){ final VariantContext.Type type = vc.getType(); final GenotypeLikelihoodsCalculationModel model; if ( type == VariantContext.Type.INDEL ) { <START> model = GenotypeLikelihoodsCalculationModel.INDEL; <END> } else { model = GenotypeLikelihoodsCalculationModel.SNP; } return genotypingEngine.calculateGenotypes(vc, model, null); }</code><technical_language>Erm, confirm INDEL model is functional in this minimal version of genotyping engine? Do a representative sampling of indels in test inputs</technical_language>

Target:
private VariantContext calculateGenotypes(VariantContext vc){ final GenotypeLikelihoodsCalculationModel model = vc.getType() == VariantContext.Type.INDEL ? GenotypeLikelihoodsCalculationModel.INDEL : GenotypeLikelihoodsCalculationModel.SNP; return genotypingEngine.calculateGenotypes(vc, model, null); }
Source:
<code>public void saveRelationship(TaskExecution taskExecution, JobExecution jobExecution) { <START> if(this.relationships.containsKey(taskExecution.getExecutionId())) { <END> this.relationships.get(taskExecution.getExecutionId()).add(jobExecution.getId()); } else { TreeSet<Long> jobExecutionIds = new TreeSet<>(); jobExecutionIds.add(jobExecution.getId()); this.relationships.put(taskExecution.getExecutionId(), jobExecutionIds); } }</code><technical_language>check for null in parameters</technical_language>

Target:
public void saveRelationship(TaskExecution taskExecution, JobExecution jobExecution) { Assert.notNull(taskExecution, "A taskExecution is required"); Assert.notNull(jobExecution, "A jobExecution is required"); if(this.relationships.containsKey(taskExecution.getExecutionId())) { this.relationships.get(taskExecution.getExecutionId()).add(jobExecution.getId()); } else { TreeSet<Long> jobExecutionIds = new TreeSet<>(); jobExecutionIds.add(jobExecution.getId()); this.relationships.put(taskExecution.getExecutionId(), jobExecutionIds); } }
Source:
<code>public DefaultRepositoryMetadata(Class<?> repositoryInterface) { super(repositoryInterface); Assert.isTrue(Repository.class.isAssignableFrom(repositoryInterface), MUST_BE_A_REPOSITORY); <START> Class<? extends Serializable> idType = resolveIdType(repositoryInterface); <END> Class<?> domainType = resolveDomainType(repositoryInterface); Assert.notNull(idType, "IdType must not be null!"); Assert.notNull(domainType, "DomainType must not be null!"); this.idType = idType; this.domainType = domainType; }</code><technical_language>assigned field directly</technical_language>

Target:
public DefaultRepositoryMetadata(Class<?> repositoryInterface) { super(repositoryInterface); Assert.isTrue(Repository.class.isAssignableFrom(repositoryInterface), MUST_BE_A_REPOSITORY); this.idType = resolveIdType(repositoryInterface); this.domainType = resolveDomainType(repositoryInterface); }
Source:
<code>public static <START> LocalFile cleanLfsBlob(Repository <END> db, InputStream originalContent) throws IOException { LocalFile buffer = new TemporaryBuffer.LocalFile(null); CleanFilter f = new CleanFilter(db, originalContent, buffer); while (f.run() != -1) { } return buffer; }</code><technical_language>reason interface is specific LocalFile? TemporaryBuffer</technical_language>

Target:
public static TemporaryBuffer cleanLfsBlob(Repository db, InputStream originalContent) throws IOException { LocalFile buffer = new TemporaryBuffer.LocalFile(null); CleanFilter f = new CleanFilter(db, originalContent, buffer); try { while (f.run() != -1) { } } catch (IOException e) { buffer.close(); throw e; } return buffer; }
Source:
<code>public static Map<Long, Map<String, MetricNameDto>> getMappedMetricDtos(Collection<MetricNameDto> metricNameDtos) { Map<Long, Map<String, MetricNameDto>> taskIdMap = new HashMap<Long, Map<String, MetricNameDto>>(); for (MetricNameDto metricName : metricNameDtos) { Set<Long> ids = metricName.getTaskIds(); for (Long id : ids) { <START> if (taskIdMap.get(id) == null) { <END> taskIdMap.put(id, new HashMap<String, MetricNameDto>()); } Map<String, MetricNameDto> metricIdMap = taskIdMap.get(id); if (metricIdMap.get(metricName.getMetricName()) == null) { metricIdMap.put(metricName.getMetricName(), metricName); } else { throw new IllegalStateException(metricName.toString() + " already in Map"); } } } return taskIdMap; }</code><technical_language>containsKey</technical_language>

Target:
public static Map<Long, Map<String, MetricNameDto>> getMappedMetricDtos(Collection<MetricNameDto> metricNameDtos) { Map<Long, Map<String, MetricNameDto>> taskIdMap = new HashMap<Long, Map<String, MetricNameDto>>(); for (MetricNameDto metricName : metricNameDtos) { Set<Long> ids = metricName.getTaskIds(); for (Long id : ids) { if (!taskIdMap.containsKey(id)) { taskIdMap.put(id, new HashMap<String, MetricNameDto>()); } Map<String, MetricNameDto> metricIdMap = taskIdMap.get(id); if (!metricIdMap.containsKey(metricName.getMetricName())) { metricIdMap.put(metricName.getMetricName(), metricName); } else { throw new IllegalStateException(metricName.toString() + " already in Map"); } } } return taskIdMap; }
Source:
<code>private void parseMetadata(TraceEventField field) { Map<@NonNull String, @NonNull Object> args = field.getArgs(); String name = field.getName(); if (args == null) { return; } <START> if (name.equals(PROCESS_NAME)) { <END> String procName = (String) args.get(NAME_ARG); fPidNames.put(field.getPid(), procName); if (procName != null) { fProperties.put("pid-" + field.getPid(), procName); } } else if (name.equals(PROCESS_LABELS)) { String procLabels = (String) args.get(LABELS); if (procLabels != null) { fProperties.put("pidLabel-" + field.getPid(), procLabels); } } else if (name.equals(PROCESS_SORT_INDEX)) { String sortIndex = (String) args.get(SORT_INDEX); if (sortIndex != null) { fProperties.put(name + '-' + field.getPid(), sortIndex); } } else if (name.equals(THREAD_NAME)) { String threadName = (String) args.get(NAME_ARG); fTidNames.put(field.getTid(), threadName); if (threadName != null) { fProperties.put("tid-" + field.getTid(), threadName); } } else if (name.equals(THREAD_SORT_INDEX)) { String sortIndex = (String) args.get(SORT_INDEX); if (sortIndex != null) { fProperties.put(name + '-' + field.getTid(), sortIndex); } } else { fProperties.put(name, String.valueOf(args)); } }</code><technical_language>switch (name)</technical_language>

Target:
private void parseMetadata(TraceEventField field) { Map<@NonNull String, @NonNull Object> args = field.getArgs(); String name = field.getName(); if (args == null) { return; } switch (name) { case PROCESS_NAME: String procName = (String) args.get(NAME_ARG); fPidNames.put(field.getPid(), procName); if (procName != null) { fProperties.put(PID_PREFIX + field.getPid(), procName); } break; case PROCESS_LABELS: String procLabels = (String) args.get(LABELS); if (procLabels != null) { fProperties.put(PID_LABEL_PREFIX + field.getPid(), procLabels); } break; case PROCESS_SORT_INDEX: String sortIndex = (String) args.get(SORT_INDEX); if (sortIndex != null) { fProperties.put(name + '-' + field.getPid(), sortIndex); } break; case THREAD_NAME: String threadName = (String) args.get(NAME_ARG); fTidNames.put(field.getTid(), threadName); if (threadName != null) { fProperties.put(TID_PREFIX + field.getTid(), threadName); } break; case THREAD_SORT_INDEX: sortIndex = (String) args.get(SORT_INDEX); if (sortIndex != null) { fProperties.put(name + '-' + field.getTid(), sortIndex); } break; default: fProperties.put(name, String.valueOf(args)); break; } }
Source:
<code>static private ByteBuffer copyByteBufferData(ByteBuffer buffer) { if (!buffer.isDirect() && !buffer.hasArray()) { int pos = buffer.position(); ByteBuffer bb = ByteBuffer.allocate(buffer.capacity()).put(buffer); bb.position(pos); <START> bb.limit(buffer.limit()); <END> buffer.position(pos); return bb; } return buffer; }</code><technical_language>buffer.remaining() allocating copy buffer. Set bb.position(0) touch bb.limit()</technical_language>

Target:
static private ByteBuffer copyByteBufferData(ByteBuffer buffer) { if(!buffer.isDirect() && !buffer.hasArray()) { int pos = buffer.position(); ByteBuffer bb = ByteBuffer.allocate(buffer.remaining()).put(buffer); bb.position(0); buffer.position(pos); return bb; } return buffer; }
Source:
<code><START> public DerivedStringProperty(String name, String defaultValue) { <END> super(name, defaultValue); deriveAndSet(); }</code><technical_language>constructor of DynamicStringProperty is package private. reason is want people DynamicPropertyFactory create instances DynamicPropertyFactory lazily install a default configuration source attach dynamic properties, if is explicitly installed. want this constructor package private provide a factory method in DynamicPropertyFactory. Or, try call DynamicPropertyFactory.getInstance() in a static block initialization of this class. === update === constructor of PropertyWrapper, calls DynamicProperty.getInstance() DynamicPropertyFactory.getInstance() is called. initialization of a configuration source is care is necessary force again. constructor remain public</technical_language>

Target:
public DerivedStringProperty(String name, String defaultValue) { delegate = DynamicPropertyFactory.getInstance().getStringProperty(name, defaultValue); deriveAndSet(); delegate.addCallback(new Runnable() { public void run() { propertyChangedInternal(); } }); }
Source:
<code>public static int getAutoplayType(@NonNull final Context context) { <START> final String defaultType = context.getString(R.string.autoplay_wifi_key); final String always = context.getString(R.string.autoplay_always_key); final String never = context.getString(R.string.autoplay_never_key); <END> final String type = getAutoplayType(context, defaultType); if (type.equals(always)) { return AUTOPLAY_TYPE_ALWAYS; } else if (type.equals(never)) { return AUTOPLAY_TYPE_NEVER; } else { return AUTOPLAY_TYPE_WIFI; } }</code><technical_language>move in in ifs below, needed. Also, Android Studio automatically shows of string, is problem unclearness</technical_language>

Target:
public static int getAutoplayType(@NonNull final Context context) { final String type = getAutoplayType(context, context.getString(R.string.autoplay_wifi_key)); if (type.equals(context.getString(R.string.autoplay_always_key))) { return AUTOPLAY_TYPE_ALWAYS; } else if (type.equals(context.getString(R.string.autoplay_never_key))) { return AUTOPLAY_TYPE_NEVER; } else { return AUTOPLAY_TYPE_WIFI; } }
Source:
<code>private void handleAddMetadata(Object arg) { if (arg instanceof List) { @SuppressWarnings("unchecked") List<Object> values = (List<Object>) arg; <START> if (values.size() == 3 && values.get(METADATA_SECTION) instanceof String <END> && values.get(METADATA_KEY) instanceof String) { if (values.get(METADATA_VALUE) instanceof String) { addMetadataString((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), (String) values.get(METADATA_VALUE)); } else if (values.get(METADATA_VALUE) instanceof Boolean) { addMetadataBoolean((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), (Boolean) values.get(METADATA_VALUE)); } else if (values.get(METADATA_VALUE) instanceof Number) { addMetadataDouble((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), ((Number) values.get(METADATA_VALUE)).doubleValue()); } } else if (values.size() == 2) { removeMetadata((String)values.get(METADATA_SECTION), (String)values.get(METADATA_KEY)); return; } } warn("ADD_METADATA object is invalid: " + arg); }</code><technical_language>I missing here, sense install signal handler soon possible, mark NDK installed, deliver pending reports? this current approach miss signals, breadcrumbs, metadata startup if cached reports, message simply discarded NativeBridge</technical_language>

Target:
private void handleAddMetadata(Object arg) { if (arg instanceof List) { @SuppressWarnings("unchecked") List<Object> values = (List<Object>) arg; if (values.size() == 3 && values.get(METADATA_SECTION) instanceof String && values.get(METADATA_KEY) instanceof String) { if (values.get(METADATA_VALUE) instanceof String) { addMetadataString((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), (String) values.get(METADATA_VALUE)); return; } else if (values.get(METADATA_VALUE) instanceof Boolean) { addMetadataBoolean((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), (Boolean) values.get(METADATA_VALUE)); return; } else if (values.get(METADATA_VALUE) instanceof Number) { addMetadataDouble((String) values.get(METADATA_SECTION), (String) values.get(METADATA_KEY), ((Number) values.get(METADATA_VALUE)).doubleValue()); return; } } else if (values.size() == 2) { removeMetadata((String)values.get(METADATA_SECTION), (String)values.get(METADATA_KEY)); return; } } warn("ADD_METADATA object is invalid: " + arg); }
Source:
<code>public void check(Message message, Topic topic) { if (ContentType.AVRO != topic.getContentType() || (ContentType.JSON == topic.getContentType() && !topic.isJsonToAvroDryRunEnabled())) { return; } BinaryDecoder binaryDecoder = DecoderFactory.get().binaryDecoder(message.getData(), null); try { <START> new GenericDatumReader<>(message.<Schema>getSchema().get().getSchema()).read(null, binaryDecoder); <END> } catch (Exception e) { throw new InvalidMessageException("Could not deserialize avro message with provided schema", ImmutableList.of(e.getMessage())); } }</code><technical_language>message.<Schema>getSchema().get().getSchema() awkward, more explicit naming</technical_language>

Target:
public void check(Message message, Topic topic) { if (ContentType.AVRO != topic.getContentType() || (ContentType.JSON == topic.getContentType() && !topic.isJsonToAvroDryRunEnabled())) { return; } BinaryDecoder binaryDecoder = DecoderFactory.get().binaryDecoder(message.getData(), null); try { new GenericDatumReader<>(message.<Schema>getSchema()).read(null, binaryDecoder); } catch (Exception e) { throw new InvalidMessageException("Could not deserialize avro message with provided schema", ImmutableList.of(e.getMessage())); } }
Source:
<code>String keyspace() { SetKeyspaceAttempt currentAttempt = targetKeyspace.get(); <START> return currentAttempt == null ? null : currentAttempt.keyspace; <END> }</code><technical_language>targetKeyspace set null if future fails, do that? reason is if set keyspace fails, want provide another opportunity set keyspace</technical_language>

Target:
String keyspace() { return targetKeyspace.get().keyspace; }
Source:
<code><START> public String show(Request request, Response response) throws IOException { <END> String environmentName = request.params("name"); EnvironmentConfig environmentConfig = fetchEntityFromConfig(environmentName); setEtagHeader(environmentConfig, response); return writerForTopLevelObject(request, response, outputWriter -> EnvironmentRepresenter.toJSON(outputWriter, environmentConfig)); }</code><technical_language>This section of code <LINK_0> bug. is fixed part of environments API v2 <LINK_1> PR</technical_language>

Target:
public String show(Request request, Response response) throws IOException { String environmentName = request.params("name"); EnvironmentConfig environmentConfig = fetchEntityFromConfig(environmentName); String etag = etagFor(environmentConfig); if (fresh(request, etag)) { return notModified(response); } setEtagHeader(environmentConfig, response); return writerForTopLevelObject(request, response, outputWriter -> EnvironmentRepresenter.toJSON(outputWriter, environmentConfig)); }
Source:
<code>public void addContextServiceInGUI() { String name = "EEContextService_" + RandomStringUtils.randomAlphanumeric(6); ConfigFragment config = page.getConfigFragment(); WizardWindow wizard = config.getResourceManager().addResource(); Editor editor = wizard.getEditor(); editor.text("name", name); editor.text(JNDI_NAME, JNDI_VALID); wizard.clickSave(); <START> Console.withBrowser(browser).dismissReloadRequiredWindowIfPresent(); <END> assertTrue("Context service should be present in table", config.resourceIsPresent(name)); ResourceAddress address = new ResourceAddress(eeAddress).add(EE_CHILD, name); verifier.verifyResource(address, true, 5000); removeEEChild(EE_CHILD, name); }</code><technical_language>In <LINK_0> merged WizardWindow.finishAndDismissReloadRequiredWindow() instead</technical_language>

Target:
public void addContextServiceInGUI() { String name = "EEContextService_" + RandomStringUtils.randomAlphanumeric(6); ConfigFragment config = page.getConfigFragment(); WizardWindow wizard = config.getResourceManager().addResource(); Editor editor = wizard.getEditor(); editor.text("name", name); editor.text(JNDI_NAME, JNDI_VALID); wizard.saveAndDismissReloadRequiredWindow(); assertTrue("Context service should be present in table", config.resourceIsPresent(name)); ResourceAddress address = new ResourceAddress(eeAddress).add(EE_CHILD, name); verifier.verifyResource(address, true, 5000); removeEEChild(EE_CHILD, name); }
Source:
<code>public boolean isTestingAccount(AccountAttributes account){ boolean isTestingAccount = false; <START> if(account.email.contains("tmt") || account.institute.contains("TEAMMATES test")){ <END> isTestingAccount = true; } return isTestingAccount; }</code><technical_language>This is test give false negatives. e.g. if a real user email 'tmt'. a longest string for cases</technical_language>

Target:
public boolean isTestingAccount(AccountAttributes account){ boolean isTestingAccount = false; if(account.email.endsWith(".tmt") || account.institute.contains("TEAMMATES Test Institute")){ isTestingAccount = true; } return isTestingAccount; }
Source:
<code>protected void validateApplications(ArtifactCoordinates domain, List<ArtifactCoordinates> applications) throws ValidationException { <START> if (applications == null || applications.size() == 0) { <END> throw new ValidationException("A domain bundle should contain at least one application"); } for (ArtifactCoordinates applicationCoordinates : applications) { validateApplication(domain, applicationCoordinates); } }</code><technical_language>application.size() -> application.isEmpty()</technical_language>

Target:
protected void validateApplications(ArtifactCoordinates domain, List<ArtifactCoordinates> applications) throws ValidationException { if (applications == null || applications.isEmpty()) { throw new ValidationException("A domain bundle should contain at least one application"); } for (ArtifactCoordinates applicationCoordinates : applications) { validateApplication(domain, applicationCoordinates); } }
Source:
<code>protected boolean isExceedSize(int tableRegionsCount, long sizeToCheck) { long sumSize = 0; for (HStore store : region.getStores()) { sumSize += store.getSize(); } if (sumSize > sizeToCheck) { LOG.debug("ShouldSplit because region size is big enough " + " size=" + StringUtils.humanSize(sumSize) + ", sizeToCheck=" + StringUtils.humanSize(sizeToCheck) + <START> ", regionsWithCommonTable=" + tableRegionsCount); <END> return true; } return false; }</code><technical_language>placeholders for arguments</technical_language>

Target:
protected boolean isExceedSize(int tableRegionsCount, long sizeToCheck) { long sumSize = 0; for (HStore store : region.getStores()) { sumSize += store.getSize(); } if (sumSize > sizeToCheck) { LOG.debug("ShouldSplit because region size is big enough " + "size={}, sizeToCheck={}, regionsWithCommonTable={}", StringUtils.humanSize(sumSize), StringUtils.humanSize(sizeToCheck), tableRegionsCount); return true; } return false; }
Source:
<code><START> public Builder time(final long timeToSet, final TimeUnit precisionToSet) { <END> Preconditions.checkNotNull(precisionToSet, "TimeUnit must not be null!"); this.time = timeToSet; this.precision = precisionToSet; return this; }</code><technical_language>Do format code in a manner</technical_language>

Target:
public Builder time(final long timeToSet, final TimeUnit precisionToSet) { this.time = timeToSet; if (null != precisionToSet) { this.precision = precisionToSet; } return this; }
Source:
<code>public HiveMetastoreClient createMetastoreClient() { List<HostAndPort> metastores = new ArrayList<>(addresses); <START> metastores.sort(Comparator.comparingLong(m -> concurrentMap.get(m).getBackoffDelayNanos())); <END> TException lastException = null; for (HostAndPort metastore : metastores) { try { HiveMetastoreClient client = new FailureAwareHiveMetaStoreClient(clientFactory.create(metastore), new ResponseHandle() { @Override public void success() { concurrentMap.get(metastore).success(); } @Override public void failed(TException e) { if (e.getCause() instanceof SocketTimeoutException) { concurrentMap.get(metastore).fail(); } } }); if (!isNullOrEmpty(metastoreUsername)) { client.setUGI(metastoreUsername); } return client; } catch (TException e) { lastException = e; } } throw new PrestoException(HIVE_METASTORE_ERROR, "Failed connecting to Hive metastore: " + addresses, lastException); }</code><technical_language>concurrentMap.get(m).getBackoffDelayNanos() is a function, return values subsequent calls. I this renders metastores.sort result indeterministic. Instead, pull for address once, sort.. do this in Steamy fashion</technical_language>

Target:
public HiveMetastoreClient createMetastoreClient() throws TException { TException lastException = null; for (HostAndPort metastore : addresses) { try { HiveMetastoreClient client = new FailureAwareHiveMetaStoreClient(clientFactory.create(metastore), new ResponseHandle() { @Override public void success() { } @Override public void failed(TException e) { if (!metastore.equals(addresses.getLast())) { addresses.remove(metastore); addresses.addLast(metastore); } } }); if (!isNullOrEmpty(metastoreUsername)) { client.setUGI(metastoreUsername); } return client; } catch (TException e) { lastException = e; } } throw new TException("Failed connecting to Hive metastore: " + addresses, lastException); }
Source:
<code>private static String adjustValueForExtension(String field, String value, ExtUUID queryEntity) { String result = value; if (queryEntity.equals(Authz.QueryEntity.PRINCIPAL)) { <START> if (!(field.equals("$DEPARTMENT") || field.equals("$TITLE"))) { <END> result = value.contains("@") ? value.substring(0, value.indexOf("@")) : value; } } return result; }</code><technical_language>need remove this search single field.... this applies query api... I do understand api specific code is here</technical_language>

Target:
private static String adjustValueForExtension(String field, String value, ExtUUID queryEntity) { String result = value; if (queryEntity.equals(Authz.QueryEntity.PRINCIPAL)) { if (!NON_ADJUSTABLE_FIELDS.contains(field)) { result = value.contains("@") ? value.substring(0, value.indexOf("@")) : value; } } return result; }
Source:
<code>public void readVector(ObjectColumnVector<T> vector, long current, long total) { int index = 0; for ( ; index < ColumnVector.DEFAULT_VECTOR_LENGTH; index++, current++) { if (current >= total) { ((ColumnVector) vector).setNumberOfValues(index); return; } T record = read(); if (shouldSkipCurrentRecord) { if (DEBUG) { LOG.debug("skipping record"); } vector.isNull[index] = true; } vector.values[index] = record; } <START> ((ColumnVector) vector).setNumberOfValues(index); <END> }</code><technical_language>do need cast here</technical_language>

Target:
protected void readVector(ObjectColumnVector<T> vector, long current, long total) { int index = 0; for ( ; index < ColumnVector.MAX_VECTOR_LENGTH; index++, current++) { if (current >= total) { ((ColumnVector) vector).setNumberOfValues(index); return; } T record = read(); if (shouldSkipCurrentRecord) { if (DEBUG) { LOG.debug("skipping record"); } vector.isNull[index] = true; } vector.values[index] = record; } ((ColumnVector) vector).setNumberOfValues(index); }
Source:
<code>public void taskSubmitted(Future<?> future, ManagedExecutorService managedExecutorService, Object o) { <START> } <END></code><technical_language>adding a debug give info long takes for a task submitted executed. helpful tuning pool</technical_language>

Target:
public void taskSubmitted(Future<?> future, ManagedExecutorService managedExecutorService, Object o) { log.debug("Task submitted: {}", Thread.currentThread().getName()); }
Source:
<code>public void addMiniTaskstoView() { List<Integer> taskIds = model.getTaskIds(); this.view.resetTaskList(); Color filterColor = MainView.getInstance().getFilterColor(); for (int i : taskIds) { MiniTaskView miniTaskView = taskMap.get(i).getMiniView(); <START> if (filterColor.equals(taskMap.get(i).getModel().getLabelColor()) <END> || filterColor.equals(MainView.getInstance() .getNoFilterColor())) { if (MainView.getInstance().getShowArchived()) { view.addTaskToView(miniTaskView); } else { if (!taskMap.get(i).getModel().getIsArchived()) { view.addTaskToView(miniTaskView); } } } } view.revalidate(); view.repaint(); }</code><technical_language>do filtering big if statement of unrelated function. a separate class for filtering, add filters modifying this function. this psuedocode: func addMiniTasksToView: for Task in tasks: if this.filter.matches(task): addMiniTask(task)</technical_language>

Target:
public void addMiniTaskstoView() { List<Integer> taskIds = model.getTaskIds(); Filter filter = new Filter(); this.view.resetTaskList(); for (int i : taskIds) { MiniTaskView miniTaskView = taskMap.get(i).getMiniView(); if (filter.matches(taskMap.get(i))) { if (MainView.getInstance().getShowArchived()) { view.addTaskToView(miniTaskView); } else { if (!taskMap.get(i).getModel().getIsArchived()) { view.addTaskToView(miniTaskView); } } } } view.revalidate(); view.repaint(); }
Source:
<code>public Subscriber<T> createSubscriber(final SubscriberWhiteboxVerification.WhiteboxSubscriberProbe<T> probe) { final Processor<T, T> processor = createIdentityProcessor(processorBufferSize); processor.subscribe( new Subscriber<T>() { private final Promise<Subscription> subs = new Promise<Subscription>(env); @Override public void onSubscribe(final Subscription subscription) { <START> if (env.debugEnabled()) <END> env.debug(String.format("whiteboxSubscriber::onSubscribe(%s)", subscription)); if (subs.isCompleted()) subscription.cancel(); probe.registerOnSubscribe(new SubscriberWhiteboxVerification.SubscriberPuppet() { @Override public void triggerRequest(long elements) { subscription.request(elements); } @Override public void signalCancel() { subscription.cancel(); } }); } @Override public void onNext(T element) { if (env.debugEnabled()) env.debug(String.format("whiteboxSubscriber::onNext(%s)", element)); probe.registerOnNext(element); } @Override public void onComplete() { if (env.debugEnabled()) env.debug("whiteboxSubscriber::onComplete()"); probe.registerOnComplete(); } @Override public void onError(Throwable cause) { if (env.debugEnabled()) env.debug(String.format("whiteboxSubscriber::onError(%s)", cause)); probe.registerOnError(cause); } }); return processor; }</code><technical_language>Needs curly braces adhere codebase style</technical_language>

Target:
public Subscriber<T> createSubscriber(final SubscriberWhiteboxVerification.WhiteboxSubscriberProbe<T> probe) { final Processor<T, T> processor = createIdentityProcessor(processorBufferSize); processor.subscribe( new Subscriber<T>() { private final Promise<Subscription> subs = new Promise<Subscription>(env); @Override public void onSubscribe(final Subscription subscription) { if (env.debugEnabled()) { env.debug(String.format("whiteboxSubscriber::onSubscribe(%s)", subscription)); } if (subs.isCompleted()) subscription.cancel(); probe.registerOnSubscribe(new SubscriberWhiteboxVerification.SubscriberPuppet() { @Override public void triggerRequest(long elements) { subscription.request(elements); } @Override public void signalCancel() { subscription.cancel(); } }); } @Override public void onNext(T element) { if (env.debugEnabled()) { env.debug(String.format("whiteboxSubscriber::onNext(%s)", element)); } probe.registerOnNext(element); } @Override public void onComplete() { if (env.debugEnabled()) { env.debug("whiteboxSubscriber::onComplete()"); } probe.registerOnComplete(); } @Override public void onError(Throwable cause) { if (env.debugEnabled()) { env.debug(String.format("whiteboxSubscriber::onError(%s)", cause)); } probe.registerOnError(cause); } }); return processor; }
Source:
<code>private GridClientAuthenticationRequest buildAuthRequest() { GridClientAuthenticationRequest req = new GridClientAuthenticationRequest(); <START> long reqId = reqIdCntr.getAndIncrement(); req.requestId(reqId); <END> req.clientId(clientId); req.credentials(credentials()); req.userAttributes(userAttrs); return req; }</code><technical_language>redundant if makeRequest is send request</technical_language>

Target:
private GridClientAuthenticationRequest buildAuthRequest() { GridClientAuthenticationRequest req = new GridClientAuthenticationRequest(); req.clientId(clientId); req.credentials(credentials()); req.userAttributes(userAttrs); return req; }
Source:
<code>public void cloudRecoveryTestForLargeBlob() throws Exception { int userMetaDataSize = 100; byte[] userMetadata = new byte[userMetaDataSize]; TestUtils.RANDOM.nextBytes(userMetadata); Map<BlobId, Integer> blobIdToSizeMap = new HashMap<>(); int blobSize = FOUR_MB_SZ; for (BlobId blobId : blobIds) { byte[] data = new byte[blobSize]; BlobProperties blobProperties = new BlobProperties(blobSize, "serviceid1", null, null, false, Utils.Infinite_Time, accountId, containerId, false, null); TestUtils.RANDOM.nextBytes(data); blobIdToSizeMap.put(blobId, blobSize); PutMessageFormatInputStream putMessageFormatInputStream = new PutMessageFormatInputStream(blobId, null, blobProperties, ByteBuffer.wrap(userMetadata), new ByteBufferInputStream(ByteBuffer.wrap(data)), blobSize); long time = System.currentTimeMillis(); CloudBlobMetadata cloudBlobMetadata = new CloudBlobMetadata(blobId, time, Utils.Infinite_Time, putMessageFormatInputStream.getSize(), CloudBlobMetadata.EncryptionOrigin.NONE); latchBasedInMemoryCloudDestination.uploadBlob(blobId, putMessageFormatInputStream.getSize(), cloudBlobMetadata, putMessageFormatInputStream); } assertTrue("Did not recover all blobs in 2 minutes", <START> latchBasedInMemoryCloudDestination.awaitDownload(2, TimeUnit.MINUTES)); <END> Thread.sleep(10000); testGetOnRecoveryNode(blobIdToSizeMap); }</code><technical_language>quick question: this read-after-write test is ensure blobs successfully uploaded cloud, right? 2 mins limit a long, change smaller number</technical_language>

Target:
public void cloudRecoveryTestForLargeBlob() throws Exception { int userMetaDataSize = 100; byte[] userMetadata = new byte[userMetaDataSize]; TestUtils.RANDOM.nextBytes(userMetadata); Map<BlobId, Integer> blobIdToSizeMap = new HashMap<>(); int blobSize = FOUR_MB_SZ; for (BlobId blobId : blobIds) { byte[] data = new byte[blobSize]; BlobProperties blobProperties = new BlobProperties(blobSize, "serviceid1", null, null, false, Utils.Infinite_Time, accountId, containerId, false, null); TestUtils.RANDOM.nextBytes(data); blobIdToSizeMap.put(blobId, blobSize); PutMessageFormatInputStream putMessageFormatInputStream = new PutMessageFormatInputStream(blobId, null, blobProperties, ByteBuffer.wrap(userMetadata), new ByteBufferInputStream(ByteBuffer.wrap(data)), blobSize); long time = System.currentTimeMillis(); CloudBlobMetadata cloudBlobMetadata = new CloudBlobMetadata(blobId, time, Utils.Infinite_Time, putMessageFormatInputStream.getSize(), CloudBlobMetadata.EncryptionOrigin.NONE); latchBasedInMemoryCloudDestination.uploadBlob(blobId, putMessageFormatInputStream.getSize(), cloudBlobMetadata, putMessageFormatInputStream); } assertTrue("Did not recover all blobs in 1 minute", latchBasedInMemoryCloudDestination.awaitDownload(1, TimeUnit.MINUTES)); Thread.sleep(10000); testGetOnRecoveryNode(blobIdToSizeMap); }
Source:
<code>public String getFunctionName() { <START> return m_name.toUpperCase(); <END> }</code><technical_language>I remember case for function names, right? CreateFunctionFromMethod.java, line 104</technical_language>

Target:
public String getFunctionName() { return m_name.toLowerCase(); }
Source:
<code>public void operateOn(StructuredRecord record) { Object val = record.get(fieldName); if (val == null) { return; } double value = ((Number) val).doubleValue(); sum1 += value; sum2 += Math.pow(value, 2); <START> stddev = Math.sqrt(count*sum2 - Math.pow(sum1, 2)); <END> count++; }</code><technical_language>do need compute stddev record? more efficient compute (and cache it?) used</technical_language>

Target:
public void operateOn(StructuredRecord record) { Object val = record.get(fieldName); if (val == null) { return; } double value = ((Number) val).doubleValue(); stats.push(value); }
Source:
<code>abstract PdlBuilder newline() throws IOException; abstract PdlBuilder indent() throws IOException; abstract PdlBuilder increaseIndent(); abstract PdlBuilder decreaseIndent(); abstract boolean writeDoc(String doc) throws IOException; PdlBuilder writeProperties(List<String> prefix, Map<String, Object> properties) throws IOException { for (Map.Entry<String, Object> entry : <START> properties.entrySet().stream() <END> .sorted(Map.Entry.comparingByKey()) .collect(Collectors.toList())) { String key = entry.getKey(); Object value = entry.getValue(); ArrayList<String> pathParts = new ArrayList<>(prefix); pathParts.add(key); if (value instanceof DataMap) { DataMap dm = (DataMap) value; if (dm.size() == 1) { writeProperties(pathParts, dm); } else { writeProperty(pathParts, dm); } } else if (Boolean.TRUE.equals(value)) { indent().write("@").writePath(pathParts).newline(); } else { writeProperty(pathParts, value); } } return this; }</code><technical_language>avoid packing this stream builder chain for-loop statement. construct list line, Stream#forEach</technical_language>

Target:
abstract PdlBuilder newline() throws IOException; abstract PdlBuilder indent() throws IOException; abstract PdlBuilder increaseIndent(); abstract PdlBuilder decreaseIndent(); abstract boolean writeDoc(String doc) throws IOException; PdlBuilder writeProperties(List<String> prefix, Map<String, Object> properties) throws IOException { List<Map.Entry<String, Object>> orderedProperties = properties.entrySet().stream() .sorted(Map.Entry.comparingByKey()) .collect(Collectors.toList()); for (Map.Entry<String, Object> entry : orderedProperties) { String key = entry.getKey(); Object value = entry.getValue(); ArrayList<String> pathParts = new ArrayList<>(prefix); pathParts.add(key); if (value instanceof DataMap) { DataMap dm = (DataMap) value; if (dm.size() == 1) { writeProperties(pathParts, dm); } else { writeProperty(pathParts, dm); } } else if (Boolean.TRUE.equals(value)) { indent().write("@").writePath(pathParts).newline(); } else { writeProperty(pathParts, value); } } return this; }