auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public Response intercept(Chain chain) throws IOException { Response response = chain.proceed(chain.request()); <START> if (response.isSuccessful()) { <END> String deprecationHeader = response.header("deprecation"); if (deprecationHeader != null) { log.warn("Using a deprecated endpoint when connecting to service", SafeArg.of("serviceClass", serviceClassName), SafeArg.of("service", response.header("server", "no server header provided"))); } } return response; }</code><technical_language>Do want limit successful responses? Failures more changes deprecate endpoints lack sufficient test coverage cross-version compatibility in mind</technical_language>

Target:
public Response intercept(Chain chain) throws IOException { Response response = chain.proceed(chain.request()); String deprecationHeader = response.header("deprecation"); if (deprecationHeader != null) { clientMetrics.deprecations(serviceClassName).mark(); if (loggingRateLimiter.tryAcquire(1)) { log.warn( "Using a deprecated endpoint when connecting to service", SafeArg.of("serviceClass", serviceClassName), SafeArg.of("service", response.header("server", "no server header provided"))); } } return response; }
Source:
<code><START> public ParseErrorMessage(int lineNumber, String messageKey, Object... messageArguments) { <END> this.lineNumber = lineNumber; this.messageKey = messageKey; this.messageArguments = messageArguments.clone(); }</code><technical_language>this public? instantiate this class class is public constructor is public</technical_language>

Target:
ParseErrorMessage(int lineNumber, String messageKey, Object... messageArguments) { this.lineNumber = lineNumber; this.messageKey = messageKey; this.messageArguments = messageArguments.clone(); }
Source:
<code>protected TmfXmlStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> attributes, String eventField) { fPath = attributes; fContainer = container; fEventField = eventField; if (!node.getNodeName().equals(TmfXmlStrings.STATE_VALUE)) { throw new IllegalArgumentException("TmfXmlStateValue constructor: Element is not a stateValue"); } fIncrement = Boolean.valueOf(node.getAttribute(TmfXmlStrings.INCREMENT)); <START> fStateValue = initializeStateValue(modelFactory, node); <END> switch (node.getAttribute(TmfXmlStrings.FORCED_TYPE)) { case TmfXmlStrings.TYPE_STRING: fForcedType = ValueForcedType.STRING; break; case TmfXmlStrings.TYPE_INT: fForcedType = ValueForcedType.INT; break; case TmfXmlStrings.TYPE_LONG: fForcedType = ValueForcedType.LONG; break; default: fForcedType = ValueForcedType.NULL; } String stack = node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK); switch (stack) { case TmfXmlStrings.STACK_PUSH: fStack = ValueTypeStack.PUSH; break; case TmfXmlStrings.STACK_POP: fStack = ValueTypeStack.POP; break; case TmfXmlStrings.STACK_PEEK: fStack = ValueTypeStack.PEEK; break; default: fStack = ValueTypeStack.NULL; } }</code><technical_language>initializeStateValueType instead</technical_language>

Target:
protected TmfXmlStateValue(ITmfXmlModelFactory modelFactory, Element node, IXmlStateSystemContainer container, List<ITmfXmlStateAttribute> attributes, String eventField) { fPath = attributes; fContainer = container; fEventField = eventField; if (!node.getNodeName().equals(TmfXmlStrings.STATE_VALUE)) { throw new IllegalArgumentException("TmfXmlStateValue constructor: Element is not a stateValue"); } fIncrement = Boolean.valueOf(node.getAttribute(TmfXmlStrings.INCREMENT)); fStateValue = initializeStateValue(modelFactory, node); switch (node.getAttribute(TmfXmlStrings.FORCED_TYPE)) { case TmfXmlStrings.TYPE_STRING: fForcedType = ValueForcedType.STRING; break; case TmfXmlStrings.TYPE_INT: fForcedType = ValueForcedType.INT; break; case TmfXmlStrings.TYPE_LONG: fForcedType = ValueForcedType.LONG; break; default: fForcedType = ValueForcedType.NULL; } String stack = node.getAttribute(TmfXmlStrings.ATTRIBUTE_STACK); switch (stack) { case TmfXmlStrings.STACK_PUSH: fStackType = ValueTypeStack.PUSH; break; case TmfXmlStrings.STACK_POP: fStackType = ValueTypeStack.POP; break; case TmfXmlStrings.STACK_PEEK: fStackType = ValueTypeStack.PEEK; break; default: fStackType = ValueTypeStack.NULL; } }
Source:
<code>protected void writeListProperty(Property entity, CSVPrinter printer) throws IOException { ListType type = (ListType) entity.getType(); if (entity instanceof ArrayProperty) { Object[] array = (Object[]) entity.getValue(); if (array == null) { printer.print(null); return; } Type itemType = type.getFieldType(); if (itemType instanceof BinaryType) { writeUnsupported(type, printer); } else { String value = Arrays.stream(array).map(itemType::encode).collect(Collectors.joining(LIST_DELIMITER)); printer.print(value); ObjectResolver resolver = itemType.getObjectResolver(); if (resolver instanceof DirectoryEntryResolver) { List<String> translated = new ArrayList<>(); DirectoryEntryResolver directoryEntryResolver = (DirectoryEntryResolver) resolver; Directory directory = directoryEntryResolver.getDirectory(); if (VOCABULARY_TYPES.contains(directory.getSchema())) { try (Session session = directory.getSession()) { String lang = ctx.getParameter(LANG_CTX_DATA); for (Object obj : array) { <START> String label = (String) session.getEntry(itemType.encode(obj)) <END> .getProperty(directory.getSchema(), "label"); Locale locale = lang != null ? Locale.forLanguageTag(lang) : ctx.getLocale(); translated.add(I18NUtils.getMessageString("messages", label, new Object[0], locale)); } } } printer.print(translated.stream().collect(Collectors.joining(LIST_DELIMITER))); } } } else { writeUnsupported(type, printer); } }</code><technical_language>getEntry return null</technical_language>

Target:
protected void writeListProperty(Property entity, CSVPrinter printer) throws IOException { ListType type = (ListType) entity.getType(); if (entity instanceof ArrayProperty) { Object[] array = (Object[]) entity.getValue(); if (array == null) { printer.print(null); return; } Type itemType = type.getFieldType(); if (itemType instanceof BinaryType) { writeUnsupported(type, printer); } else { String value = Arrays.stream(array).map(itemType::encode).collect(Collectors.joining(LIST_DELIMITER)); printer.print(value); Directory vocabulary = DocumentModelCSVHelper.getVocabulary(itemType); if (vocabulary != null) { String[] values = Arrays.stream(array).map(itemType::encode).toArray(String[]::new); writeListVocabularyProperty(values, vocabulary, printer); } } } else { writeUnsupported(type, printer); } }
Source:
<code>public void onEvent(Event event, Object source, Object data) { boolean xObjectFound; for (PageNotificationEventDescriptor descriptor : pageNotificationEventDescriptorContainer.getDescriptorList()) { <START> if (descriptor.getEventTrigger().contains(event.getClass().getCanonicalName())) { <END> XWikiDocument document = (XWikiDocument) source; Map<DocumentReference, List<BaseObject>> documentXObjects = document.getXObjects(); xObjectFound = false; for (DocumentReference documentReference : documentXObjects.keySet()) { if (this.checkXObject(documentReference, descriptor)) { xObjectFound = true; break; } } if (xObjectFound && this.evaluateVelocityTemplate(descriptor.getAuthorReference(), descriptor.getValidationExpression())) { observationManager.notify( new PageNotificationEvent(descriptor), "org.xwiki.platform:xwiki-platform-notifications-api", document); } } } }</code><technical_language>I I rely matches method instead of comparing raw type this</technical_language>

Target:
public void onEvent(Event event, Object source, Object data) { for (PageNotificationEventDescriptor descriptor : pageNotificationEventDescriptorManager.getDescriptors()) { if (descriptor.getEventTriggers().contains(event.getClass().getCanonicalName()) && checkXObjectCondition(descriptor, source) && this.evaluateVelocityTemplate(descriptor.getAuthorReference(), descriptor.getValidationExpression())) { observationManager.notify( new PageNotificationEvent(descriptor), "org.xwiki.platform:xwiki-platform-notifications-api", source); } } }
Source:
<code>private void removeInvalidRoles() { <START> if (getParameters().getUserToRoles() == null || getParameters().getUserToRoles().isEmpty() || <END> getParameters().getRoleMap() == null) { return; } Set<String> roles = new HashSet<>(getParameters().getRoleMap().values()); roles.addAll(getParameters().getRoleMap().keySet()); log.info("Checking for missing roles"); missingRoles = getImportValidator().findMissingEntities(roles, val -> roleDao.getByName(val)); getParameters().getUserToRoles().forEach((k, v) -> v.removeAll(missingRoles)); }</code><technical_language>MapUtils.isEmpty instead</technical_language>

Target:
private void removeInvalidRoles() { if (MapUtils.isEmpty(getParameters().getUserToRoles()) || MapUtils.isEmpty(getParameters().getRoleMap())) { return; } Set<String> roles = new HashSet<>(getParameters().getRoleMap().values()); roles.addAll(getParameters().getRoleMap().keySet()); log.info("Checking for missing roles"); missingRoles = getImportValidator().findMissingEntities(roles, val -> roleDao.getByName(val)); getParameters().getUserToRoles().forEach((k, v) -> v.removeAll(missingRoles)); }
Source:
<code>private void addEnvironmentParameters(final Map<String, Object> items) { for (final Map.Entry<String, Object> item : items.entrySet()) { String key = item.getKey(); <START> if (key.startsWith("secure:")) { <END> repo.addEnvironmentParameter(key.substring(key.indexOf("secure:")), secureService.decrypt(item.getValue().toString())); } else { repo.addEnvironmentParameter(key, item.getValue()); } } }</code><technical_language>a constants for "secure:"</technical_language>

Target:
private void addEnvironmentParameters(final Map<String, Object> items) { for (final Map.Entry<String, Object> item : items.entrySet()) { String key = item.getKey(); if (key.startsWith(SECURE_PREFIX)) { repo.addEnvironmentParameter(key.substring(key.indexOf(SECURE_PREFIX)), secureService.decrypt(item.getValue().toString())); } else { repo.addEnvironmentParameter(key, item.getValue()); } } }
Source:
<code>public void javaDoc(){ assertTrue("Groovy project doesn't exist.", Eclim.projectExists(Groovy.TEST_PROJECT)); int count = getJavaDocCount("true"); int minimalCount = 50; <START> Assert.assertTrue("We received some JavaDoc links", count > minimalCount); <END> }</code><technical_language>Please stick existing coding style omit Assert. prefix. Ditto for other cases below</technical_language>

Target:
public void javaDoc(){ assertTrue("Groovy project doesn't exist.", Eclim.projectExists(Groovy.TEST_PROJECT)); int count = getJavaDocCount("anything"); assertJavaDocPresent(count); }
Source:
<code>public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { <START> if (!((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName().isEmpty()) { addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName()); } <END> addCompactTopLabelTextField(gridPane, ++gridRow, UK_SORT_CODE, ((FasterPaymentsAccountPayload) paymentAccountPayload).getSortCode()); addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.accountNr"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getAccountNr()); return gridRow; }</code><technical_language>If this field is shown trade process creates unnecessary scrolling. <img width="1312" alt="Bildschirmfoto 2020-03-26 um 16 16 33" src="<LINK_0>"> change line 54-55 addCompactTopLabelTextField(gridPane, gridRow, 1, Res.get("payment.accountNr"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getAccountNr()); puts sort code account nr next other. <img width="1312" alt="Bildschirmfoto 2020-03-26 um 16 19 57" src="<LINK_1>"> work for cases</technical_language>

Target:
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { if (!((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName().isEmpty()) { addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName()); } addCompactTopLabelTextField(gridPane, ++gridRow, UK_SORT_CODE, ((FasterPaymentsAccountPayload) paymentAccountPayload).getSortCode()); addCompactTopLabelTextField(gridPane, gridRow, 1, Res.get("payment.accountNr"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getAccountNr()); return gridRow; }
Source:
<code>protected Map<?,?> getCustomChildFlags() { return ImmutableMap.builder() .putAll(super.getCustomChildFlags()) .put(MongoDBServer.REPLICA_SET_ENABLED, true) <START> .put(MongoDBServer.REPLICA_SET, this) <END> .build(); }</code><technical_language>Instead of passing a direct reference this, pass getProxy(). This ensure entities proxy, method calls intercepted (to converted effector calls necessary), ensure entity graph distributed want do that. Note revisit passing this is obvious do. framework automatically switch instance passed other entities proxy real entity. easier track if for call getProxy() this</technical_language>

Target:
protected Map<?,?> getCustomChildFlags() { return ImmutableMap.builder() .putAll(super.getCustomChildFlags()) .put(MongoDBServer.REPLICA_SET, getProxy()) .build(); }
Source:
<code>public BlockManagementTaskResult() { <START> mBlockOpResults = new Hashtable<>(); <END> }</code><technical_language>reason want HashTable here</technical_language>

Target:
public BlockManagementTaskResult() { mBlockOpResults = new HashMap<>(); }
Source:
<code>public static LiteralExpression newConstant(Object value, PDataType type) throws SQLException { if (value == null) { if (type == null) { return NULL_EXPRESSION; } return TYPED_NULL_EXPRESSIONS[type.ordinal()]; } PDataType actualType = PDataType.fromLiteral(value); if (!actualType.isCoercibleTo(type, value)) { throw new SQLException("Type mismatch: " + type + " and " + actualType + " for " + value); } value = type.toObject(value, actualType); try { byte[] b = type.toBytes(value); if (b.length == 0) { return TYPED_NULL_EXPRESSIONS[type.ordinal()]; } return new LiteralExpression(value, type, b); } catch (IllegalDataException e) { <START> throw SQLExceptionInfo.getNewInfoObject(SQLExceptionCodeEnum.ILLEGAL_DATA).genWrappedException(e); <END> } }</code><technical_language>follow builder pattern here. genWrappedException -> build SQLException Builder class, SQLExceptionInfo.getNewInfoObject -> new SQLException.Builder(). line this: new SQLExceptionInfo.Builder(e).setCode(SQLExceptionCodeEnum.ILLEGAL_DATA).build();</technical_language>

Target:
public static LiteralExpression newConstant(Object value, PDataType type) throws SQLException { if (value == null) { if (type == null) { return NULL_EXPRESSION; } return TYPED_NULL_EXPRESSIONS[type.ordinal()]; } PDataType actualType = PDataType.fromLiteral(value); if (!actualType.isCoercibleTo(type, value)) { throw new TypeMismatchException(type, actualType, value.toString()); } value = type.toObject(value, actualType); try { byte[] b = type.toBytes(value); if (b.length == 0) { return TYPED_NULL_EXPRESSIONS[type.ordinal()]; } return new LiteralExpression(value, type, b); } catch (IllegalDataException e) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.ILLEGAL_DATA).setRootCause(e).build().buildException(); } }
Source:
<code><START> public Response getAccountEmailAuditLogsWithHistory(@PathParam("accountId") final UUID accountId, <END> @PathParam("accountEmailId") final UUID accountEmailId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException { final TenantContext tenantContext = context.createTenantContextWithAccountId(accountId, request); final List<AuditLogWithHistory> auditLogWithHistory = accountUserApi.getEmailAuditLogsWithHistoryForId(accountId, accountEmailId, AuditLevel.FULL, tenantContext); return Response.status(Status.OK).entity(getAuditLogsWithHistory(auditLogWithHistory)).build(); }</code><technical_language>I need accountId (same remark below)</technical_language>

Target:
public Response getAccountEmailAuditLogsWithHistory(@PathParam("accountId") final UUID accountId, @PathParam("accountEmailId") final UUID accountEmailId, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException { final TenantContext tenantContext = context.createTenantContextWithAccountId(accountId, request); final List<AuditLogWithHistory> auditLogWithHistory = accountUserApi.getEmailAuditLogsWithHistoryForId(accountEmailId, AuditLevel.FULL, tenantContext); return Response.status(Status.OK).entity(getAuditLogsWithHistory(auditLogWithHistory)).build(); }
Source:
<code>public String transform(String value) { <START> LocalAuthPasswordValidator.validatePassword(value, jsonMapper); <END> if (StringUtils.isBlank(value)){ return ""; } return hash(value); }</code><technical_language>This generic of a place put this validation. case catch this</technical_language>

Target:
public String transform(String value) { if (StringUtils.isBlank(value)){ return ""; } return hash(value); }
Source:
<code>private Builder(ReadSupport<T> readSupport, Path path) { <START> this.readSupport = Objects.requireNonNull(readSupport, "readSupport"); <END> this.file = null; this.path = Objects.requireNonNull(path, "path cannot be null"); this.conf = new Configuration(); this.optionsBuilder = HadoopReadOptions.builder(conf); }</code><technical_language>suggestion this.readSupport = Objects.requireNonNull(readSupport, "readSupport null");</technical_language>

Target:
private Builder(ReadSupport<T> readSupport, Path path) { this.readSupport = Objects.requireNonNull(readSupport, "readSupport cannot be null"); this.file = null; this.path = Objects.requireNonNull(path, "path cannot be null"); this.conf = new Configuration(); this.optionsBuilder = HadoopReadOptions.builder(conf); }
Source:
<code>public void testGenotypePhenotypeSearchFeaturePagingMore() throws AvroRemoteException { SearchGenotypePhenotypeRequest request = SearchGenotypePhenotypeRequest.newBuilder().build(); request.setFeature("KIT *wild"); SearchGenotypePhenotypeResponse response = client.genotypePhenotype.searchGenotypePhenotype(request); <START> assertThat(response).isNotNull(); <END> assertThat(response.getAssociations()).isNotNull() ; assertThat(response.getAssociations().size()).isGreaterThan(1); }</code><technical_language>Null possible</technical_language>

Target:
public void testGenotypePhenotypeSearchFeaturePagingMore() throws AvroRemoteException { SearchGenotypePhenotypeRequest request = SearchGenotypePhenotypeRequest.newBuilder().build(); request.setFeature(TestData.FEATURE_NAME); SearchGenotypePhenotypeResponse response = client.genotypePhenotype.searchGenotypePhenotype(request); assertThat(response.getAssociations()).isNotNull() ; assertThat(response.getAssociations().size()).isGreaterThan(1); }
Source:
<code><START> int computeWidthDifference (GtkRequisition requisition, int width) { <END> int diffwidth; diffwidth = requisition.width - width; if (width - diffwidth < 0) { return requisition.width; } else { return width; } }</code><technical_language>Suggestion: Reduce this a 1 liner: return (requisition.width - width) < 0 ? requisition.width : width;</technical_language>

Target:
int computeWidthDifference (GtkRequisition requisition, int width) { return (requisition.width - width) < 0 ? requisition.width : width; }
Source:
<code>public void mustEvictCleanPageWithoutFlushing() throws Exception { writeInitialDataTo( file( "a" ) ); RecordingPageCacheTracer tracer = new RecordingPageCacheTracer(); RecordingPageCursorTracer cursorTracer = new RecordingPageCursorTracer(); ConfigurablePageCursorTracerSupplier cursorTracerSupplier = new ConfigurablePageCursorTracerSupplier( cursorTracer ); try ( MuninnPageCache pageCache = createPageCache( fs, 2, 8, blockCacheFlush( tracer ), cursorTracerSupplier ) ) { <START> try ( PagedFile pagedFile = pageCache.map( file( "a" ), 8 ) ) <END> { try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); } cursorTracer.reportEvents(); assertNotNull( cursorTracer.observe( Fault.class ) ); assertEquals( 1, cursorTracer.faults() ); assertEquals( 1, tracer.faults() ); int clockArm = pageCache.evictPages( 1, 0, tracer.beginPageEvictions( 1 ) ); assertThat( clockArm, is( 1 ) ); assertNotNull( tracer.observe( Evict.class ) ); } } }</code><technical_language>PageCacheTest, places try-with-resources clauses combined</technical_language>

Target:
public void mustEvictCleanPageWithoutFlushing() throws Exception { writeInitialDataTo( file( "a" ) ); RecordingPageCacheTracer tracer = new RecordingPageCacheTracer(); RecordingPageCursorTracer cursorTracer = new RecordingPageCursorTracer(); ConfigurablePageCursorTracerSupplier cursorTracerSupplier = new ConfigurablePageCursorTracerSupplier( cursorTracer ); try ( MuninnPageCache pageCache = createPageCache( fs, 2, 8, blockCacheFlush( tracer ), cursorTracerSupplier ); PagedFile pagedFile = pageCache.map( file( "a" ), 8 ) ) { try ( PageCursor cursor = pagedFile.io( 0, PF_SHARED_READ_LOCK ) ) { assertTrue( cursor.next() ); } cursorTracer.reportEvents(); assertNotNull( cursorTracer.observe( Fault.class ) ); assertEquals( 1, cursorTracer.faults() ); assertEquals( 1, tracer.faults() ); int clockArm = pageCache.evictPages( 1, 0, tracer.beginPageEvictions( 1 ) ); assertThat( clockArm, is( 1 ) ); assertNotNull( tracer.observe( Evict.class ) ); } }
Source:
<code>public void testThrownErrorSingleTagGHFileNotFound() throws IOException { SCMHeadObserver mockSCMHeadObserver = Mockito.mock(SCMHeadObserver.class); Error e = new Error("Bad Tag Request", new GHFileNotFoundException()); Mockito.when(mockSCMHeadObserver.getIncludes()).thenReturn(Collections .singleton(new GitHubTagSCMHead("existent-tag", System.currentTimeMillis()))); <START> GHRepository repoSpy = Mockito.spy(repo); <END> GitHubSCMSourceContext context = new GitHubSCMSourceContext(null, mockSCMHeadObserver); context.wantTags(true); GitHubSCMSourceRequest request = context.newRequest(revisions()[0], null); Mockito.doThrow(e).when(repoSpy).getRef("tags/existent-tag"); Iterator<GHRef> tags = new GitHubSCMSource.LazyTags(request, repoSpy).iterator(); assertFalse(tags.hasNext()); }</code><technical_language>Extract identical setup a separate method</technical_language>

Target:
public void testThrownErrorSingleTagGHFileNotFound() throws IOException { SCMHeadObserver mockSCMHeadObserver = Mockito.mock(SCMHeadObserver.class); Error e = new Error("Bad Tag Request", new GHFileNotFoundException()); Mockito.when(mockSCMHeadObserver.getIncludes()).thenReturn(Collections .singleton(new GitHubTagSCMHead("existent-tag", System.currentTimeMillis()))); GHRepository repoSpy = Mockito.spy(repo); GitHubSCMSourceContext context = new GitHubSCMSourceContext(null, mockSCMHeadObserver); context.wantTags(true); GitHubSCMSourceRequest request = context.newRequest(new GitHubSCMSource("cloudbeers", "yolo", null, false), null); Mockito.doThrow(e).when(repoSpy).getRef("tags/existent-tag"); Iterator<GHRef> tags = new GitHubSCMSource.LazyTags(request, repoSpy).iterator(); assertFalse(tags.hasNext()); }
Source:
<code><START> MessageConverterConfigurer messageConverterConfigurer <END> (ChannelBindingServiceProperties channelBindingServiceProperties) { return new MessageConverterConfigurer(channelBindingServiceProperties); }</code><technical_language>longer public</technical_language>

Target:
public MessageConverterConfigurer messageConverterConfigurer (ChannelBindingServiceProperties channelBindingServiceProperties) { return new MessageConverterConfigurer(channelBindingServiceProperties); }
Source:
<code>public Subscription updateSubscription(final String subscriptionId, final SubscriptionBase newValue) throws NoSuchSubscriptionException, SubscriptionUpdateConflictException { if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) { throw new DbWriteOperationsBlockedException("Cannot create subscription: write operations on DB " + "are blocked by feature flag."); } final Subscription old = subscriptionRepository.getSubscription(subscriptionId); authorizationValidator.authorizeSubscriptionAdmin(old); subscriptionValidationService.validateSubscriptionChange(old, newValue); old.mergeFrom(newValue); <START> old.setUpdatedAt(new DateTime()); <END> subscriptionRepository.updateSubscription(old); return old; }</code><technical_language>DateTimeZone.UTC</technical_language>

Target:
public Subscription updateSubscription(final String subscriptionId, final SubscriptionBase newValue) throws NoSuchSubscriptionException, SubscriptionUpdateConflictException { if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.DISABLE_DB_WRITE_OPERATIONS)) { throw new DbWriteOperationsBlockedException("Cannot create subscription: write operations on DB " + "are blocked by feature flag."); } final Subscription old = subscriptionRepository.getSubscription(subscriptionId); authorizationValidator.authorizeSubscriptionAdmin(old); subscriptionValidationService.validateSubscriptionChange(old, newValue); old.mergeFrom(newValue); old.setUpdatedAt(new DateTime(DateTimeZone.UTC)); subscriptionRepository.updateSubscription(old); return old; }
Source:
<code>protected boolean delegate(float delta) { <START> return rendererChanged; <END> }</code><technical_language>need "rendererChanged". "delegate" is update method of action (probably method name) returns true action is done. If action needs update execute (like in this case), return true (all happen, happened initialize)</technical_language>

Target:
protected boolean delegate(float delta) { return true; }
Source:
<code>public Iterable<Server> listNodesByIds(final Iterable<String> ids) { return Iterables.filter(listNodes(), new Predicate<Server>() { @Override public boolean apply(Server server) { <START> return Iterables.contains(ids, Integer.toString(server.id)); <END> } }); }</code><technical_language>one</technical_language>

Target:
public Iterable<Server> listNodesByIds(final Iterable<String> ids) { return filter(listNodes(), new Predicate<Server>() { @Override public boolean apply(Server server) { return contains(ids, Integer.toString(server.id)); } }); }
Source:
<code>public static void enlargeButtonText(Button button) { if (modifier == 1.0f) { return; } <START> if (!enlargedButtons.contains(button)) { <END> button.setTextSize(TypedValue.COMPLEX_UNIT_PX, button.getTextSize() * getModifier()); enlargedButtons.add(button); } }</code><technical_language>is this keeping of modified buttons necessary</technical_language>

Target:
public static void enlargeButtonText(Button button) { if (modifier == 1.0f) { return; } button.setTextSize(TypedValue.COMPLEX_UNIT_PX, button.getTextSize() * getModifier()); }
Source:
<code>private <T> InstanceRegistry<T> instanceRegistry(final Class<T> category) { <START> @SuppressWarnings("unchecked") <END> InstanceRegistry<T> registry = (InstanceRegistry<T>) categories.get(category); if (registry == null) { throw new IllegalArgumentException("The category '" + category + "' is not registered"); } return registry; }</code><technical_language>This safe, InstanceRegistry is a private class control access constructor</technical_language>

Target:
private <T> InstanceRegistry<T> instanceRegistry(final Class<T> category) { ensureArgumentNonNull("category", category); @SuppressWarnings("unchecked") InstanceRegistry<T> registry = (InstanceRegistry<T>) categories.get(category); if (registry == null) { throw new IllegalArgumentException("The category '" + category + "' is not registered"); } return registry; }
Source:
<code><START> public FileScan(final String filename, final Schema schema, final Character delimiter) { <END> this(filename, schema, delimiter, null, null, null); }</code><technical_language>Feel free simplify code rid of some of constructor variants. I lean of String instead of DataSource, combination of arguments 1) (source, schema) [rest default], 2) (source, schema, delimiter) [rest default], 3) arguments specified</technical_language>

Target:
public FileScan(final String filename, final Schema schema, final Character delimiter) { this(new FileSource(filename), schema, delimiter, null, null, null); }
Source:
<code>public Map<String, ResourceAssignment> getBaseline() { if (_globalBaseline == null) { try { HelixProperty baseline = _dataAccessor.compressedBucketRead(_baselinePath, HelixProperty.class); _globalBaseline = splitAssignments(baseline); } catch (HelixException e) { <START> _globalBaseline = new HashMap<>(); <END> } } return _globalBaseline; }</code><technical_language>I prefer throwing exception. rebalancer decide next step</technical_language>

Target:
public Map<String, ResourceAssignment> getBaseline() { if (_globalBaseline == null) { HelixProperty baseline = _dataAccessor.compressedBucketRead(_baselinePath, HelixProperty.class); _globalBaseline = splitAssignments(baseline); } return _globalBaseline; }
Source:
<code>public static void register(Context ctx, PreferenceManager preferenceManager){ CountlyConfig config = new CountlyConfig() <START> .setAppKey("146836f41172f9e3287cab6f2cc347de3f5ddf3b") <END> .setContext(ctx) .setIdMode(DeviceId.Type.ADVERTISING_ID) .setRequiresConsent(true) .setConsentEnabled(basicFeatures) .setServerURL(BuildConfig.NOTIFICATION_SERVER) .setLoggingEnabled(!BuildConfig.DEBUG) .setViewTracking(true) .setHttpPostForced(true) .setViewTracking(true) .enableCrashReporting() .enableCrashReporting(); CountlyManager.reloadConsent(preferenceManager); Countly.sharedInstance().init(config); }</code><technical_language>Is fine commit key publicly</technical_language>

Target:
public static void register(Context ctx, PreferenceManager preferenceManager){ CountlyConfig config = new CountlyConfig() .setAppKey("146836f41172f9e3287cab6f2cc347de3f5ddf3b") .setContext(ctx) .setDeviceId(preferenceManager.getOrGenerateUUID4()) .setRequiresConsent(true) .setConsentEnabled(getConsentsEnabled(preferenceManager)) .setServerURL(BuildConfig.NOTIFICATION_SERVER) .setLoggingEnabled(!BuildConfig.DEBUG) .setViewTracking(true) .setHttpPostForced(true) .enableCrashReporting(); Countly.sharedInstance().init(config); }
Source:
<code>private Set<Path> getFileRepo() { if (this.scmRepositories != null) { String repositoryUri = null; try { for (AbstractScmEnvironmentRepository repository : scmRepositories) { repositoryUri = repository.getUri(); Resource resource = this.resourceLoader.getResource(repositoryUri); if (resource instanceof FileSystemResource) { <START> return Collections.singleton(Paths.get(resource.getURI())); <END> } } } catch (IOException e) { log.error("Cannot resolve URI for path: " + repositoryUri); } } if (this.nativeEnvironmentRepository != null) { Set<Path> paths = new LinkedHashSet<>(); for (String path : this.nativeEnvironmentRepository.getSearchLocations()) { Resource resource = this.resourceLoader.getResource(path); if (resource.exists()) { try { paths.add(Paths.get(resource.getURI())); } catch (Exception e) { log.error("Cannot resolve URI for path: " + path); } } } return paths; } return null; }</code><technical_language>I guess watch one? if multiple file:// git repos</technical_language>

Target:
private Set<Path> getFileRepo() { if (this.scmRepositories != null) { String repositoryUri = null; Set<Path> paths = new LinkedHashSet<>(); try { for (AbstractScmEnvironmentRepository repository : scmRepositories) { repositoryUri = repository.getUri(); Resource resource = this.resourceLoader.getResource(repositoryUri); if (resource instanceof FileSystemResource) { paths.add(Paths.get(resource.getURI())); } } return paths; } catch (IOException e) { log.error("Cannot resolve URI for path: " + repositoryUri); } } if (this.nativeEnvironmentRepository != null) { Set<Path> paths = new LinkedHashSet<>(); for (String path : this.nativeEnvironmentRepository.getSearchLocations()) { Resource resource = this.resourceLoader.getResource(path); if (resource.exists()) { try { paths.add(Paths.get(resource.getURI())); } catch (Exception e) { log.error("Cannot resolve URI for path: " + path); } } } return paths; } return null; }
Source:
<code>void copy() throws IOException { FileInputStream input = new FileInputStream(src); FileOutputStream output = new FileOutputStream(dest); <START> FileChannel channel = input.getChannel(); output.getChannel().transferFrom(channel, 0, channel.size()); input.close(); output.close(); <END> }</code><technical_language>Wrap try/finally ensure streams closed in case of failure</technical_language>

Target:
void copy() throws IOException { FileInputStream input = new FileInputStream(src); FileOutputStream output = new FileOutputStream(dest); try { FileChannel channel = input.getChannel(); output.getChannel().transferFrom(channel, 0, channel.size()); } finally { input.close(); output.close(); } }
Source:
<code>private static ArrayList<Integer> targetWidths() { ArrayList<Integer> resolutions = new ArrayList<Integer>(); int MAX_SIZE = 8192; double SRCSET_INCREMENT_PERCENTAGE = 8; double prev = 100; <START> while (prev <= MAX_SIZE) { <END> resolutions.add((int)(2 * Math.round(prev/2))); prev *= 1 + (SRCSET_INCREMENT_PERCENTAGE / 100) * 2; } resolutions.add(MAX_SIZE); return resolutions; }</code><technical_language>suggestion while (prev < MAX_SIZE) {</technical_language>

Target:
private static ArrayList<Integer> targetWidths() { ArrayList<Integer> resolutions = new ArrayList<Integer>(); int MAX_SIZE = 8192, roundedPrev; double SRCSET_INCREMENT_PERCENTAGE = 8; double prev = 100; while (prev < MAX_SIZE) { roundedPrev = (int)(2 * Math.round(prev / 2)); resolutions.add(roundedPrev); prev *= 1 + (SRCSET_INCREMENT_PERCENTAGE / 100) * 2; } resolutions.add(MAX_SIZE); return resolutions; }
Source:
<code>public void update() throws Exception { context.turnOffAuthorisationSystem(); MetadataSchema metadataSchema = MetadataSchemaBuilder.createMetadataSchema(context, TEST_NAME, TEST_NAMESPACE) <START> .build(); <END> MetadataSchemaRest metadataSchemaRest = new MetadataSchemaRest(); metadataSchemaRest.setId(metadataSchema.getID()); metadataSchemaRest.setPrefix(TEST_NAME_UPDATED); metadataSchemaRest.setNamespace(TEST_NAMESPACE_UPDATED); getClient(getAuthToken(admin.getEmail(), password)) .perform(put("/api/core/metadataschemas/" + metadataSchema.getID()) .content(new ObjectMapper().writeValueAsBytes(metadataSchemaRest)) .contentType(contentType)) .andExpect(status().isOk()); getClient().perform(get("/api/core/metadataschemas/" + metadataSchema.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$", MetadataschemaMatcher .matchEntry(TEST_NAME_UPDATED, TEST_NAMESPACE_UPDATED))); }</code><technical_language>turn auth system creating test data</technical_language>

Target:
public void update() throws Exception { context.turnOffAuthorisationSystem(); MetadataSchema metadataSchema = MetadataSchemaBuilder.createMetadataSchema(context, TEST_NAME, TEST_NAMESPACE) .build(); context.restoreAuthSystemState(); MetadataSchemaRest metadataSchemaRest = new MetadataSchemaRest(); metadataSchemaRest.setId(metadataSchema.getID()); metadataSchemaRest.setPrefix(TEST_NAME_UPDATED); metadataSchemaRest.setNamespace(TEST_NAMESPACE_UPDATED); getClient(getAuthToken(admin.getEmail(), password)) .perform(put("/api/core/metadataschemas/" + metadataSchema.getID()) .content(new ObjectMapper().writeValueAsBytes(metadataSchemaRest)) .contentType(contentType)) .andExpect(status().isOk()); getClient().perform(get("/api/core/metadataschemas/" + metadataSchema.getID())) .andExpect(status().isOk()) .andExpect(jsonPath("$", MetadataschemaMatcher .matchEntry(TEST_NAME_UPDATED, TEST_NAMESPACE_UPDATED))); }
Source:
<code>public synchronized void stop() { if (acceptor != null) { try { <START> close(true).await(); <END> } catch (InterruptedException e) { log.warn("Exception caught while closing", e); } finally { acceptor = null; } } }</code><technical_language>Add info log this line</technical_language>

Target:
public synchronized void stop() { if (acceptor != null) { try { close(true).await(); log.info("Stopped Gerrit SSHD"); } catch (InterruptedException e) { log.warn("Exception caught while closing", e); } finally { acceptor = null; } } }
Source:
<code>private ArrayList<String> getTrackedEventsFromFolder(String harDirPath) { ArrayList<String> finalTrackedEvents = new ArrayList<String>(); ArrayList<String> listOfHarFiles = new ArrayList<String>(); listOfHarFiles = getAllHarFiles(harDirPath); for (int i = 0; i < listOfHarFiles.size(); i++) { ArrayList<String> trackedEvents = new ArrayList<String>(); trackedEvents = getTrackedEventsFromFile(harDirPath+listOfHarFiles.get(i)); <START> finalTrackedEvents.addAll(trackedEvents); <END> } return finalTrackedEvents; }</code><technical_language>Instead of: ArrayList<String> trackedEvents = new ArrayList<String>(); trackedEvents = getTrackedEventsFromFile(harDirPath+listOfHarFiles.get(i)); finalTrackedEvents.addAll(trackedEvents); do like: finalTrackedEvents.addAll(getTrackedEventsFromFile(harDirPath+listOfHarFiles.get(i)); I if is good idea initialize ArrayList loop, is a placeholder for pass</technical_language>

Target:
private ArrayList<String> getTrackedEventsFromFolder(String harDirPath) { ArrayList<String> finalTrackedEvents = new ArrayList<String>(); ArrayList<String> listOfHarFiles = new ArrayList<String>(); listOfHarFiles = getAllHarFiles(harDirPath); for (int i = 0; i < listOfHarFiles.size(); i++) { finalTrackedEvents.addAll(getTrackedEventsFromFile(harDirPath+listOfHarFiles.get(i))); } return finalTrackedEvents; }
Source:
<code>private static void validateStreamEmitterMethod(Method method, int outputAnnotationCount, String methodAnnotatedOutboundName) { if (StringUtils.hasText(methodAnnotatedOutboundName)) { Assert.isTrue(outputAnnotationCount == 0, StreamEmitterErrorMessages.INVALID_OUTPUT_METHOD_PARAMETERS); } else { Assert.isTrue(outputAnnotationCount > 0, StreamEmitterErrorMessages.NO_OUTPUT_SPECIFIED); } if (!method.getReturnType().equals(Void.TYPE)) { Assert.isTrue(StringUtils.hasText(methodAnnotatedOutboundName), StreamEmitterErrorMessages.RETURN_TYPE_NO_OUTBOUND_SPECIFIED); Assert.isTrue(method.getParameterCount() == 0, StreamEmitterErrorMessages.RETURN_TYPE_METHOD_ARGUMENTS); } else { if (!StringUtils.hasText(methodAnnotatedOutboundName)) { int methodArgumentsLength = method.getParameterTypes().length; for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { <START> MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(method, parameterIndex); <END> if (methodParameter.hasParameterAnnotation(Output.class)) { String outboundName = (String) AnnotationUtils .getValue(methodParameter.getParameterAnnotation(Output.class)); Assert.isTrue(StringUtils.hasText(outboundName), StreamEmitterErrorMessages.INVALID_OUTBOUND_NAME); } else { throw new IllegalArgumentException( StreamEmitterErrorMessages.OUTPUT_ANNOTATION_MISSING_ON_METHOD_PARAMETERS_VOID_RETURN_TYPE); } } } } }</code><technical_language>This is a Method new MethodParameter() is fully sufficient. a Constructor otherwise</technical_language>

Target:
private static void validateStreamEmitterMethod(Method method, int outputAnnotationCount, String methodAnnotatedOutboundName) { if (StringUtils.hasText(methodAnnotatedOutboundName)) { Assert.isTrue(outputAnnotationCount == 0, StreamEmitterErrorMessages.INVALID_OUTPUT_METHOD_PARAMETERS); } else { Assert.isTrue(outputAnnotationCount > 0, StreamEmitterErrorMessages.NO_OUTPUT_SPECIFIED); } if (!method.getReturnType().equals(Void.TYPE)) { Assert.isTrue(StringUtils.hasText(methodAnnotatedOutboundName), StreamEmitterErrorMessages.RETURN_TYPE_NO_OUTBOUND_SPECIFIED); Assert.isTrue(method.getParameterCount() == 0, StreamEmitterErrorMessages.RETURN_TYPE_METHOD_ARGUMENTS); } else { if (!StringUtils.hasText(methodAnnotatedOutboundName)) { int methodArgumentsLength = method.getParameterTypes().length; for (int parameterIndex = 0; parameterIndex < methodArgumentsLength; parameterIndex++) { MethodParameter methodParameter = new MethodParameter(method, parameterIndex); if (methodParameter.hasParameterAnnotation(Output.class)) { String outboundName = (String) AnnotationUtils .getValue(methodParameter.getParameterAnnotation(Output.class)); Assert.isTrue(StringUtils.hasText(outboundName), StreamEmitterErrorMessages.INVALID_OUTBOUND_NAME); } else { throw new IllegalArgumentException( StreamEmitterErrorMessages.OUTPUT_ANNOTATION_MISSING_ON_METHOD_PARAMETERS_VOID_RETURN_TYPE); } } } } }
Source:
<code>private List<ProxyData> getProxyData(String provider) { List<ProxyData> proxyDatas = new ArrayList<>(); ProxyData[] entries = ProxySelector.getProxyData(provider); for (ProxyData <START> entrie : <END> entries) { entrie.setSource(provider); proxyDatas.add(entrie); } return proxyDatas; }</code><technical_language>entry</technical_language>

Target:
private List<ProxyData> getProxyData(String provider) { List<ProxyData> proxyDatas = new ArrayList<>(); ProxyData[] entries = ProxySelector.getProxyData(provider); for (ProxyData entry : entries) { entry.setSource(provider); proxyDatas.add(entry); } return proxyDatas; }
Source:
<code>public synchronized void initRoutingTable(final EMRoutingTable routingTable) { final Map<Integer, Set<Integer>> storeIdToBlockIds = routingTable.getStoreIdToBlockIds(); numTotalBlocks = routingTable.getNumTotalBlocks(); storeIdToEndpointId.putAll(routingTable.getStoreIdToEndpointId()); for (final Map.Entry<Integer, Set<Integer>> entry : storeIdToBlockIds.entrySet()) { final int storeId = entry.getKey(); for (final int blockId : entry.getValue()) { blockIdToStoreId.put(blockId, storeId); } } initialized = true; LOG.log(Level.FINE, "Server resolver is initialized"); <START> synchronized (this) { <END> this.notifyAll(); } }</code><technical_language>nit: If this method synchronized, this synchronized statement is unnecessary</technical_language>

Target:
public synchronized void initRoutingTable(final EMRoutingTable routingTable) { if (initialized) { return; } final Map<Integer, Set<Integer>> storeIdToBlockIds = routingTable.getStoreIdToBlockIds(); numTotalBlocks = routingTable.getNumTotalBlocks(); storeIdToEndpointId.putAll(routingTable.getStoreIdToEndpointId()); for (final Map.Entry<Integer, Set<Integer>> entry : storeIdToBlockIds.entrySet()) { final int storeId = entry.getKey(); for (final int blockId : entry.getValue()) { blockIdToStoreId.put(blockId, storeId); } } initialized = true; LOG.log(Level.FINE, "Server resolver is initialized"); synchronized (this) { this.notifyAll(); } }
Source:
<code>private static AuthenticationException needAuthentication(String message) { <START> return new AuthenticationException(message, "Bearer realm=\"Presto\", token_type=\"JWT\"'"); <END> }</code><technical_language>This extra '</technical_language>

Target:
private static AuthenticationException needAuthentication(String message) { return new AuthenticationException(message, "Bearer realm=\"Presto\", token_type=\"JWT\""); }
Source:
<code>private boolean bufferCurrentEventAndScheduleIfRequired(RecordsRetrieved recordsRetrieved, RecordFlow triggeringFlow) { boolean isCurrentEventScheduled = false; final RecordsRetrievedContext recordsRetrievedContext = new RecordsRetrievedContext(recordsRetrieved, triggeringFlow); try { recordsDeliveryQueue.add(recordsRetrievedContext); if (recordsDeliveryQueue.size() == 1) { subscriber.onNext(recordsRetrieved); isCurrentEventScheduled = true; } } catch (IllegalStateException e) { log.warn("{}: Unable to enqueue the payload due to capacity restrictions in delivery queue with remaining capacity ", shardId, recordsDeliveryQueue.remainingCapacity()); throw e; } catch (Throwable t) { <START> recordsDeliveryQueue.remove(recordsRetrievedContext); <END> throw t; } return isCurrentEventScheduled; }</code><technical_language>removal of this event, is throwable accepted here? I expect flow restarted beginning exception. log error this throw block</technical_language>

Target:
void bufferCurrentEventAndScheduleIfRequired(RecordsRetrieved recordsRetrieved, RecordFlow triggeringFlow) { final RecordsRetrievedContext recordsRetrievedContext = new RecordsRetrievedContext(recordsRetrieved, triggeringFlow, Instant.now()); try { recordsDeliveryQueue.add(recordsRetrievedContext); if (recordsDeliveryQueue.size() == 1) { subscriber.onNext(recordsRetrieved); } } catch (IllegalStateException e) { log.warn("{}: Unable to enqueue the payload due to capacity restrictions in delivery queue with remaining capacity ", shardId, recordsDeliveryQueue.remainingCapacity()); throw e; } catch (Throwable t) { log.error("{}: Unable to deliver event to the shard consumer.", shardId, t); throw t; } }
Source:
<code>public GenerateVepAnnotationStepParametersValidator(boolean isStudyIdRequired) { super(new String[]{JobParametersNames.DB_COLLECTIONS_VARIANTS_NAME, JobParametersNames.DB_NAME, JobParametersNames.APP_VEP_CACHE_PATH, JobParametersNames.APP_VEP_CACHE_SPECIES, JobParametersNames.APP_VEP_CACHE_VERSION, JobParametersNames.APP_VEP_NUMFORKS, JobParametersNames.APP_VEP_PATH, JobParametersNames.APP_VEP_TIMEOUT, JobParametersNames.INPUT_FASTA, JobParametersNames.ANNOTATION_OVERWRITE, <START> JobParametersNames.OUTPUT_DIR_ANNOTATION}, <END> new String[]{}); this.isStudyIdRequired = isStudyIdRequired; }</code><technical_language>this sorted alphabetically, in validators declaration</technical_language>

Target:
public GenerateVepAnnotationStepParametersValidator(boolean isStudyIdRequired) { super(new String[]{JobParametersNames.ANNOTATION_OVERWRITE, JobParametersNames.APP_VEP_CACHE_PATH, JobParametersNames.APP_VEP_CACHE_SPECIES, JobParametersNames.APP_VEP_CACHE_VERSION, JobParametersNames.APP_VEP_NUMFORKS, JobParametersNames.APP_VEP_PATH, JobParametersNames.APP_VEP_TIMEOUT, JobParametersNames.DB_COLLECTIONS_VARIANTS_NAME, JobParametersNames.DB_NAME, JobParametersNames.INPUT_FASTA, JobParametersNames.OUTPUT_DIR_ANNOTATION}, new String[]{}); this.isStudyIdRequired = isStudyIdRequired; }
Source:
<code>public void tearDown() throws IOException { try { DeleteJob.deleteJob(PROJECT_ID, LOCATION, JOB_ID); <START> } catch (GoogleJsonResponseException gjre) { } <END> deleteBucket(BUCKET_NAME); System.setOut(originalOut); bout.reset(); }</code><technical_language>catching ignoring? above, if catch, do something, if wish ignore exception, please so. Typically word "expected" variable name. <LINK_0></technical_language>

Target:
public void tearDown() throws IOException { DeleteJob.deleteJob(PROJECT_ID, LOCATION, JOB_ID); deleteBucket(BUCKET_NAME); System.setOut(originalOut); bout.reset(); }
Source:
<code>private void handleOnFragmentChange() { getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { FragmentManager fragmentManager = getSupportFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(R.id.list_fragment_container); if (fragment instanceof MessageListFragment) { String tag = fragment.getTag(); <START> if (menu==null) <END> return; if (tag.equals(getString(R.string.home_frament_tag))) { calendar = Calendar.getInstance(); menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_today); }else if (tag.equals(getString(R.string.today_fragment_tag))) { menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_one_day_before); } } } }); }</code><technical_language>Please format code in this block</technical_language>

Target:
private void handleOnFragmentChange() { getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { @Override public void onBackStackChanged() { if (menu == null) return; if (narrowedList==null) { calendar = Calendar.getInstance(); menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_today); } else if (narrowedList.filter instanceof NarrowFilterByDate) { menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_one_day_before); } } }); }