auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>void addPredicateParamMissingForReference(String theResourceName, String theParamName, boolean theMissing, RequestPartitionId theRequestPartitionId) { From<?, SearchParamPresent> paramPresentJoin = myQueryRootStack.createJoin(SearchBuilderJoinEnum.PRESENCE, null); Expression<Long> hashPresence = paramPresentJoin.get("myHashPresence").as(Long.class); Long hash = SearchParamPresent.calculateHashPresence(myPartitionSettings, theRequestPartitionId, theResourceName, theParamName, !theMissing); List<Predicate> predicates = new ArrayList<>(); predicates.add(myCriteriaBuilder.equal(hashPresence, hash)); addPartitionIdPredicate(theRequestPartitionId, paramPresentJoin, predicates); <START> myQueryRootStack.setHasIndexJoins(); <END> myQueryRootStack.addPredicates(predicates); }</code><technical_language>This niggles me. ensuring explicitly call this in right places, a side effect of adding a join predicate? if for some reason, walk query tree end deduce a join</technical_language>

Target:
void addPredicateParamMissingForReference(String theResourceName, String theParamName, boolean theMissing, RequestPartitionId theRequestPartitionId) { From<?, SearchParamPresent> paramPresentJoin = myQueryStack.createJoin(SearchBuilderJoinEnum.PRESENCE, null); Expression<Long> hashPresence = paramPresentJoin.get("myHashPresence").as(Long.class); Long hash = SearchParamPresent.calculateHashPresence(myPartitionSettings, theRequestPartitionId, theResourceName, theParamName, !theMissing); List<Predicate> predicates = new ArrayList<>(); predicates.add(myCriteriaBuilder.equal(hashPresence, hash)); addPartitionIdPredicate(theRequestPartitionId, paramPresentJoin, predicates); myQueryStack.addPredicatesWithImplicitTypeSelection(predicates); }
Source:
<code>public void shouldCreateNewDruReferenceMap() throws Exception { final String JSON = "{\n" + " \"conceptReferenceTerm\":\"ee7693a0-8a55-22e3-8507-1f26fdd6e3f3\"\n" + ",\n" + " \"conceptMapType\": \"sece2323fa-0fa0-461f-9b59-6765997d84\"\n" + ",\n" + " \"drug\": \"8e2323fa-0fa0-461f-9b59-6765997d849d\"\n" + "}"; Drug drug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> maps = drug.getDrugReferenceMaps(); Assert.assertEquals(1, maps.size()); MockHttpServletRequest req = newPostRequest(getURI(), JSON); <START> Set<DrugReferenceMap> updatedMaps = drug.getDrugReferenceMaps(); <END> SimpleObject result = deserialize(handle(req)); Assert.assertEquals(2, updatedMaps.size()); Assert.assertEquals(RestTestConstants1_10.CONCEPT_REF_TERM_UUID, Util.getByPath(result, "conceptReferenceTerm/uuid")); Assert.assertEquals(RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID, Util.getByPath(result, "conceptMapType/uuid")); Assert.assertEquals(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID, Util.getByPath(result, "drug/uuid")); Assert.assertEquals("Panadol - concept_map_type2", Util.getByPath(result, "display")); }</code><technical_language>I fetch drug posting</technical_language>

Target:
public void shouldCreateNewDruReferenceMap() throws Exception { final String JSON = "{\n" + " \"conceptReferenceTerm\":\"" + RestTestConstants1_10.CONCEPT_REF_TERM_UUID + "\"\n" + ",\n" + " \"conceptMapType\": \"" + RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID + "\"\n" + ",\n" + " \"drug\": \"" + RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID + "\"\n" + "}"; Drug drug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> maps = drug.getDrugReferenceMaps(); Assert.assertEquals(1, maps.size()); MockHttpServletRequest req = newPostRequest(getURI(), JSON); MockHttpServletResponse resp = handle(req); Drug updatedDrug = conceptService.getDrugByUuid(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID); Set<DrugReferenceMap> updatedMaps = updatedDrug.getDrugReferenceMaps(); Assert.assertEquals(2, updatedMaps.size()); SimpleObject result = deserialize(resp); Assert.assertEquals(RestTestConstants1_10.CONCEPT_REF_TERM_UUID, Util.getByPath(result, "conceptReferenceTerm/uuid")); Assert.assertEquals(RestTestConstants1_10.CONCEPT_MAP_TYPE_UUID, Util.getByPath(result, "conceptMapType/uuid")); Assert.assertEquals(RestTestConstants1_10.DRUG_REFERENCE_DRUG_UUID, Util.getByPath(result, "drug/uuid")); Assert.assertEquals("Panadol - concept_map_type2", Util.getByPath(result, "display")); }
Source:
<code><START> public VelocityAdminMode(final HttpServletRequest request, final HttpServletResponse response, final IHTMLPage htmlPage, <END> final Host host) { super(request, response, htmlPage, host); }</code><technical_language>constructor for compatibility deprecate if necessary</technical_language>

Target:
protected VelocityAdminMode(final HttpServletRequest request, final HttpServletResponse response, final IHTMLPage htmlPage, final Host host) { super(request, response, htmlPage, host); }
Source:
<code>private Engine.IndexResult index(Engine engine, Engine.Index index) throws IOException { active.set(true); final Engine.IndexResult result; index = indexingOperationListeners.preIndex(shardId, index); try { if (logger.isTraceEnabled()) { logger.trace( "index [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin()); } result = engine.index(index); <START> if (logger.isTraceEnabled()) { <END> logger.trace( "index-done [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin " + "result-seq# result-term failure [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin(), result.getSeqNo(), result.getTerm(), result.getFailure()); } } catch (Exception e) { if (logger.isTraceEnabled()) { logger.trace(new ParameterizedMessage( "index-fail [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin() ), e); } indexingOperationListeners.postIndex(shardId, index, e); throw e; } indexingOperationListeners.postIndex(shardId, index, result); return result; }</code><technical_language>extract this a local variable avoid multiple calls</technical_language>

Target:
private Engine.IndexResult index(Engine engine, Engine.Index index) throws IOException { active.set(true); final Engine.IndexResult result; index = indexingOperationListeners.preIndex(shardId, index); boolean traceEnabled = logger.isTraceEnabled(); try { if (traceEnabled) { logger.trace( "index [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin()); } result = engine.index(index); if (traceEnabled) { logger.trace( "index-done [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin " + "result-seq# result-term failure [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin(), result.getSeqNo(), result.getTerm(), result.getFailure()); } } catch (Exception e) { if (traceEnabled) { logger.trace(new ParameterizedMessage( "index-fail [{}][{}] seq# allocation-id primaryTerm operationPrimaryTerm origin [{}]", index.type(), index.id(), index.seqNo(), routingEntry().allocationId(), index.primaryTerm(), operationPrimaryTerm, index.origin() ), e); } indexingOperationListeners.postIndex(shardId, index, e); throw e; } indexingOperationListeners.postIndex(shardId, index, result); return result; }
Source:
<code>public void getDataContext() { final String key1 = "Key1"; final String value1 = "first-value"; Context context = new Context(key1, value1); Optional<Object> optionalObject = context.getData(key1); <START> System.out.printf("Key1 value : %s%n", optionalObject.get().toString()); <END> END: com.azure.core.util.context.getData#object }</code><technical_language>I of optional in case key1's exist. java if (optionalObject.isPresent()) { System.out.printf("Key1 value: %s%n", optionalObject.get()); } else { System.out.println("Key1 exist data."); }</technical_language>

Target:
public void getDataContext() { final String key1 = "Key1"; final String value1 = "first-value"; Context context = new Context(key1, value1); Optional<Object> optionalObject = context.getData(key1); if (optionalObject.isPresent()) { System.out.printf("Key1 value: %s%n", optionalObject.get()); } else { System.out.println("Key1 does not exist or have data."); } END: com.azure.core.util.context.getData#object }
Source:
<code>private static void getInput(SqlNode node, ArrayList<String> inputSource) { if (node instanceof SqlJoin) { SqlJoin joinNode = (SqlJoin) node; ArrayList<String> inputsLeft = new ArrayList<>(); ArrayList<String> inputsRight = new ArrayList<>(); getInput(joinNode.getLeft(), inputsLeft); getInput(joinNode.getRight(), inputsRight); if (!inputsLeft.isEmpty() && !inputsRight.isEmpty()) { <START> throw new SamzaException("Joins on two entities are not supported yet"); <END> } inputSource.addAll(inputsLeft); inputSource.addAll(inputsRight); } else if (node instanceof SqlIdentifier) { inputSource.add(node.toString()); } else if (node instanceof SqlBasicCall) { SqlBasicCall basicCall = ((SqlBasicCall) node); if (basicCall.getOperator() instanceof SqlAsOperator) { getInput(basicCall.operand(0), inputSource); } } }</code><technical_language>This means join is supported this moment. Is case a join side of input? If not, I suggest fail earlier get inputs</technical_language>

Target:
private static void getInput(SqlNode node, ArrayList<String> inputSource) { if (node instanceof SqlJoin) { SqlJoin joinNode = (SqlJoin) node; ArrayList<String> inputsLeft = new ArrayList<>(); ArrayList<String> inputsRight = new ArrayList<>(); getInput(joinNode.getLeft(), inputsLeft); getInput(joinNode.getRight(), inputsRight); if (!inputsLeft.isEmpty() && !inputsRight.isEmpty()) { throw new SamzaException("Joins on two entities are not supported yet"); } inputSource.addAll(inputsLeft); inputSource.addAll(inputsRight); } else if (node instanceof SqlIdentifier) { inputSource.add(node.toString()); } else if (node instanceof SqlBasicCall) { SqlBasicCall basicCall = ((SqlBasicCall) node); if (basicCall.getOperator() instanceof SqlAsOperator) { getInput(basicCall.operand(0), inputSource); } else if (basicCall.getOperator() instanceof SqlUnnestOperator && basicCall.operand(0) instanceof SqlSelect) { inputSource.add(getInputFromSelectQuery(basicCall.operand(0))); return; } } else if (node instanceof SqlSelect) { getInput(((SqlSelect) node).getFrom(), inputSource); } }
Source:
<code>public void testCloseFailedChunkedInput() { Exception error = new Exception("Unable to produce a chunk"); ThrowingChunkedInput input = new ThrowingChunkedInput(error); EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler()); try { <START> ch.writeAndFlush(input).sync(); <END> fail("Exception expected"); } catch (Exception e) { assertEquals(error, e); } assertTrue(input.closed); }</code><technical_language>replace writeOutbound(...)</technical_language>

Target:
public void testCloseFailedChunkedInput() { Exception error = new Exception("Unable to produce a chunk"); ThrowingChunkedInput input = new ThrowingChunkedInput(error); EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler()); try { ch.writeOutbound(input); fail("Exception expected"); } catch (Exception e) { assertEquals(error, e); } assertTrue(input.isClosed()); assertFalse(ch.finish()); }
Source:
<code>public void ignoreConstraintAnnotationsOnParameter(Member member, int index) { if ( annotationIgnoresForMethodParameter.get( member ) == null ) { <START> List<Integer> tmpList = new ArrayList<Integer>(); <END> tmpList.add( index ); annotationIgnoresForMethodParameter.put( member, tmpList ); } else { annotationIgnoresForMethodParameter.get( member ).add( index ); } }</code><technical_language>newArrayList()</technical_language>

Target:
public void ignoreConstraintAnnotationsOnParameter(Member member, int index) { if ( annotationIgnoresForMethodParameter.get( member ) == null ) { List<Integer> tmpList = newArrayList(); tmpList.add( index ); annotationIgnoresForMethodParameter.put( member, tmpList ); } else { annotationIgnoresForMethodParameter.get( member ).add( index ); } }
Source:
<code>private boolean isEventCrfCompleted(EventCrf eventCrf) { if(eventCrf.getStatusId() == EventCRFStatus.INITIAL_DATA_ENTRY_COMPLETE.getCode()) { return true; }else if(eventCrf.getStatusId() == EventCRFStatus.DOUBLE_DATA_ENTRY_COMPLETE.getCode()) { return true; <START> }else if(eventCrf.getStatusId() == 2) { <END> return true; }else { return false; } }</code><technical_language>Do numbers for statuses, enum names instead, clearer others read code understand</technical_language>

Target:
private boolean isEventCrfCompleted(EventCrf eventCrf) { if(eventCrf.getStatusId() == Status.UNAVAILABLE.getCode()) { return true; }else { return false; } }
Source:
<code>public TurboIssueEventTests() { sampleEvents = new ArrayList<>(); sampleEvents.add( new TurboIssueEvent( new User().setLogin("A"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0).getTime()) .setLabelName("A1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("A"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 2, 0).getTime()) .setLabelName("A2")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 0, 30).getTime()) .setLabelName("B1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0).getTime()) .setLabelName("B2")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("B"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 1, 31).getTime()) .setLabelName("B1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("C"), IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 2, 30, 15).getTime()) .setLabelName("C1")); sampleEvents.add( new TurboIssueEvent( new User().setLogin("D"), IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 3, 20, 59).getTime()) <START> .setLabelName("D1")); <END> }</code><technical_language>a block of code is repeated times. Is abstract a small utility method</technical_language>

Target:
public TurboIssueEventTests() { sampleEvents = new ArrayList<>(); sampleEvents.add( createLabelUpdateEvent("A", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0), "A1")); sampleEvents.add( createLabelUpdateEvent("A", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 2, 0), "A2")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 0, 30), "B1")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 1, 1, 0), "B2")); sampleEvents.add( createLabelUpdateEvent("B", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 1, 1, 31), "B1")); sampleEvents.add( createLabelUpdateEvent("C", IssueEventType.Labeled, new GregorianCalendar(2015, 1, 1, 2, 30, 15), "C1")); sampleEvents.add( createLabelUpdateEvent("D", IssueEventType.Unlabeled, new GregorianCalendar(2015, 1, 1, 3, 20, 59), "D1")); }
Source:
<code>private void addFieldMapping(JsonObject payload, EntityIndexBinding descriptor, DocumentFieldMetadata fieldMetadata) { String simpleFieldName = FieldHelper.getEmbeddedFieldPropertyName( fieldMetadata.getName() ); JsonObject field = new JsonObject(); String fieldType = getFieldType( descriptor, fieldMetadata ); if ( fieldType == null ) { LOG.debug( "Not adding a mapping for field " + fieldMetadata.getFieldName() + " as its type could not be determined" ); return; } field.addProperty( "type", fieldType ); field.addProperty( "store", fieldMetadata.getStore() == Store.NO ? false : true ); String index = getIndex( descriptor, fieldMetadata ); field.addProperty( "index", index ); <START> if ( "no".equals( index ) && FieldHelper.isSortableField(descriptor, fieldMetadata.getFieldName()) ) { <END> field.addProperty( "doc_values", true ); } String analyzerName = getAnalyzerName( descriptor, fieldMetadata, index ); if ( analyzerName != null ) { field.addProperty( "analyzer", analyzerName ); } if ( fieldMetadata.getBoost() != null ) { field.addProperty( "boost", fieldMetadata.getBoost() ); } if ( fieldMetadata.indexNullAs() != null ) { field.addProperty( "null_value", fieldMetadata.indexNullAs() ); } getOrCreateProperties( payload, fieldMetadata.getName() ).add( simpleFieldName, field ); for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) { if ( !facetMetadata.getFacetName().equals( fieldMetadata.getFieldName() ) ) { addFieldMapping( payload, facetMetadata ); } } }</code><technical_language>Formatting (padding in parenthesis)</technical_language>

Target:
private void addFieldMapping(JsonObject payload, EntityIndexBinding descriptor, DocumentFieldMetadata fieldMetadata) { String simpleFieldName = FieldHelper.getEmbeddedFieldPropertyName( fieldMetadata.getName() ); JsonObject field = new JsonObject(); String fieldType = getFieldType( descriptor, fieldMetadata ); if ( fieldType == null ) { LOG.debug( "Not adding a mapping for field " + fieldMetadata.getFieldName() + " as its type could not be determined" ); return; } field.addProperty( "type", fieldType ); field.addProperty( "store", fieldMetadata.getStore() == Store.NO ? false : true ); addIndexOptions( field, descriptor, fieldMetadata.getName(), fieldType, fieldMetadata.getIndex(), fieldMetadata.getAnalyzerReference() ); if ( fieldMetadata.getBoost() != null ) { field.addProperty( "boost", fieldMetadata.getBoost() ); } if ( fieldMetadata.indexNullAs() != null ) { field.addProperty( "null_value", fieldMetadata.indexNullAs() ); } getOrCreateProperties( payload, fieldMetadata.getName() ).add( simpleFieldName, field ); for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) { if ( !facetMetadata.getFacetName().equals( fieldMetadata.getFieldName() ) ) { addFieldMapping( payload, facetMetadata ); } } }
Source:
<code>public void testTimedInterface() { final IDummy dummy = TimedInterface.newProxy(IDummy.class, new DummyImpl(), "id"); DefaultMonitorRegistry.getInstance().register((CompositeMonitor)dummy); for (int i = 0; i < 42; i++) { dummy.method1(); if (i % 2 == 0) { dummy.method2(i); } } final CompositeMonitor<Long> compositeMonitor = (CompositeMonitor<Long>) dummy; final List<Monitor<?>> monitors = compositeMonitor.getMonitors(); assertEquals(monitors.size(), 2); assertEquals(compositeMonitor.getValue().longValue(), 2L); final TagList tagList = BasicTagList.of( TimedInterface.CLASS_TAG, "DummyImpl", TimedInterface.INTERFACE_TAG, "IDummy", TimedInterface.ID_TAG, "id"); final MonitorConfig expectedConfig = MonitorConfig.builder(TimedInterface.TIMED_INTERFACE) .withTags(tagList).build(); assertEquals(compositeMonitor.getConfig(), expectedConfig); for (Monitor<?> monitor: monitors) { final MonitorConfig config = monitor.getConfig(); final String method = config.getName(); final MonitorConfig expected = MonitorConfig.builder(method).withTags(tagList).build(); assertEquals(config, expected); if (method.equals("method1")) { long value = ((Monitor<Long>) monitor).getValue() - 5; <START> assertTrue(value >= 0 && value <= 4); <END> } else { assertEquals(method, "method2"); long value = ((Monitor<Long>) monitor).getValue() - 15; assertTrue(value >= 0 && value <= 4); } } }</code><technical_language>this help. A sleep for 5ms give time for other stuff machine in if is heavily loaded. I some systems (maybe Windows?) resolution of sleep 10ms sleep for that</technical_language>

Target:
public void testTimedInterface() { final IDummy dummy = TimedInterface.newProxy(IDummy.class, new DummyImpl(), "id"); DefaultMonitorRegistry.getInstance().register((CompositeMonitor)dummy); for (int i = 0; i < 42; i++) { dummy.method1(); if (i % 2 == 0) { dummy.method2(i); } } final CompositeMonitor<Long> compositeMonitor = (CompositeMonitor<Long>) dummy; final List<Monitor<?>> monitors = compositeMonitor.getMonitors(); assertEquals(monitors.size(), 2); assertEquals(compositeMonitor.getValue().longValue(), 2L); final TagList tagList = BasicTagList.of( TimedInterface.CLASS_TAG, "DummyImpl", TimedInterface.INTERFACE_TAG, "IDummy", TimedInterface.ID_TAG, "id"); final MonitorConfig expectedConfig = MonitorConfig.builder(TimedInterface.TIMED_INTERFACE) .withTags(tagList).build(); assertEquals(compositeMonitor.getConfig(), expectedConfig); for (Monitor<?> monitor: monitors) { final MonitorConfig config = monitor.getConfig(); final String method = config.getName(); final MonitorConfig expected = MonitorConfig.builder(method).withTags(tagList).build(); assertEquals(config, expected); if (method.equals("method1")) { long value = ((Monitor<Long>) monitor).getValue() - 20; assertTrue(value >= 0 && value <= 9); } else { assertEquals(method, "method2"); long value = ((Monitor<Long>) monitor).getValue() - 40; assertTrue(value >= 0 && value <= 9); } } }
Source:
<code>public ServerAddressMacroRegistrar( EventBus eventBus, Provider<MacroRegistry> macroRegistryProvider, AppContext appContext, WsAgentServerUtil wsAgentServerUtil) { this.macroRegistryProvider = macroRegistryProvider; this.appContext = appContext; this.wsAgentServerUtil = wsAgentServerUtil; eventBus.addHandler( BasicIDEInitializedEvent.TYPE, e -> { if (appContext.getWorkspace().getStatus() == RUNNING) { registerMacros(); } }); eventBus.addHandler(WorkspaceRunningEvent.TYPE, e -> registerMacros()); eventBus.addHandler( WorkspaceStoppedEvent.TYPE, e -> { <START> if (macros != null) { <END> macros.forEach(macro -> macroRegistryProvider.get().unregister(macro)); macros.clear(); } }); }</code><technical_language>a constructor initialize macros empty set avoid null checking</technical_language>

Target:
public ServerAddressMacroRegistrar( EventBus eventBus, Provider<MacroRegistry> macroRegistryProvider, AppContext appContext, WsAgentServerUtil wsAgentServerUtil) { this.macroRegistryProvider = macroRegistryProvider; this.appContext = appContext; this.wsAgentServerUtil = wsAgentServerUtil; eventBus.addHandler( BasicIDEInitializedEvent.TYPE, e -> { if (appContext.getWorkspace().getStatus() == RUNNING) { registerMacros(); } }); eventBus.addHandler(WorkspaceRunningEvent.TYPE, e -> registerMacros()); eventBus.addHandler( WorkspaceStoppedEvent.TYPE, e -> { macros.forEach(macro -> macroRegistryProvider.get().unregister(macro)); macros.clear(); }); }
Source:
<code>MessageQueue(boolean singleReaderMode, int publishHighwaterMark) { <START> this.queue = new LinkedBlockingQueue<NatsMessage>(); <END> this.running = new AtomicInteger(RUNNING); this.sizeInBytes = new AtomicLong(0); this.length = new AtomicLong(0); this.poisonPill = new NatsMessage("_poison", null, NatsConnection.EMPTY_BODY, false); this.filterLock = new ReentrantLock(); this.singleThreadedReader = singleReaderMode; }</code><technical_language>a publish buffer, set infinite reconnect. I analogous buffer in other clients</technical_language>

Target:
MessageQueue(boolean singleReaderMode, int publishHighwaterMark) { this.queue = publishHighwaterMark > 0 ? new LinkedBlockingQueue<NatsMessage>(publishHighwaterMark) : new LinkedBlockingQueue<NatsMessage>(); this.running = new AtomicInteger(RUNNING); this.sizeInBytes = new AtomicLong(0); this.length = new AtomicLong(0); this.poisonPill = new NatsMessage("_poison", null, NatsConnection.EMPTY_BODY, false); this.filterLock = new ReentrantLock(); this.singleThreadedReader = singleReaderMode; }
Source:
<code>private void assertWarehouseLocationModel(DefaultStructuredMetadataModel warehouselocationModel) { <START> Assert.assertThat(warehouselocationModel.getFields().size(), CoreMatchers.is(2)); <END> Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(0).getName(), CoreMatchers.is("latitude")); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(1).getName(), CoreMatchers.is("longitude")); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); }</code><technical_language>IsCollectionWithSize matcher</technical_language>

Target:
private void assertWarehouseLocationModel(DefaultStructuredMetadataModel warehouselocationModel) { Assert.assertThat(warehouselocationModel.getFields(), IsCollectionWithSize.hasSize(2)); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(0).getName(), CoreMatchers.is("latitude")); Assert.assertThat(warehouselocationModel.getFields().get(0).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel(), CoreMatchers.instanceOf(DefaultSimpleMetaDataModel.class)); Assert.assertThat(warehouselocationModel.getFields().get(1).getName(), CoreMatchers.is("longitude")); Assert.assertThat(warehouselocationModel.getFields().get(1).getMetaDataModel().getDataType(), CoreMatchers.is(DataType.NUMBER)); }
Source:
<code>private StorageServiceMBean newStorageService() { return (StorageServiceMBean) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{StorageServiceMBean.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); switch (name) { case "takeSnapshot": invocations.add("takeSnapshot"); return null; case "clearSnapshot": invocations.add("clearSnapshot"); return null; case "truncate": invocations.add("truncate"); return null; case "getAllDataFileLocations": <START> return new String[]{dataDir}; <END> default: throw new UnsupportedOperationException(name); } } }); }</code><technical_language>this a single string for add support for multiple locations. is confusing hard coding index 0 elsewhere</technical_language>

Target:
private StorageServiceMBean newStorageService() { return (StorageServiceMBean) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{StorageServiceMBean.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); switch (name) { case "takeSnapshot": invocations.add("takeSnapshot"); return null; case "clearSnapshot": invocations.add("clearSnapshot"); return null; case "getAllDataFileLocations": return new String[]{dataDir}; default: throw new UnsupportedOperationException(name); } } }); }
Source:
<code>public Object inject(Object instance) throws InjectionProviderException { <START> return instance; <END> }</code><technical_language>I this return null, similar default MyFaces implementation of InjectionProvider</technical_language>

Target:
public Object inject(Object instance) throws InjectionProviderException { return null; }
Source:
<code>private void checkStripeExecutorView(StripedExecutor execSvc, String viewName, String poolName) throws Exception { CountDownLatch latch = new CountDownLatch(1); <START> execSvc.execute(0, new SystemViewSelfTest.TestRunnable(latch, 0)); <END> execSvc.execute(0, new SystemViewSelfTest.TestRunnable(latch, 1)); execSvc.execute(1, new SystemViewSelfTest.TestRunnable(latch, 2)); execSvc.execute(1, new SystemViewSelfTest.TestRunnable(latch, 3)); try { boolean res = waitForCondition(() -> systemView(viewName).size() == 2, 5_000); assertTrue(res); TabularDataSupport view = systemView(viewName); CompositeData row0 = view.get(new Object[] {0}); assertEquals(0, row0.get("stripeIndex")); assertEquals(SystemViewSelfTest.TestRunnable.class.getSimpleName() + '1', row0.get("description")); assertEquals(poolName + "-stripe-0", row0.get("threadName")); assertEquals(SystemViewSelfTest.TestRunnable.class.getName(), row0.get("taskName")); CompositeData row1 = view.get(new Object[] {1}); assertEquals(1, row1.get("stripeIndex")); assertEquals(SystemViewSelfTest.TestRunnable.class.getSimpleName() + '3', row1.get("description")); assertEquals(poolName + "-stripe-1", row1.get("threadName")); assertEquals(SystemViewSelfTest.TestRunnable.class.getName(), row1.get("taskName")); } finally { latch.countDown(); } }</code><technical_language>import TestRunnable class</technical_language>

Target:
private void checkStripeExecutorView(StripedExecutor execSvc, String viewName, String poolName) throws Exception { CountDownLatch latch = new CountDownLatch(1); execSvc.execute(0, new TestRunnable(latch, 0)); execSvc.execute(0, new TestRunnable(latch, 1)); execSvc.execute(1, new TestRunnable(latch, 2)); execSvc.execute(1, new TestRunnable(latch, 3)); try { boolean res = waitForCondition(() -> systemView(viewName).size() == 2, 5_000); assertTrue(res); TabularDataSupport view = systemView(viewName); CompositeData row0 = view.get(new Object[] {0}); assertEquals(0, row0.get("stripeIndex")); assertEquals(TestRunnable.class.getSimpleName() + '1', row0.get("description")); assertEquals(poolName + "-stripe-0", row0.get("threadName")); assertEquals(TestRunnable.class.getName(), row0.get("taskName")); CompositeData row1 = view.get(new Object[] {1}); assertEquals(1, row1.get("stripeIndex")); assertEquals(TestRunnable.class.getSimpleName() + '3', row1.get("description")); assertEquals(poolName + "-stripe-1", row1.get("threadName")); assertEquals(TestRunnable.class.getName(), row1.get("taskName")); } finally { latch.countDown(); } }
Source:
<code>private void loadChapterOrganizers(Directory directory) { <START> if (Strings.isNullOrEmpty(serializedOrganizers)) { <END> return; } String[] organizers = serializedOrganizers.split(ID_SEPARATOR_FOR_SPLIT); for (String organizerId : organizers) { Chapter organizerChapter = null; for (Chapter chapter : directory.getGroups()) { if (chapter.getOrganizers().contains(organizerId)) { organizerChapter = chapter; break; } } if (organizerChapter != null) { final Organizer organizer = new Organizer(); organizer.setPlusId(organizerId); organizer.setChapterName(organizerChapter.getName()); organizer.setChapterId(organizerChapter.getGplusId()); Plus.PeopleApi.load(getGoogleApiClient(), organizer.getPlusId()) .setResultCallback(new ResultCallback<People.LoadPeopleResult>() { @Override public void onResult(People.LoadPeopleResult loadPeopleResult) { organizer.setResolved(loadPeopleResult.getPersonBuffer().get(0)); adapter.add(organizer); adapter.notifyDataSetChanged(); } }); } } }</code><technical_language>TextUtils.isEmpty() for this. Thank :small_blue_diamond:</technical_language>

Target:
private void loadChapterOrganizers(Directory directory) { if (TextUtils.isEmpty(serializedOrganizers)) { return; } String[] organizers = serializedOrganizers.split(ID_SEPARATOR_FOR_SPLIT); for (String organizerId : organizers) { Chapter organizerChapter = null; for (Chapter chapter : directory.getGroups()) { if (chapter.getOrganizers().contains(organizerId)) { organizerChapter = chapter; break; } } if (organizerChapter != null) { final Organizer organizer = new Organizer(); organizer.setPlusId(organizerId); organizer.setChapterName(organizerChapter.getName()); organizer.setChapterId(organizerChapter.getGplusId()); Plus.PeopleApi.load(getGoogleApiClient(), organizer.getPlusId()) .setResultCallback(new ResultCallback<People.LoadPeopleResult>() { @Override public void onResult(People.LoadPeopleResult loadPeopleResult) { organizer.setResolved(loadPeopleResult.getPersonBuffer().get(0)); adapter.add(organizer); adapter.notifyDataSetChanged(); } }); } } }
Source:
<code>void handleBatch(final PlanContext planContext) { <START> final BatchBuilder<K, T> batchBuilder = _batches.remove(planContext.getId()); <END> if (batchBuilder != null) { final Batch<K, T> batch = batchBuilder.build(); if (batch.size() > 0) { try { final Map<G, Batch<K, T>> batches = split(batch); if (batches.size() > 0) { taskForBatches(batches.entrySet()).forEach(task -> new ContextImpl(planContext, task).runTask()); } } catch (Throwable t) { batch.failAllRemaining(t); } } } }</code><technical_language>BatchBuilder is added _batches if batchable task is created. removed, Tasks in plan plan context, this is guaranteed work. Do I right</technical_language>

Target:
void handleBatch(final PlanContext planContext) { final BatchBuilder<K, T> batchBuilder = _batches.remove(planContext.getId()); if (batchBuilder != null) { final Batch<K, T> batch = batchBuilder.build(); if (batch.size() > 0) { try { final Map<G, Batch<K, T>> batches = split(batch); if (batches.size() > 0) { taskForBatches(batches.entrySet()).forEach(task -> new ContextImpl(planContext, task).runTask()); } } catch (Throwable t) { batch.failAll(t); } } } }
Source:
<code>public void testSimpleSendAndReceive() throws Exception { final AtomicBoolean messageReceived = new AtomicBoolean(false); final CountDownLatch latch = new CountDownLatch(1); final QueueChannel channel = new QueueChannel(); ExecutorService exec = Executors.newSingleThreadExecutor(); exec.execute(() -> { Message<?> message = channel.receive(); if (message != null) { messageReceived.set(true); latch.countDown(); } }); assertFalse(messageReceived.get()); channel.send(new GenericMessage<String>("testing")); <START> latch.await(10000, TimeUnit.MILLISECONDS); <END> assertTrue(messageReceived.get()); exec.shutdownNow(); }</code><technical_language>miss assert await result</technical_language>

Target:
public void testSimpleSendAndReceive() throws Exception { final CountDownLatch latch = new CountDownLatch(1); final QueueChannel channel = new QueueChannel(); ExecutorService exec = Executors.newSingleThreadExecutor(); exec.execute(() -> { Message<?> message = channel.receive(); if (message != null) { latch.countDown(); } }); channel.send(new GenericMessage<String>("testing")); assertTrue(latch.await(10000, TimeUnit.MILLISECONDS)); exec.shutdownNow(); }
Source:
<code>public TrimResult trimFields(Project project, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) { for (Ord<RexNode> ord : Ord.zip(project.getProjects())) { if (fieldsUsed.get(ord.i)) { if (this.viewProjectToTableSchema != null && this.viewProjectToTableSchema.containsKey(project)) { Table tab = this.viewProjectToTableSchema.get(project); <START> if (this.directColumnAccessInfo != null) { this.directColumnAccessInfo.add(tab.getCompleteName(), tab.getAllCols().get(ord.i).getName()); } if (this.allColumnAccessInfo != null) { this.allColumnAccessInfo.add(tab.getCompleteName(), tab.getAllCols().get(ord.i).getName()); } <END> } } } return super.trimFields(project, fieldsUsed, extraFields); }</code><technical_language>this is duplicates ColumnAccessInfo a lot of places; sense extend ColumnAccessInfo internally; enable "mark" columns; add a method is able retrieve columns based usage not. right CAI is a Map< TableNameString, Set<ColumnNameString>>; changing this a Map<TableNameString, Set<ColumnAccess> ColumnAccess ColumnNameString some extra info is added here</technical_language>

Target:
public TrimResult trimFields(Project project, ImmutableBitSet fieldsUsed, Set<RelDataTypeField> extraFields) { if (this.columnAccessInfo != null && this.viewProjectToTableSchema != null && this.viewProjectToTableSchema.containsKey(project)) { for (Ord<RexNode> ord : Ord.zip(project.getProjects())) { if (fieldsUsed.get(ord.i)) { Table tab = this.viewProjectToTableSchema.get(project); this.columnAccessInfo.add(tab.getCompleteName(), tab.getAllCols().get(ord.i).getName()); } } } return super.trimFields(project, fieldsUsed, extraFields); }
Source:
<code>public <T extends ObjectId> AsyncRevObjectQueue parseAny( Iterable<T> objectIds, boolean reportMissing) { List<T> need = new ArrayList<T>(); List<RevObject> have = new ArrayList<RevObject>(); for (T id : objectIds) { RevObject r = objects.get(id); if (r != null && (r.flags & PARSED) != 0) have.add(r); else need.add(id); } final Iterator<RevObject> objItr = have.iterator(); if (need.isEmpty()) { return new AsyncRevObjectQueue() { public RevObject next() { return objItr.hasNext() ? objItr.next() : null; } public boolean cancel(boolean mayInterruptIfRunning) { return true; } public void release() { } }; } final AsyncObjectLoaderQueue<T> lItr = reader.open(need, reportMissing); return new AsyncRevObjectQueue() { public RevObject next() throws MissingObjectException, IncorrectObjectTypeException, IOException { if (objItr.hasNext()) return objItr.next(); if (!lItr.next()) return null; ObjectId id = lItr.getObjectId(); ObjectLoader ldr = lItr.open(); RevObject r = objects.get(id); if (r == null) r = parseNew(id, ldr); else if (r instanceof RevCommit) { <START> initializeShallowCommits(); <END> byte[] raw = ldr.getCachedBytes(); ((RevCommit) r).parseCanonical(RevWalk.this, raw); } else if (r instanceof RevTag) { byte[] raw = ldr.getCachedBytes(); ((RevTag) r).parseCanonical(RevWalk.this, raw); } else r.flags |= PARSED; return r; } public boolean cancel(boolean mayInterruptIfRunning) { return lItr.cancel(mayInterruptIfRunning); } public void release() { lItr.release(); } }; }</code><technical_language>I suggest this in constructor, in dispose, commit is processed</technical_language>

Target:
public <T extends ObjectId> AsyncRevObjectQueue parseAny( Iterable<T> objectIds, boolean reportMissing) { List<T> need = new ArrayList<T>(); List<RevObject> have = new ArrayList<RevObject>(); for (T id : objectIds) { RevObject r = objects.get(id); if (r != null && (r.flags & PARSED) != 0) have.add(r); else need.add(id); } final Iterator<RevObject> objItr = have.iterator(); if (need.isEmpty()) { return new AsyncRevObjectQueue() { public RevObject next() { return objItr.hasNext() ? objItr.next() : null; } public boolean cancel(boolean mayInterruptIfRunning) { return true; } public void release() { } }; } final AsyncObjectLoaderQueue<T> lItr = reader.open(need, reportMissing); return new AsyncRevObjectQueue() { public RevObject next() throws MissingObjectException, IncorrectObjectTypeException, IOException { if (objItr.hasNext()) return objItr.next(); if (!lItr.next()) return null; ObjectId id = lItr.getObjectId(); ObjectLoader ldr = lItr.open(); RevObject r = objects.get(id); if (r == null) r = parseNew(id, ldr); else if (r instanceof RevCommit) { byte[] raw = ldr.getCachedBytes(); ((RevCommit) r).parseCanonical(RevWalk.this, raw); } else if (r instanceof RevTag) { byte[] raw = ldr.getCachedBytes(); ((RevTag) r).parseCanonical(RevWalk.this, raw); } else r.flags |= PARSED; return r; } public boolean cancel(boolean mayInterruptIfRunning) { return lItr.cancel(mayInterruptIfRunning); } public void release() { lItr.release(); } }; }
Source:
<code>public Command perform(Object... args) { String id = (String) args[0]; boolean verbose = true; if (args.length > 1) { <START> if (args[1] instanceof Boolean) { <END> verbose = (Boolean) args[1]; } } if (controller.getModel().getScenes().size() == 1) { if (verbose) { controller.getViews().showDialog( InfoDialogBuilder.NAME, controller.getApplicationAssets().getI18N() .m("scene.delete.error-message")); } } else { EditorGame game = controller.getModel().getGame(); List<Command> commandList = new ArrayList<Command>(); String alternateScene = null; if (game.getEditScene().equals(id)) { alternateScene = findAlternateScene(id); commandList.add(new FieldCommand(game, FieldNames.EDIT_SCENE, alternateScene, false)); } if (controller.getModel().getGame().getInitialScene().equals(id)) { if (alternateScene != null) { alternateScene = findAlternateScene(id); } commandList.add(new FieldCommand(controller.getModel() .getGame(), FieldNames.INITIAL_SCENE, alternateScene, false)); } commandList.add(new MapCommand.RemoveFromMapCommand(controller .getModel().getScenes(), id)); commandList.add(new ListCommand.RemoveFromListCommand(game .getSceneorder(), id)); CompositeCommand deleteSceneCommand = new CompositeCommand( commandList); return deleteSceneCommand; } return null; }</code><technical_language>This check is necessary - done in validate()</technical_language>

Target:
public Command perform(Object... args) { String id = (String) args[0]; boolean verbose = true; if (args.length > 1) { verbose = (Boolean) args[1]; } if (controller.getModel().getScenes().size() == 1) { if (verbose) { controller.getViews().showDialog( InfoDialogBuilder.NAME, controller.getApplicationAssets().getI18N() .m("scene.delete.error-message")); } } else { EditorGame game = controller.getModel().getGame(); List<Command> commandList = new ArrayList<Command>(); String alternateScene = null; if (game.getEditScene().equals(id)) { alternateScene = findAlternateScene(id); commandList.add(new FieldCommand(game, FieldNames.EDIT_SCENE, alternateScene, false)); } if (controller.getModel().getGame().getInitialScene().equals(id)) { if (alternateScene != null) { alternateScene = findAlternateScene(id); } commandList.add(new FieldCommand(controller.getModel() .getGame(), FieldNames.INITIAL_SCENE, alternateScene, false)); } commandList.add(new MapCommand.RemoveFromMapCommand(controller .getModel().getScenes(), id)); commandList.add(new ListCommand.RemoveFromListCommand(game .getSceneorder(), id)); CompositeCommand deleteSceneCommand = new CompositeCommand( commandList); return deleteSceneCommand; } return null; }
Source:
<code>private Object[] transformParameters(Object[] params) { if (params == null) { return null; } Object[] result = new Object[params.length * 2]; <START> for (int stringIndex = 0, originalIndex = params.length; stringIndex < params.length; <END> ++stringIndex, ++originalIndex) { Object param = params[stringIndex]; if (param != null) { result[stringIndex] = param.toString(); result[originalIndex] = params[stringIndex]; } } return result; }</code><technical_language>I paramsIndex instead of originalIndex a name</technical_language>

Target:
private static Object[] transformParameters(Object[] params) { if (params == null) { return null; } Object[] result = new Object[params.length * 2]; for (int stringParamsIndex = 0, originalParamsIndex = params.length; stringParamsIndex < params.length; ++stringParamsIndex, ++originalParamsIndex) { Object param = params[stringParamsIndex]; if (param != null) { result[stringParamsIndex] = param.toString(); result[originalParamsIndex] = params[stringParamsIndex]; } } return result; }
Source:
<code>public static void main(String... args) { LOGGER.info("Starting Kafka Consumers"); final ExecutorService executor = Executors.newSingleThreadExecutor(); final ApnsConsumer apnsConsumer = new ApnsConsumer(); executor.submit(apnsConsumer); <START> Runtime.getRuntime().addShutdownHook(new Thread() { <END> @Override public void run() { apnsConsumer.shutdown(); executor.shutdown(); try { executor.awaitTermination(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { LOGGER.log(Level.SEVERE, "Error on close", ie); } } }); }</code><technical_language>lambdas</technical_language>

Target:
public static void main(String... args) { LOGGER.info("Starting Kafka Consumers"); final ExecutorService executor = Executors.newSingleThreadExecutor(); final ApnsConsumer apnsConsumer = new ApnsConsumer(); executor.submit(apnsConsumer); Runtime.getRuntime().addShutdownHook(new Thread(() -> { apnsConsumer.shutdown(); executor.shutdown(); try { executor.awaitTermination(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { LOGGER.log(Level.SEVERE, "Error on close", ie); } })); }
Source:
<code>private Constraint maximizeMergesPerWord(ConstraintFactory cf) { return cf.from(ScrabbleWordAssignment.class) <START> .join(ScrabbleCell.class, new FilteringBiJoiner<>((swa, sc) -> sc.getWordSet().contains(swa) && sc.hasMerge())) <END> .groupBy((swa, sc) -> swa.getId(), ConstraintCollectors.countBi()) .penalize("Maximize merges per word", HardMediumSoftScore.ONE_MEDIUM, (id, count) -> count * count); }</code><technical_language>Please replace FilteringBiJoiner Joiners.filtering(...)</technical_language>

Target:
private Constraint maximizeMergesPerWord(ConstraintFactory cf) { return cf.from(ScrabbleWordAssignment.class) .join(ScrabbleCell.class, Joiners.filtering((swa, sc) -> sc.getWordSet().contains(swa) && sc.hasMerge())) .groupBy((swa, sc) -> swa.getId(), ConstraintCollectors.countBi()) .reward("Maximize merges per word", HardMediumSoftScore.ONE_MEDIUM, (id, count) -> count * count); }
Source:
<code><START> public static synchronized JobValidatorRegistry getInstance() { <END> if (instance == null) { instance = new JobValidatorRegistry(); } return instance; }</code><technical_language>of [lazy holder pattern](<LINK_0> prevent conditional call</technical_language>

Target:
public static synchronized JobValidatorRegistry getInstance() { return LazyHolder.INSTANCE; }
Source:
<code>private void loadContacts() { showNoContactPermissionFragment(false); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_loading_contacts)); ContactsProvider.getContacts(this, new FullContactsListener() { @Override public void onGetContacts(final Set<ContactDataComplete> contacts, final ContactsProvider.Error error) { Lg.i("onGetContacts error=", error); <START> if (!mContactList.isVisible() && isFinishing()) { <END> Lg.i("onGetContacts the fragment went away"); return; } switch (error) { case NONE: mAdapter.setContacts(contacts); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_no_contacts_found)); break; case BUG: mAdapter.clear(); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_error_loading_contacts)); break; case NO_INTERNET_CONNECTION: mAdapter.clear(); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_error_loading_contacts_no_internet)); break; case PERMISSION_DENIED: showNoContactPermissionFragment(true); break; } GooglePlayServicesHelper.registerGcmIfNeeded(MainActivity.this); } }); }</code><technical_language>!mContactList.isVisible() || isFinishing()</technical_language>

Target:
private void loadContacts() { showNoContactPermissionFragment(false); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_loading_contacts)); ContactsProvider.getContacts(this, new FullContactsListener() { @Override public void onGetContacts(final Set<ContactDataComplete> contacts, final ContactsProvider.Error error) { Lg.i("onGetContacts error=", error); if (!mContactList.isVisible() || isFinishing()) { Lg.i("onGetContacts the fragment went away"); return; } switch (error) { case NONE: mAdapter.setContacts(contacts); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_no_contacts_found)); break; case BUG: mAdapter.clear(); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_error_loading_contacts)); break; case NO_INTERNET_CONNECTION: mAdapter.clear(); mContactList.setEmptyText(getString(R.string.main_activity_contact_list_error_loading_contacts_no_internet)); break; case PERMISSION_DENIED: showNoContactPermissionFragment(true); break; } GooglePlayServicesHelper.registerGcmIfNeeded(MainActivity.this); } }); }
Source:
<code>AnalyzedStatement analyzeShowTransaction(Analysis analysis) { <START> AnalyzedStatement analyzedStatement = analyzer.unboundAnalyze(rewriteShowTransaction(), <END> analysis.sessionContext(), ParamTypeHints.EMPTY); analysis.rootRelation((AnalyzedRelation) analyzedStatement); return analyzedStatement; }</code><technical_language>unboundAnalyze() helper method well</technical_language>

Target:
AnalyzedStatement analyzeShowTransaction(Analysis analysis) { return unboundAnalyze(rewriteShowTransaction(), analysis); }