auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void forwardEvent(Event event) { if (forwardNodes && event.getNodeid() != null && event.getNodeid() != 0) { maybeUpdateNode(event.getNodeid()); } <START> boolean result = true; <END> if (filterEvents) { ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(eventFilter); try { result = exp.getValue(event, Boolean.class); } catch (Exception e) { LOG.error(" Event filter : didn't evaluate any result on Event {}", eventFilter, event.toStringSimple(), e); } } if (result) { sendRecord(() -> { final OpennmsModelProtos.Event mappedEvent = protobufMapper.toEvent(event).build(); LOG.debug("Sending event with UEI: {}", mappedEvent.getUei()); return new ProducerRecord<>(eventTopic, mappedEvent.getUei(), mappedEvent.toByteArray()); }); } else { LOG.debug("Event not forwarded based on filter ", event.toStringSimple(), eventFilter); return; } }</code><technical_language>rename this variable? shouldForwardEvent is a lot more indicative thanresult</technical_language>

Target:
private void forwardEvent(Event event) { if (forwardNodes && event.getNodeid() != null && event.getNodeid() != 0) { maybeUpdateNode(event.getNodeid()); } boolean shouldForwardEvent = true; if (filterEvents) { ExpressionParser parser = new SpelExpressionParser(); Expression exp = parser.parseExpression(eventFilter); try { shouldForwardEvent = exp.getValue(event, Boolean.class); } catch (Exception e) { LOG.error(" Event filter : didn't evaluate any result on Event {}", eventFilter, event.toStringSimple(), e); } } if (shouldForwardEvent) { sendRecord(() -> { final OpennmsModelProtos.Event mappedEvent = protobufMapper.toEvent(event).build(); LOG.debug("Sending event with UEI: {}", mappedEvent.getUei()); return new ProducerRecord<>(eventTopic, mappedEvent.getUei(), mappedEvent.toByteArray()); }); } else { if (LOG.isDebugEnabled()) { LOG.debug("Event not forwarded based on filter ", event.toStringSimple(), eventFilter); } return; } }
Source:
<code>protected boolean isEapProfile() { String profile = ServerProfileModel.getProfile(getServer()); if( "openshift3.eap".equals(profile)) { <START> return false; <END> } return true; }</code><technical_language>nope, return true</technical_language>

Target:
protected boolean isEapProfile() { String profile = ServerProfileModel.getProfile(getServer()); if( "openshift3.eap".equals(profile)) { return true; } return false; }
Source:
<code>public void convertsNegativeBigIntegersCorrectly() { int iterations = 100_000; int bitLength = LockServiceImpl.RANDOM_BIT_COUNT; for (int i = 0; i < iterations; i++) { <START> BigInteger randomBigInteger = new BigInteger(bitLength, RANDOM).multiply(new BigInteger("-1")); <END> LockRefreshToken lockRefreshToken = new LockRefreshToken(randomBigInteger, Long.MIN_VALUE); assertConversionFromAndToLegacyPreservesId(lockRefreshToken); } }</code><technical_language>nit: realise copied this over, new BigInteger(bitLength, RANDOM).negate() instead</technical_language>

Target:
public void convertsNegativeBigIntegersCorrectly() { int iterations = 100_000; int bitLength = LockServiceImpl.RANDOM_BIT_COUNT; for (int i = 0; i < iterations; i++) { BigInteger randomBigInteger = new BigInteger(bitLength, RANDOM).negate(); LockRefreshToken lockRefreshToken = new LockRefreshToken(randomBigInteger, Long.MIN_VALUE); assertConversionFromAndToLegacyPreservesId(lockRefreshToken); } }
Source:
<code>public Object processInvocation(final InterceptorContext context) throws Exception { final StartupCountdown.Frame frame = countdown.enter(); try { Object proceed = context.proceed(); countdown.countDown(); return proceed; <START> } catch (Exception e) { throw e; <END> } finally { StartupCountdown.restore(frame); } }</code><technical_language>leave this part off. suggestion</technical_language>

Target:
public Object processInvocation(final InterceptorContext context) throws Exception { final StartupCountdown.Frame frame = countdown.enter(); try { Object proceed = context.proceed(); countdown.countDown(); return proceed; } finally { StartupCountdown.restore(frame); } }
Source:
<code>private SystemTable checkAndGetTable(ConnectorSession session, ConnectorTableHandle tableHandle) { SystemTableHandle systemTableHandle = (SystemTableHandle) tableHandle; Optional<SystemTable> table = tables.getSystemTable(session, systemTableHandle.getSchemaTableName()); <START> checkArgument(table.isPresent()); <END> return table.get(); }</code><technical_language>orElseThrow</technical_language>

Target:
private SystemTable checkAndGetTable(ConnectorSession session, ConnectorTableHandle tableHandle) { SystemTableHandle systemTableHandle = (SystemTableHandle) tableHandle; return tables.getSystemTable(session, systemTableHandle.getSchemaTableName()) .orElseThrow(() -> new PrestoException(NOT_FOUND, format("Table %s not found", systemTableHandle.getSchemaTableName()))); }
Source:
<code>public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations, Moshi moshi) { if (Types.getRawType(type) != baseType || !annotations.isEmpty()) { return null; } int size = labelToType.size(); Map<String, JsonAdapter<Object>> labelToAdapter = new LinkedHashMap<>(size); Map<Type, String> typeToLabel = new LinkedHashMap<>(size); for (Map.Entry<String, Type> entry : labelToType.entrySet()) { String label = entry.getKey(); Type typeValue = entry.getValue(); typeToLabel.put(typeValue, label); labelToAdapter.put(label, moshi.adapter(typeValue)); } JsonAdapter<Object> objectJsonAdapter; if (baseType == Object.class) { <START> objectJsonAdapter = moshi.nextAdapter(this, Object.class, Util.NO_ANNOTATIONS); <END> } else { objectJsonAdapter = moshi.adapter(Object.class); } return new RuntimeJsonAdapter(labelKey, labelToAdapter, typeToLabel, objectJsonAdapter) .nullSafe(); }</code><technical_language>.. worth a test confirms Object works base type</technical_language>

Target:
public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations, Moshi moshi) { if (Types.getRawType(type) != baseType || !annotations.isEmpty()) { return null; } int size = labelToType.size(); Map<String, JsonAdapter<Object>> labelToAdapter = new LinkedHashMap<>(size); Map<Type, String> typeToLabel = new LinkedHashMap<>(size); for (Map.Entry<String, Type> entry : labelToType.entrySet()) { String label = entry.getKey(); Type typeValue = entry.getValue(); typeToLabel.put(typeValue, label); labelToAdapter.put(label, moshi.adapter(typeValue)); } JsonAdapter<Object> objectJsonAdapter = moshi.adapter(Object.class); return new RuntimeJsonAdapter(labelKey, labelToAdapter, typeToLabel, objectJsonAdapter).nullSafe(); }
Source:
<code>public Map<String, Collection<SearchResult>> search(SearchContext context, String query, Collection<String> sites, Collection<String> types, int offset, int limit, String sort, String order) { String fuzzySyntax = getFuzzySyntax(); query = replaceSpecialCharacters(query); HashMap<String, ArrayList<String>> terms = parse(query); query = repeat("\"%s\"", terms.get("quoted"), " ") + " " + repeat("%s" + fuzzySyntax, terms.get("single"), " "); Map<String, Collection<SearchResult>> results = new HashMap<String, Collection<SearchResult>>(); <START> if(query==null || StringUtils.isEmpty(query.trim())) return results; <END> if(null==types || types.isEmpty()) return results; List<String> enabledTypes = UnifiedSearchService.getEnabledSearchTypes(); for(SearchServiceConnector connector:this.getConnectors()){ if(!enabledTypes.contains(connector.getSearchType())) continue; if(!types.contains("all") && !types.contains(connector.getSearchType())) continue; LOG.debug("\n[UNIFIED SEARCH]: connector = " + connector.getClass().getSimpleName()); try { results.put(connector.getSearchType(), connector.search(context, query, sites, offset, limit, sort, order)); } catch (Exception e) { LOG.error(e.getMessage(), e); continue; } } return results; }</code><technical_language>StringUtils.isEmpty() is enough in this case</technical_language>

Target:
public Map<String, Collection<SearchResult>> search(SearchContext context, String query, Collection<String> sites, Collection<String> types, int offset, int limit, String sort, String order) { String fuzzySyntax = getFuzzySyntax(); query = replaceSpecialCharacters(query); HashMap<String, ArrayList<String>> terms = parse(query); query = repeat("\"%s\"", terms.get("quoted"), " ") + " " + repeat("%s" + fuzzySyntax, terms.get("single"), " "); Map<String, Collection<SearchResult>> results = new HashMap<String, Collection<SearchResult>>(); if(StringUtils.isBlank(query)) return results; if(null==types || types.isEmpty()) return results; List<String> enabledTypes = UnifiedSearchService.getEnabledSearchTypes(); for(SearchServiceConnector connector:this.getConnectors()){ if(!enabledTypes.contains(connector.getSearchType())) continue; if(!types.contains("all") && !types.contains(connector.getSearchType())) continue; LOG.debug("\n[UNIFIED SEARCH]: connector = " + connector.getClass().getSimpleName()); try { results.put(connector.getSearchType(), connector.search(context, query, sites, offset, limit, sort, order)); } catch (Exception e) { LOG.error(e.getMessage(), e); continue; } } return results; }
Source:
<code>BufferAndBacklog pollBuffer() { synchronized (buffers) { Buffer buffer = null; if (buffers.isEmpty()) { flushRequested = false; } while (!buffers.isEmpty()) { BufferConsumer bufferConsumer = buffers.peek(); buffer = bufferConsumer.build(); checkState(bufferConsumer.isFinished() || buffers.size() == 1, "When there are multiple buffers, an unfinished bufferConsumer can not be at the head of the buffers queue."); if (buffers.size() == 1) { flushRequested = false; } if (bufferConsumer.isFinished()) { buffers.pop().close(); decreaseBuffersInBacklogUnsafe(bufferConsumer.isBuffer()); } if (buffer.readableBytes() > 0) { break; } buffer.recycleBuffer(); buffer = null; if (!bufferConsumer.isFinished()) { break; } } if (buffer == null) { dataAvailableNotified = false; return null; } boolean isAvailable = isAvailableUnsafe(); dataAvailableNotified = isAvailable; updateStatistics(buffer); return new BufferAndBacklog( buffer, isAvailable, <START> getBuffersInBacklog(), <END> nextBufferIsEventUnsafe()); } }</code><technical_language>I guess path of buffer == null caused duplicated notification for LocalInputChannel. If fixed duplicated notification in this PR, remove this path for simple</technical_language>

Target:
BufferAndBacklog pollBuffer() { synchronized (buffers) { if (isBlockedByCheckpoint) { return null; } Buffer buffer = null; if (buffers.isEmpty()) { flushRequested = false; } while (!buffers.isEmpty()) { BufferConsumer bufferConsumer = buffers.peek(); buffer = bufferConsumer.build(); checkState(bufferConsumer.isFinished() || buffers.size() == 1, "When there are multiple buffers, an unfinished bufferConsumer can not be at the head of the buffers queue."); if (buffers.size() == 1) { flushRequested = false; } if (bufferConsumer.isFinished()) { buffers.pop().close(); decreaseBuffersInBacklogUnsafe(bufferConsumer.isBuffer()); } if (buffer.readableBytes() > 0) { break; } buffer.recycleBuffer(); buffer = null; if (!bufferConsumer.isFinished()) { break; } } if (buffer == null) { dataAvailableNotified = false; return null; } if (buffer.getDataType().isBlockingUpstream()) { isBlockedByCheckpoint = true; } boolean isAvailable = isDataAvailableUnsafe(); dataAvailableNotified = isAvailable; updateStatistics(buffer); return new BufferAndBacklog( buffer, isAvailable, getBuffersInBacklog(), isEventAvailableUnsafe()); } }
Source:
<code>private Command buildDeleteDiagramElement() { Command cmd = UnexecutableCommand.INSTANCE; if (permissionAuthority.canEditInstance(diagramElement) && permissionAuthority.canEditInstance(diagramElement.eContainer())) { boolean semanticElementCanBeDeleted = true; final Set<EObject> allSemanticElements = getSemanticElementsToDestroy(diagramElement); for (final EObject semantic : allSemanticElements) { final EObject container = semantic.eContainer(); if (!permissionAuthority.canDeleteInstance(semantic) || (container != null && !permissionAuthority.canEditInstance(container))) { semanticElementCanBeDeleted = false; } } if (semanticElementCanBeDeleted) { final DCommand result = createEnclosingCommand(); final DDiagram foundDiagram = SiriusUtil.findDiagram(diagramElement); setTool(); if (tool != null) { addDeleteDiagramElementFromTool(result); EObject rootContainer = null; final boolean automaticRefresh = Platform.getPreferencesService().getBoolean(SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null); if (automaticRefresh) { <START> addRefreshTask(diagramElement, result, tool); <END> rootContainer = EcoreUtil.getRootContainer(diagramElement); } else { EObjectQuery eObjectQuery = new EObjectQuery(diagramElement); DRepresentation dRepresentation = eObjectQuery.getRepresentation().get(); rootContainer = dRepresentation; } cmd = new NoNullResourceCommand(result, diagramElement); } else { cmd = buildDeleteDiagramElementCommandWithoutTool(result, foundDiagram); } } } return cmd; }</code><technical_language>This refresh task added in manual auto refresh cases. Some dead code removed: rootContainer is used</technical_language>

Target:
private Command buildDeleteDiagramElement() { Command cmd = UnexecutableCommand.INSTANCE; if (permissionAuthority.canEditInstance(diagramElement) && permissionAuthority.canEditInstance(diagramElement.eContainer())) { boolean semanticElementCanBeDeleted = true; final Set<EObject> allSemanticElements = getSemanticElementsToDestroy(diagramElement); for (final EObject semantic : allSemanticElements) { final EObject container = semantic.eContainer(); if (!permissionAuthority.canDeleteInstance(semantic) || (container != null && !permissionAuthority.canEditInstance(container))) { semanticElementCanBeDeleted = false; } } if (semanticElementCanBeDeleted) { final DCommand result = createEnclosingCommand(); final DDiagram foundDiagram = SiriusUtil.findDiagram(diagramElement); setTool(); if (tool != null) { addDeleteDiagramElementFromTool(result); addRefreshTask(diagramElement, result, tool); cmd = new NoNullResourceCommand(result, diagramElement); } else { cmd = buildDeleteDiagramElementCommandWithoutTool(result, foundDiagram); } } } return cmd; }
Source:
<code>public Object getEntityInstance() { for ( Object obj : projection ) { if ( clazz.isInstance( obj ) ) { <START> return obj; <END> } } return null; }</code><technical_language>I store instance a field loop projections instanceof attempts? easily store EntityInstance populateWithEntityInstance</technical_language>

Target:
public Object getEntityInstance() { return entityInstance; }
Source:
<code>public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { Locale userLocale = (Locale) request.getAttribute(LocaleFilter.LOCALE); if (userLocale == null) { log.warn("Detected Locale is null, setting to default: " + LocaleFilter.DEFAULT_LOCALE); userLocale = LocaleFilter.DEFAULT_LOCALE; } List<BrandingTheme> brandingThemes = brandingManager.getBrandingThemes(); request.setAttribute(THEMES_KEY, brandingThemes); <START> ResourceBundle bundle = ResourceBundle.getBundle("BrandingBundle", userLocale, <END> BrandingResourceBundle.getBrandingControl(BLANK)); Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle, userLocale)); chain.doFilter(request, response); }</code><technical_language>"BrandingBundle" a constant</technical_language>

Target:
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { Locale userLocale = (Locale) request.getAttribute(LocaleFilter.LOCALE); if (userLocale == null) { log.warn("Detected Locale is null, setting to default: " + LocaleFilter.DEFAULT_LOCALE); userLocale = LocaleFilter.DEFAULT_LOCALE; } List<BrandingTheme> brandingThemes = brandingManager.getBrandingThemes(); request.setAttribute(THEMES_KEY, brandingThemes); ResourceBundle bundle = ResourceBundle.getBundle(BRANDING_BASE_NAME, userLocale, BrandingResourceBundle.getBrandingControl(BLANK)); Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle, userLocale)); chain.doFilter(request, response); }
Source:
<code>private boolean identifiedByName(Class<?> type) { <START> return Map.class.equals(type) || byte[].class.equals(type); <END> }</code><technical_language>I this Map.class.equals(type) is a remnant a previous implementation removed</technical_language>

Target:
private boolean identifiedByName(Class<?> type) { return byte[].class.equals(type); }
Source:
<code>public boolean addVertex(final V v) { <START> if (adjacent.put(v, new HashSet<>()) == null) { <END> inDegrees.put(v, 0); rootVertices.add(v); return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } }</code><technical_language>This code creates a HashSet object v exists</technical_language>

Target:
public boolean addVertex(final V v) { if (!adjacent.containsKey(v)) { adjacent.put(v, new HashSet<>()); inDegrees.put(v, 0); rootVertices.add(v); return true; } else { LOG.log(Level.WARNING, "The vertex {0} already exists", new Object[]{v}); return false; } }
Source:
<code>private SimpleTree getTree() { JComponent component = myToolWindow.getContentManager().getComponent(); return myRobot.finder().findByType(component, <START> SimpleTree.class); <END> }</code><technical_language>This JTree fixture expects, exposing internals test</technical_language>

Target:
private JTree getTree() { JComponent component = myToolWindow.getContentManager().getComponent(); return myRobot.finder().findByType(component, JTree.class); }
Source:
<code>private void cleanUnusedFilesFromCache() { <START> try (Stream<Path> pathElements = Files.walk(this.cacheDirectory)) { <END> pathElements .filter(Files::isRegularFile) .forEach(this::deleteCachedFileIfNeeded); } catch (IOException e) { log.error("Cleaning featured mod files cache failed", e); } }</code><technical_language>this is obsolete</technical_language>

Target:
private void cleanUnusedFilesFromCache() { try (Stream<Path> pathElements = Files.walk(preferencesService.getFeaturedModCachePath())) { pathElements .filter(Files::isRegularFile) .forEach(this::deleteCachedFileIfNeeded); } catch (IOException e) { log.error("Cleaning featured mod files cache failed", e); } }
Source:
<code>private ParticipantObjectIdentificationType createQueryParticipantObjectIdentification(String queryId, String hcid) { ParticipantObjectIdentificationType participantObject = createParticipantObject( DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_TYPE_CODE_SYSTEM, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_TYPE_CODE_ROLE, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_CODE, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_CODE_SYSTEM, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_DISPLAY_NAME); if (NullChecker.isNotNullish(queryId)) { participantObject.setParticipantObjectID(queryId); } TypeValuePairType encoding = new TypeValuePairType(); encoding.setType(DocQueryAuditTransformsConstants.QUERY_ENCODING_TYPE); encoding.setValue(DocQueryAuditTransformsConstants.UTF_8.getBytes()); participantObject.getParticipantObjectDetail().add(encoding); if (NullChecker.isNotNullish(hcid)) { TypeValuePairType homeCommunityTypeValue = new TypeValuePairType(); homeCommunityTypeValue.setType(DocQueryAuditTransformsConstants.HOME_COMMUNITY_ID); homeCommunityTypeValue.setValue(hcid.getBytes()); participantObject.getParticipantObjectDetail().add(homeCommunityTypeValue); <START> } <END> return participantObject; }</code><technical_language>refactor setting values for ParticipantObject TypeValuePairType a separate method passing arguments method</technical_language>

Target:
private ParticipantObjectIdentificationType createQueryParticipantObjectIdentification(String queryId, String hcid) { ParticipantObjectIdentificationType participantObject = createParticipantObject( DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_TYPE_CODE_SYSTEM, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_TYPE_CODE_ROLE, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_CODE, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_CODE_SYSTEM, DocQueryAuditTransformsConstants.PARTICIPANT_QUERY_OBJ_ID_TYPE_DISPLAY_NAME); if (NullChecker.isNotNullish(queryId)) { participantObject.setParticipantObjectID(queryId); } participantObject.getParticipantObjectDetail().add(getTypeValuePair( DocQueryAuditTransformsConstants.QUERY_ENCODING_TYPE, DocQueryAuditTransformsConstants.UTF_8.getBytes())); if (NullChecker.isNotNullish(hcid)) { participantObject.getParticipantObjectDetail().add(getTypeValuePair( DocQueryAuditTransformsConstants.HOME_COMMUNITY_ID, hcid.getBytes())); } return participantObject; }
Source:
<code>public <T> Model<T> get(Class<T> type, @CheckForNull Class<?> propertyOwner, @Nullable String property) { <START> if (type.getAnnotation(ExportedBean.class) == null) { <END> throw new NotExportableException(type); } return getOrNull(type, propertyOwner, property); }</code><technical_language>I meant write java Model<T> model = getOrNull(type, propertyOwner, property); if (model == null) { throw new NotExportableException(type); } return model;</technical_language>

Target:
public <T> Model<T> get(Class<T> type, @CheckForNull Class<?> propertyOwner, @Nullable String property) throws NotExportableException { Model<T> model = getOrNull(type, propertyOwner, property); if (model == null) { throw new NotExportableException(type); } return model; }
Source:
<code>public ServiceResponse<List<PatientEncounterItem>> returnCurrentDayPatientEncounters() { ServiceResponse<List<PatientEncounterItem>> response = new ServiceResponse<>(); List<PatientEncounterItem> patientEncounterItems = new ArrayList<>(); ExpressionList<PatientEncounter> query = QueryProvider.getPatientEncounterQuery() .where() <START> .ge("id",0); <END> try{ List<PatientItem> patientItems=null; List<? extends IPatientEncounter> patient = patientEncounterRepository.find(query); for (IPatientEncounter patient1 : patient) { DateTime triageDate= patient1.getDateOfTriageVisit(); Date tDate=triageDate.toDate(); String triagePatientDate=dateUtils.getFriendlyDate(tDate); Date todayDate=DateTime.now().toDate(); String currentDate=dateUtils.getFriendlyDate(todayDate); if(triagePatientDate.equalsIgnoreCase(currentDate)) { patientEncounterItems.add(itemModelMapper.createPatientEncounterItem(patient1)); } } response.setResponseObject(patientEncounterItems); } catch (Exception ex) { response.addError("", ex.getMessage()); } return response; }</code><technical_language>database grab patient encounters looping check if is equal current date. In a real system this pull 5,500 encounters today issue, performance impacted number of encounters grow able logic dates reduce number of encounters fetched database. Instead of .ge("id",0), able do like: .where() .ge("date_of_triage_visit", 12:00:00am today) .le("date_of_triage_visit", 12:00:00am tomorrow) automatically get encounters for for loop</technical_language>

Target:
public ServiceResponse<List<PatientEncounterItem>> returnCurrentDayPatientEncounters() { ServiceResponse<List<PatientEncounterItem>> response = new ServiceResponse<>(); List<PatientEncounterItem> patientEncounterItems = new ArrayList<>(); DateTime today= DateTime.now(); today=today.withTimeAtStartOfDay(); DateTime tommorrow=today; tommorrow=tommorrow.plusDays(1); ExpressionList<PatientEncounter> query = QueryProvider.getPatientEncounterQuery() .where() .ge("date_of_triage_visit", today) .le("date_of_triage_visit", tommorrow); try{ List<PatientItem> patientItems=null; List<? extends IPatientEncounter> patient = patientEncounterRepository.find(query); for (IPatientEncounter patient1 : patient) { patientEncounterItems.add(itemModelMapper.createPatientEncounterItem(patient1)); } response.setResponseObject(patientEncounterItems); } catch (Exception ex) { response.addError("", ex.getMessage()); } return response; }
Source:
<code>private Set<Capability> searchRepository(Repository osgiRepo, String pkg) { Requirement req = buildRequirement(pkg); Set<Capability> resultSet = new LinkedHashSet<>(); Map<Requirement, Collection<Capability>> providers = osgiRepo.findProviders(Collections.singleton(req)); for (Collection<Capability> values : providers.values()) { if (values == null) { continue; } for (Capability providerCap : values) { <START> resultSet.add(providerCap); <END> } } return resultSet; }</code><technical_language>body of this for loop simplified resultSet.addAll(values). [findProviders() spec](<LINK_0>, values null here</technical_language>

Target:
private Collection<Capability> searchRepository(Repository osgiRepo, String pkg) { final Requirement req = buildRequirement(pkg); Map<Requirement, Collection<Capability>> providers = osgiRepo.findProviders(Collections.singleton(req)); return providers.get(req); }
Source:
<code>public CompletableFuture<Set<String>> keySet() { return applyAll(service -> service.keySet()) <START> .thenApply(results -> results.reduce((s1, s2) -> <END> ImmutableSet.<String>builder().addAll(s1).addAll(s2).build()).orElse(ImmutableSet.of())); }</code><technical_language>collect more sense here</technical_language>

Target:
public CompletableFuture<Set<String>> keySet() { return applyAll(service -> service.keySet()) .thenApply(results -> results.flatMap(Collection::stream).collect(Collectors.toSet())); }
Source:
<code>private List<String> makeCleanupList(String entityId, List<Statement> data) { Set<String> values = new HashSet<>(); Set<String> refs = new HashSet<>(); munger.mungeWithValues(entityId, data, <START> rdfRepository.getValues(Collections.singletonList(uris.entity() <END> + entityId)), rdfRepository.getRefs(Collections.singletonList(uris.entity() + entityId)), values, refs, null, null); List<String> changeList = new ArrayList<>(); changeList.addAll(values); changeList.addAll(refs); return changeList; }</code><technical_language>static import</technical_language>

Target:
private List<String> makeCleanupList(String entityId, List<Statement> data) { Set<String> values = new HashSet<>(); Set<String> refs = new HashSet<>(); munger.mungeWithValues(entityId, data, rdfRepository.getValues(singletonList(uris.entity() + entityId)), rdfRepository.getRefs(singletonList(uris.entity() + entityId)), values, refs, null, null); List<String> changeList = new ArrayList<>(); changeList.addAll(values); changeList.addAll(refs); return changeList; }
Source:
<code>public CustomTxtParserWizard() { super(); <START> setWindowTitle(Messages.CustomTxtParserInputWizardPage_windowTitle); <END> }</code><technical_language>this in ctor call this(null) here</technical_language>

Target:
public CustomTxtParserWizard() { this(null); }
Source:
<code>public String evaluate(Object obj, String expression) { String result = ""; try { scriptEngine.put(getType(), obj); result = String.valueOf(scriptEngine.eval(expression)); } catch (Exception ignored) <START> return result; <END> }</code><technical_language>sense change default of result variable N/A similar? more sense for users a bunch of empty lines</technical_language>

Target:
public String evaluate(Object obj, String expression) { String result = ""; try { scriptEngine.put(getType(), obj); result = String.valueOf(scriptEngine.eval(expression)); } catch (Exception exception) { LOGGER.warn("Unable to evaluate expression %s due to: %s. Please check your shell confugration", expression, exception.getMessage()); result = "<evalution error - see log>"; } return result; }
Source:
<code>private void processSeenContent(OwlTelescopeReporter telescope) { Iterable<ModelWithPayload<Content>> brands = Iterables.filter(seenContent.values(), IS_BRAND::test); for (ModelWithPayload<Content> container : brands) { checkAndWriteSeenContent(container, telescope); } Iterable<ModelWithPayload<Content>> series = Iterables.filter(seenContent.values(), IS_SERIES::test); for (ModelWithPayload<Content> container : series) { checkAndWriteSeenContent(container, telescope); <START> } <END> Iterable<ModelWithPayload<Content>> notContainers = seenContent.values() .stream() .filter(and(not(IS_BRAND::test), not(IS_SERIES::test))::apply) .collect(Collectors.toList()); for (ModelWithPayload<Content> notContainer : notContainers) { checkAndWriteSeenContent(notContainer, telescope); } }</code><technical_language>change lambdas. do fly ask there</technical_language>

Target:
private void processSeenContent(OwlTelescopeReporter telescope) { List<ModelWithPayload<Content>> brands = new ArrayList<>(); List<ModelWithPayload<Content>> series = new ArrayList<>(); List<ModelWithPayload<Content>> notContainers = new ArrayList<>(); for (ModelWithPayload<Content> container : seenContent.values()){ if (container.getModel() instanceof Brand){ brands.add(container); } else if (container.getModel() instanceof Series){ series.add(container); } else { notContainers.add(container); } } brands.stream().forEach(c -> checkAndWriteSeenContent(c, telescope)); series.stream().forEach(c -> checkAndWriteSeenContent(c, telescope)); notContainers.stream().forEach(c -> checkAndWriteSeenContent(c, telescope)); }
Source:
<code>public Object auditLogGeneration(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature(); Method method = signature.getMethod(); GenerateAuditLog auditLogAnnotation = method.getAnnotation(GenerateAuditLog.class); Object responseObject = proceedingJoinPoint.proceed(); if (auditLogAnnotation.scope().in(ALL, SUCCESS)) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getResponse(); ResponseStatus responseStatusAnnotation = method.getAnnotation(ResponseStatus.class); int responseCode = response != null ? response.getStatus() : 0; if (responseStatusAnnotation != null) { responseCode = responseStatusAnnotation.value().value(); } Object auditLogResponseObject = responseObject; if (responseObject instanceof ResponseEntity) { responseCode = ((ResponseEntity) responseObject).getStatusCode().value(); auditLogResponseObject = ((ResponseEntity) responseObject).getBody(); } <START> if (responseCode == 0 || HttpStatus.valueOf(responseCode).is2xxSuccessful() <END> || HttpStatus.valueOf(responseCode).is3xxRedirection()) { auditLogSender.sendAuditLog(request, extractRequestBody(proceedingJoinPoint), responseCode, auditLogResponseObject, auditLogAnnotation); } } return responseObject; }</code><technical_language>simpler write !HttpStatus.valueOf(responseCode).isError()</technical_language>

Target:
public Object auditLogGeneration(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { MethodSignature signature = (MethodSignature) proceedingJoinPoint.getSignature(); Method method = signature.getMethod(); GenerateAuditLog auditLogAnnotation = method.getAnnotation(GenerateAuditLog.class); Object responseObject = proceedingJoinPoint.proceed(); if (auditLogAnnotation.scope().in(ALL, SUCCESS)) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getResponse(); ResponseStatus responseStatusAnnotation = method.getAnnotation(ResponseStatus.class); int responseCode = response != null ? response.getStatus() : 0; if (responseStatusAnnotation != null) { responseCode = responseStatusAnnotation.value().value(); } Object auditLogResponseObject = responseObject; if (responseObject instanceof ResponseEntity) { responseCode = ((ResponseEntity) responseObject).getStatusCode().value(); auditLogResponseObject = ((ResponseEntity) responseObject).getBody(); } if (responseCode == 0 || !HttpStatus.valueOf(responseCode).isError()) { auditLogSender.sendAuditLog(request, extractRequestBody(proceedingJoinPoint), responseCode, auditLogResponseObject, auditLogAnnotation); } } return responseObject; }
Source:
<code><START> PRED_change_branch_1(Term a1, Operation n) { <END> arg1 = a1; cont = n; }</code><technical_language>public</technical_language>

Target:
public PRED_change_branch_1(Term a1, Operation n) { arg1 = a1; cont = n; }
Source:
<code>public DeviceFunction getDeviceFunction() { <START> return DeviceFunction.GET_CONFIGURATION; <END> }</code><technical_language>SCAN_MBUS_CHANNELS</technical_language>

Target:
public DeviceFunction getDeviceFunction() { return DeviceFunction.SCAN_MBUS_CHANNELS; }
Source:
<code><START> CommandCenterTab(CampaignGUI gui, String name) { <END> super(gui, name); MekHQ.registerHandler(this); }</code><technical_language>suggestion public CommandCenterTab(CampaignGUI gui, String name) {</technical_language>

Target:
public CommandCenterTab(CampaignGUI gui, String name) { super(gui, name); MekHQ.registerHandler(this); }
Source:
<code>public synchronized String getMemento() throws CoreException { Document doc = DebugPlugin.newDocument(); Element rootNode = doc.createElement(DIRECTOR_ROOT_NODE); doc.appendChild(rootNode); Element pathNode = doc.createElement(CONTAINERS_NODE); if(fDuplicates) { pathNode.setAttribute(DUPLICATES_ATTR, "true"); } else { pathNode.setAttribute(DUPLICATES_ATTR, "false"); } rootNode.appendChild(pathNode); if(fSourceContainers !=null){ for (ISourceContainer <START> fSourceContainer : <END> fSourceContainers) { Element node = doc.createElement(CONTAINER_NODE); ISourceContainer container = fSourceContainer; ISourceContainerType type = container.getType(); node.setAttribute(CONTAINER_TYPE_ATTR, type.getId()); node.setAttribute(CONTAINER_MEMENTO_ATTR, type.getMemento(container)); pathNode.appendChild(node); } } return DebugPlugin.serializeDocument(doc); }</code><technical_language>rename</technical_language>

Target:
public synchronized String getMemento() throws CoreException { Document doc = DebugPlugin.newDocument(); Element rootNode = doc.createElement(DIRECTOR_ROOT_NODE); doc.appendChild(rootNode); Element pathNode = doc.createElement(CONTAINERS_NODE); if(fDuplicates) { pathNode.setAttribute(DUPLICATES_ATTR, "true"); } else { pathNode.setAttribute(DUPLICATES_ATTR, "false"); } rootNode.appendChild(pathNode); if(fSourceContainers !=null){ for (ISourceContainer container : fSourceContainers) { Element node = doc.createElement(CONTAINER_NODE); ISourceContainerType type = container.getType(); node.setAttribute(CONTAINER_TYPE_ATTR, type.getId()); node.setAttribute(CONTAINER_MEMENTO_ATTR, type.getMemento(container)); pathNode.appendChild(node); } } return DebugPlugin.serializeDocument(doc); }
Source:
<code>public static void laconic(org.slf4j.Logger logger, Level level, String message, int max) { int messageCount = getAndIncrementMessageCount(message); <START> if (messageCount <= max) { <END> if (level.isInRange(Level.ERROR, Level.ALL)) { logger.error(message); } else if (level == Level.WARN) { logger.warn(message); } else if (level == Level.INFO) { logger.info(message); } else if (level == Level.DEBUG) { logger.debug(message); } } }</code><technical_language>previously incremented count if maximum (ie. check increment) increment count - in theory this risks overflowing integer, in practice issue</technical_language>

Target:
public static void laconic(org.slf4j.Logger logger, Level level, String message, int max) { if (shouldLog(message, max)) { if (level.isInRange(Level.ERROR, Level.ALL)) { logger.error(message); } else if (level == Level.WARN) { logger.warn(message); } else if (level == Level.INFO) { logger.info(message); } else if (level == Level.DEBUG) { logger.debug(message); } } }
Source:
<code>void suspendAll() throws InterruptedException { for (ServiceTermination termination : terminations) { LOG.info("Suspending down '{}' service", termination.getServiceName()); eventService.publish(new SuspendingSystemServiceEvent(termination.getServiceName())); try { termination.suspend(); } catch (UnsupportedOperationException e) { LOG.info( "Suspending down '{}' service isn't supported, terminating it", termination.getServiceName()); doTerminate(termination); } catch (InterruptedException x) { LOG.error( <START> "Interrupted while waiting for '{}' service to suspend", termination.getServiceName()); <END> throw x; } LOG.info("Service '{}' is suspended", termination.getServiceName()); eventService.publish(new SystemServiceSuspendedEvent(termination.getServiceName())); } }</code><technical_language>move suspended event log try block</technical_language>

Target:
void suspendAll() throws InterruptedException { for (ServiceTermination termination : terminations) { LOG.info("Suspending down '{}' service", termination.getServiceName()); eventService.publish(new SuspendingSystemServiceEvent(termination.getServiceName())); try { termination.suspend(); eventService.publish(new SystemServiceSuspendedEvent(termination.getServiceName())); LOG.info("Service '{}' is suspended", termination.getServiceName()); } catch (UnsupportedOperationException e) { LOG.info( "Suspending down '{}' service isn't supported, terminating it", termination.getServiceName()); doTerminate(termination); } catch (InterruptedException x) { LOG.error( "Interrupted while waiting for '{}' service to suspend", termination.getServiceName()); throw x; } } }
Source:
<code>private void validateWriteSizeLimitConfig() { int serializerSize = ZNRecordUtil.getSerializerWriteSizeLimit(); int zkClientSize = getWriteSizeLimit(); if (serializerSize > zkClientSize) { <START> throw new IllegalStateException("ZNRecord serializer write size limit: " + serializerSize <END> + " is greater than size limit in ZkClient: " + zkClientSize); } }</code><technical_language>compression on, serializer return a smaller package input size. do fail here? is debatable</technical_language>

Target:
private void validateWriteSizeLimitConfig() { int serializerSize = ZNRecordUtil.getSerializerWriteSizeLimit(); LOG.info("ZNRecord serializer write size limit: {}; ZkClient write size limit: {}", serializerSize, WRITE_SIZE_LIMIT); if (serializerSize > WRITE_SIZE_LIMIT) { throw new IllegalStateException("ZNRecord serializer write size limit " + serializerSize + " is greater than ZkClient size limit " + WRITE_SIZE_LIMIT); } }
Source:
<code><START> public static boolean canStop(StopMode stopMode, boolean isEntityStopped) { <END> return stopMode == StopMode.ALWAYS || stopMode == StopMode.IF_NOT_STOPPED && !isEntityStopped; }</code><technical_language>reduce visibility of method if exposed for testing</technical_language>

Target:
protected static boolean canStop(StopMode stopMode, boolean isEntityStopped) { return stopMode == StopMode.ALWAYS || stopMode == StopMode.IF_NOT_STOPPED && !isEntityStopped; }
Source:
<code>private PendingResult<Status> addGeofence(LostApiClient client, Geofence geofence, PendingIntent pendingIntent) throws SecurityException { int pendingIntentId = (int) System.currentTimeMillis(); internalIntent = intentFactory.createIntent(context); <START> internalIntent.addCategory(String.valueOf(pendingIntentId)); <END> ParcelableGeofence pGeofence = (ParcelableGeofence) geofence; idToPendingIntent.put(pendingIntentId, pendingIntent); idToGeofence.put(pendingIntentId, pGeofence); PendingIntent internalPendingIntent = intentFactory.createPendingIntent(context, pendingIntentId, internalIntent); String requestId = String.valueOf(pGeofence.hashCode()); locationManager.addProximityAlert( pGeofence.getLatitude(), pGeofence.getLongitude(), pGeofence.getRadius(), pGeofence.getDuration(), internalPendingIntent); if (pGeofence.getRequestId() != null && !pGeofence.getRequestId().isEmpty()) { requestId = pGeofence.getRequestId(); } pendingIntentMap.put(requestId, pendingIntent); return new SimplePendingResult(true); }</code><technical_language>a category extra</technical_language>

Target:
private PendingResult<Status> addGeofence(LostApiClient client, Geofence geofence, PendingIntent pendingIntent) throws SecurityException { int pendingIntentId = idGenerator.generateId(); internalIntent = intentFactory.createIntent(context); internalIntent.addCategory(String.valueOf(pendingIntentId)); ParcelableGeofence pGeofence = (ParcelableGeofence) geofence; idToPendingIntent.put(pendingIntentId, pendingIntent); idToGeofence.put(pendingIntentId, pGeofence); PendingIntent internalPendingIntent = intentFactory.createPendingIntent(context, pendingIntentId, internalIntent); String requestId = String.valueOf(pGeofence.hashCode()); locationManager.addProximityAlert( pGeofence.getLatitude(), pGeofence.getLongitude(), pGeofence.getRadius(), pGeofence.getDuration(), internalPendingIntent); if (pGeofence.getRequestId() != null && !pGeofence.getRequestId().isEmpty()) { requestId = pGeofence.getRequestId(); } pendingIntentMap.put(requestId, pendingIntent); return new SimplePendingResult(true); }
Source:
<code>public void testHoistedFunction2() { test("if (window) { f(); function f() }", <START> "if (window) { f(); function f() }"); <END> }</code><technical_language>a testSame() method for this one</technical_language>

Target:
public void testHoistedFunction2() { test("if (window) { f(); function f() }", "if (window) { var f = function() {}; f(); }"); }
Source:
<code>public void refuseToBuildDisabledProject() throws Exception { FreeStyleProject project = j.createFreeStyleProject("the-project"); project.disable(); CLICommandInvoker invoker = new CLICommandInvoker(j, new BuildCommand()); CLICommandInvoker.Result result = invoker.invokeWithArgs("the-project"); <START> assertThat(result, failedWith(CLIReturnCodeStandard.ILLEGAL_STATE.getCode())); <END> assertThat(result.stderr(), containsString("ERROR: Cannot build the-project because it is disabled.")); assertNull("Project should not be built", project.getBuildByNumber(1)); }</code><technical_language>If add another matcher name failedWith, match CLIResultCode more expressive</technical_language>

Target:
public void refuseToBuildDisabledProject() throws Exception { FreeStyleProject project = j.createFreeStyleProject("the-project"); project.disable(); CLICommandInvoker invoker = new CLICommandInvoker(j, new BuildCommand()); CLICommandInvoker.Result result = invoker.invokeWithArgs("the-project"); assertThat(result, failedWith(StandardCLIReturnCode.ILLEGAL_STATE.getCode())); assertThat(result.stderr(), containsString("ERROR: Cannot build the-project because it is disabled.")); assertNull("Project should not be built", project.getBuildByNumber(1)); }
Source:
<code>public CteValuesListDeleteHandlerImpl( SessionFactoryImplementor factory, HqlSqlWalker walker, String catalog, String schema) { super( factory, walker, catalog, schema ); final String idSubselect = generateIdSubselect( getTargetedQueryable() ); for ( Type type : getTargetedQueryable().getPropertyTypes() ) { if ( type.isCollectionType() ) { CollectionType cType = (CollectionType) type; <START> AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory.getCollectionPersister( cType.getRole() ); <END> if ( cPersister.isManyToMany() ) { deletes.add( generateDelete( cPersister.getTableName(), cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup" ) ); } } } String[] tableNames = getTargetedQueryable().getConstraintOrderedTableNameClosure(); String[][] columnNames = getTargetedQueryable().getContraintOrderedTableKeyColumnClosure(); for ( int i = 0; i < tableNames.length; i++ ) { deletes.add( generateDelete( tableNames[i], columnNames[i], idSubselect, "bulk delete" ) ); } }</code><technical_language>factory.getCollectionPersister(...) is deprecated. in AbstractInlineIdsDeleteHandlerImpl</technical_language>

Target:
public CteValuesListDeleteHandlerImpl( SessionFactoryImplementor factory, HqlSqlWalker walker, String catalog, String schema) { super( factory, walker, catalog, schema ); final String idSubselect = generateIdSubselect( getTargetedQueryable() ); for ( Type type : getTargetedQueryable().getPropertyTypes() ) { if ( type.isCollectionType() ) { CollectionType cType = (CollectionType) type; AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory.getMetamodel().collectionPersister( cType.getRole() ); if ( cPersister.isManyToMany() ) { deletes.add( generateDelete( cPersister.getTableName(), cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup" ) ); } } } String[] tableNames = getTargetedQueryable().getConstraintOrderedTableNameClosure(); String[][] columnNames = getTargetedQueryable().getContraintOrderedTableKeyColumnClosure(); for ( int i = 0; i < tableNames.length; i++ ) { deletes.add( generateDelete( tableNames[i], columnNames[i], idSubselect, "bulk delete" ) ); } }
Source:
<code>public void asyncExec(Runnable runnable) { try { EDTExecutor.invokeLater(runnable); } catch (ProcessCanceledException e) { <START> log.error("Synchronous execution on EDT interrupted - " + runnable, e); <END> } }</code><technical_language>suggestion log.error("Asynchronous execution EDT interrupted - " + runnable, e);</technical_language>

Target:
public void asyncExec(Runnable runnable) { EDTExecutor.invokeLater(runnable); }
Source:
<code>protected int computeGrowthAmount(Material material) { int amount = 0; if (!isAdult() && !(Material.HAY_BLOCK == material && !isTamed())) { Integer mapResult = GROWING_FOODS.get(material); if (mapResult != null) { <START> amount = Math.min(mapResult, Math.abs(getAge())); <END> } } return amount; }</code><technical_language>need for local variable. return this line, return 0 end of method</technical_language>

Target:
protected int computeGrowthAmount(Material material) { if (!isAdult() && !(Material.HAY_BLOCK == material && !isTamed())) { Integer mapResult = GROWING_FOODS.get(material); if (mapResult != null) { return Math.min(mapResult, Math.abs(getAge())); } } return 0; }
Source:
<code>private Map<String, String> makeParams() { HashMap<String, String> params = new HashMap<>(); params.put(Params.TO.paramName, to); params.put(Params.COMMENT.paramName, comment); params.put(Params.MESSAGE.paramName, message); params.put(Params.LABEL.paramName, label); params.put(Params.CODEPRO.paramName, getStringOrNull(codepro)); <START> params.put(Params.EXPIRE.paramName, getStringOrNull(expirePeriod)); <END> setAmount(params); return params; }</code><technical_language>I include parameters omitted. If change this a of a problem</technical_language>

Target:
private Map<String, String> makeParams() { HashMap<String, String> params = new HashMap<>(); params.put(Params.TO.paramName, to); setAmount(params); if (comment != null) { params.put(Params.COMMENT.paramName, comment); } if (message != null) { params.put(Params.MESSAGE.paramName, message); } if (label != null) { params.put(Params.LABEL.paramName, label); } if (codepro != null) { params.put(Params.CODEPRO.paramName, codepro.toString()); } if (expirePeriod != null) { params.put(Params.EXPIRE.paramName, expirePeriod.toString()); } return params; }
Source:
<code>private int getNumBytes(final List<Pair<Integer, Double>> columns) { <START> return columns.size() * (Integer.SIZE + Double.SIZE); <END> }</code><technical_language>encodeColumns(), need additional Integer.SIZE bytes for encoding List<Pair<Integer, Double>></technical_language>

Target:
private int getNumBytes(final List<Pair<Integer, Double>> columns) { return Integer.SIZE + columns.size() * (Integer.SIZE + Double.SIZE); }
Source:
<code>public void delete(final Breakpoint breakpoint) { readAllBreakpointMarker.then(onFulfilled -> { BreakpointStorageImpl.this.breakpoints.removeIf( b -> b.getLineNumber() == breakpoint.getLineNumber() && b.getPath().equals(breakpoint.getPath()) ); <START> if (storage != null) { <END> preserve(); } }); }</code><technical_language>place check for nullable storage method preserve instead of this times</technical_language>

Target:
public void delete(final Breakpoint breakpoint) { readAllBreakpointMarker.then(onFulfilled -> { BreakpointStorageImpl.this.breakpoints.removeIf( b -> b.getLineNumber() == breakpoint.getLineNumber() && b.getPath().equals(breakpoint.getPath()) ); preserve(); }); }