auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>private void setInterpretationAndStatus(EncounterTransaction.Observation observation, Obs obs) { try { Method getInterpretation = obs.getClass().getDeclaredMethod("getInterpretation"); Method getStatus = obs.getClass().getDeclaredMethod("getStatus"); Enum obsInterpretation = (Enum) getInterpretation.invoke(obs); Enum obsStatus = (Enum) getStatus.invoke(obs); String interpretation = (obsInterpretation != null) ? obsInterpretation.name() : null; String status = (obsStatus != null) ? obsStatus.name() : null; observation.setInterpretation(interpretation); observation.setStatus(status); } catch (IllegalAccessException e) { <START> e.printStackTrace(); <END> } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }</code><technical_language>get a chance this? <LINK_0></technical_language>

Target:
private void setInterpretationAndStatus(EncounterTransaction.Observation observation, Obs obs) { try { Method getInterpretation = obs.getClass().getDeclaredMethod("getInterpretation"); Method getStatus = obs.getClass().getDeclaredMethod("getStatus"); Enum obsInterpretation = (Enum) getInterpretation.invoke(obs); Enum obsStatus = (Enum) getStatus.invoke(obs); String interpretation = (obsInterpretation != null) ? obsInterpretation.name() : null; String status = (obsStatus != null) ? obsStatus.name() : null; observation.setInterpretation(interpretation); observation.setStatus(status); } catch (IllegalAccessException e) { log.warn("Illegal access of methods via reflection", e); } catch (NoSuchMethodException e) { log.warn("No such method exists", e); } catch (InvocationTargetException e) { log.warn("Exception during Method invocation", e); } }
Source:
<code>public void testSymbolizerUoMOther() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); FeatureTypeStyle fts = fts(p); <START> p.setUnitOfMeasure(NonSI.ASTRONOMICAL_UNIT); <END> StringWriter out = new StringWriter(); exception.expect(IllegalArgumentException.class); Ysld.encode(sld(fts), out); }</code><technical_language>if relevant in context of test, "astronomical unit" is a light year: <LINK_0></technical_language>

Target:
public void testSymbolizerUoMOther() throws Exception { PointSymbolizer p = CommonFactoryFinder.getStyleFactory().createPointSymbolizer(); FeatureTypeStyle fts = fts(p); p.setUnitOfMeasure(USCustomary.LIGHT_YEAR); StringWriter out = new StringWriter(); exception.expect(IllegalArgumentException.class); Ysld.encode(sld(fts), out); }
Source:
<code>public void testInterruptsNotCached() throws Exception { final NettyTestUtil.NettyServerAndClient nettyServerAndClient = createNettyServerAndClient(); <START> ConnectionID connectionId = new ConnectionID(new InetSocketAddress( nettyServerAndClient.server().getConfig().getServerAddress(), nettyServerAndClient.server().getConfig().getServerPort()), 0); try { AwaitingNettyClient nettyClient = new AwaitingNettyClient(nettyServerAndClient.client()); PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0); nettyClient.awaitForInterrupts = true; connectAndInterrupt(factory, connectionId); <END> nettyClient.awaitForInterrupts = false; factory.createPartitionRequestClient(connectionId); } finally { nettyServerAndClient.client().shutdown(); nettyServerAndClient.server().shutdown(); } }</code><technical_language>leave is request a ConnectionID AwaitingNettyClient</technical_language>

Target:
public void testInterruptsNotCached() throws Exception { NettyTestUtil.NettyServerAndClient nettyServerAndClient = createNettyServerAndClient(); try { AwaitingNettyClient nettyClient = new AwaitingNettyClient(nettyServerAndClient.client()); PartitionRequestClientFactory factory = new PartitionRequestClientFactory(nettyClient, 0); nettyClient.awaitForInterrupts = true; connectAndInterrupt(factory, nettyServerAndClient.getConnectionID(0)); nettyClient.awaitForInterrupts = false; factory.createPartitionRequestClient(nettyServerAndClient.getConnectionID(0)); } finally { nettyServerAndClient.client().shutdown(); nettyServerAndClient.server().shutdown(); } }
Source:
<code>public AdvancedCache<String, V> getCache(String name, MediaType requestedMediaType) { if (requestedMediaType == null) { <START> throw new IllegalArgumentException("requestedMediaType cannot be null"); <END> } checkCacheAvailable(name); boolean matchesAll = requestedMediaType.matchesAll(); String cacheKey = matchesAll ? name : name + requestedMediaType.getTypeSubtype(); AdvancedCache<String, V> registered = knownCaches.get(cacheKey); if (registered != null) return registered; if (name.equals(PROTOBUF_METADATA_CACHE_NAME)) { return (AdvancedCache<String, V>) instance.getCache(PROTOBUF_METADATA_CACHE_NAME).getAdvancedCache() .withEncoding(UTF8CompatEncoder.class); } AdvancedCache<?, ?> encodedCache = getCache(name).getAdvancedCache(); Configuration cacheConfiguration = encodedCache.getCacheConfiguration(); if (cacheConfiguration.memory().storageType() == StorageType.OFF_HEAP) { encodedCache = encodedCache.withKeyEncoding(UTF8Encoder.class); } encodedCache = encodedCache.withMediaType(TEXT_PLAIN_TYPE, requestedMediaType.toString()); AdvancedCache<String, V> decoratedCache = (AdvancedCache<String, V>) encodedCache; knownCaches.putIfAbsent(cacheKey, decoratedCache); return decoratedCache; }</code><technical_language>I noticed a lot of throwing IllegalArgumentException for a null argument. I personally NullPointerException for this IllegalArgumentException is more a null is passed valid (ie. > 0 -3 something)</technical_language>

Target:
public AdvancedCache<String, V> getCache(String name, MediaType requestedMediaType) { if (requestedMediaType == null) { throw new NullPointerException("requestedMediaType cannot be null"); } checkCacheAvailable(name); boolean matchesAll = requestedMediaType.matchesAll(); String cacheKey = matchesAll ? name : name + requestedMediaType.getTypeSubtype(); AdvancedCache<String, V> registered = knownCaches.get(cacheKey); if (registered != null) return registered; if (name.equals(PROTOBUF_METADATA_CACHE_NAME)) { return (AdvancedCache<String, V>) instance.getCache(PROTOBUF_METADATA_CACHE_NAME).getAdvancedCache() .withEncoding(UTF8CompatEncoder.class); } AdvancedCache<?, ?> encodedCache = getCache(name).getAdvancedCache(); Configuration cacheConfiguration = encodedCache.getCacheConfiguration(); if (cacheConfiguration.memory().storageType() == StorageType.OFF_HEAP) { encodedCache = encodedCache.withKeyEncoding(UTF8Encoder.class); } encodedCache = encodedCache.withMediaType(TEXT_PLAIN_TYPE, requestedMediaType.toString()); AdvancedCache<String, V> decoratedCache = (AdvancedCache<String, V>) encodedCache; knownCaches.putIfAbsent(cacheKey, decoratedCache); return decoratedCache; }
Source:
<code>public void canBeSubmitted(PerunSession session, Map<String, String> params) throws PerunException { User user = session.getPerunPrincipal().getUser(); AttributesManager am = session.getPerun().getAttributesManager(); <START> <END> Attribute affiliations = am.getAttribute(session, user, A_U_D_userEduPersonScopedAffiliations); if (affiliations.getValue() != null) { LinkedHashMap<String, String> val = affiliations.valueAsMap(); for (String key: val.keySet()) { if (key.startsWith("faculty@")) { return; } } } Attribute rems = am.getAttribute(session, user, A_U_D_userBonaFideStatusRems); if (rems.getValue() != null) { return; } throw new CantBeSubmittedException("User does not meet the criteria for applying for Bona Fide Status"); }</code><technical_language>beforeApprove(), User object. present, if module is VO. is a wrap implementation catch exception translate generic CantBeSubmittedException user nicer message report error box</technical_language>

Target:
public void canBeSubmitted(PerunSession session, Map<String, String> params) throws PerunException { User user = session.getPerunPrincipal().getUser(); if (user == null) { throw new CantBeSubmittedException("This module can be set only for registration to Group."); } AttributesManager am = session.getPerun().getAttributesManager(); Attribute affiliations = am.getAttribute(session, user, A_U_D_userEduPersonScopedAffiliations); if (affiliations.getValue() != null) { LinkedHashMap<String, String> val = affiliations.valueAsMap(); for (String key: val.keySet()) { if (key.startsWith("faculty@")) { return; } } } Attribute rems = am.getAttribute(session, user, A_U_D_userBonaFideStatusRems); if (rems.getValue() != null) { return; } throw new CantBeSubmittedException("User does not meet the criteria for applying for Bona Fide Status"); }
Source:
<code>public void updateAuthorization(Authorization authorization, String groupName, HttpLocalizedOperationResult result, Username validUser) { UpdateAuthorizationCommand command = new UpdateAuthorizationCommand(groupName, authorization); try{ PipelineConfigsUpdateCommand updateCommand = new PipelineConfigsUpdateCommand(goConfigService, command, result, validUser, groupName); goConfigService.updateConfig(updateCommand, validUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { result.unprocessableEntity(LocalizedMessage.string("ENTITY_CONFIG_VALIDATION_FAILED")); } else { <START> result.internalServerError(LocalizedMessage.string("INTERNAL_SERVER_ERROR")); <END> } } }</code><technical_language>show error message result.internalServerError(LocalizedMessage.string("INTERNAL_SERVER_ERROR", e.getMessage()));</technical_language>

Target:
public void updateAuthorization(Authorization authorization, String groupName, HttpLocalizedOperationResult result, Username validUser) { UpdateAuthorizationCommand command = new UpdateAuthorizationCommand(groupName, authorization); try{ PipelineConfigsUpdateCommand updateCommand = new PipelineConfigsUpdateCommand(goConfigService, command, result, validUser, groupName); goConfigService.updateConfig(updateCommand, validUser); } catch (Exception e) { if (e instanceof GoConfigInvalidException) { result.unprocessableEntity(LocalizedMessage.string("ENTITY_CONFIG_VALIDATION_FAILED")); } else if(e instanceof ConfigUpdateCheckFailedException) { return; } else { result.internalServerError(LocalizedMessage.string("INTERNAL_SERVER_ERROR")); } } }
Source:
<code>SingleItemModel(String blogId, long date, String itemID, String title, int totals, String url, String icon) { this.mBlogID = blogId; this.mItemID = itemID; this.mTitle = title; this.mTotals = totals; <START> if (url == null || "null".equals(url) || "false".equals(url)) { <END> this.mUrl = ""; } else { this.mUrl = url; } this.mDate = date; this.mIcon = icon; }</code><technical_language><LINK_0> instead</technical_language>

Target:
SingleItemModel(String blogId, long date, String itemID, String title, int totals, String url, String icon) { this.mBlogID = blogId; this.mItemID = itemID; this.mTitle = title; this.mTotals = totals; if (!URLUtil.isValidUrl(url)) { this.mUrl = ""; } else { this.mUrl = url; } this.mDate = date; this.mIcon = icon; }
Source:
<code>public static Collection<Object[]> data() { List<Object[]> values = new ArrayList<>(); values.add(new Object[] {Collections.singletonList("TLSv1.2"), Collections.singletonList("TLSv1.2")}); if (Java.IS_JAVA11_COMPATIBLE) { values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Collections.singletonList("TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Arrays.asList("TLSv1.3", "TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Collections.singletonList("TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Arrays.asList("TLSv1.3", "TLSv1.2")}); <START> <END> } return values; }</code><technical_language>changes? I good</technical_language>

Target:
public static Collection<Object[]> data() { List<Object[]> values = new ArrayList<>(); values.add(new Object[] {Collections.singletonList("TLSv1.2"), Collections.singletonList("TLSv1.2")}); if (Java.IS_JAVA11_COMPATIBLE) { values.add(new Object[] {Collections.singletonList("TLSv1.2"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Collections.singletonList("TLSv1.3"), Collections.singletonList("TLSv1.2")}); values.add(new Object[] {Collections.singletonList("TLSv1.3"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Collections.singletonList("TLSv1.2"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Collections.singletonList("TLSv1.2"), Arrays.asList("TLSv1.3", "TLSv1.2")}); values.add(new Object[] {Collections.singletonList("TLSv1.3"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Collections.singletonList("TLSv1.3"), Arrays.asList("TLSv1.3", "TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Collections.singletonList("TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.3", "TLSv1.2"), Arrays.asList("TLSv1.3", "TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Collections.singletonList("TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Collections.singletonList("TLSv1.2")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Arrays.asList("TLSv1.2", "TLSv1.3")}); values.add(new Object[] {Arrays.asList("TLSv1.2", "TLSv1.3"), Arrays.asList("TLSv1.3", "TLSv1.2")}); } return values; }
Source:
<code>public static Region[] values() { Collection<Region> valuesCollection = VALUES_BY_NAME.values(); <START> return valuesCollection.toArray(new Region[valuesCollection.size()]); <END> }</code><technical_language>return collection instead of converting array</technical_language>

Target:
public static Collection<Region> values() { return VALUES_BY_NAME.values(); }
Source:
<code>public void <START> testNonAtomicPushWithOptions() <END> throws Exception { PushResult r; server.setPerformsAtomicTransactions(false); List<String> pushOptions = Arrays.asList("Hello", "World!"); try (Transport tn = testProtocol.open(uri, client, "server")) { tn.setPushAtomic(false); tn.setCapablePushOptions(true); tn.setPushOptions(pushOptions); r = tn.push(NullProgressMonitor.INSTANCE, commands()); } RemoteRefUpdate one = r.getRemoteUpdate("refs/heads/one"); RemoteRefUpdate two = r.getRemoteUpdate("refs/heads/two"); System.out.println("PushOptionsTest: receivePack.getPushOptions() = " + receivePack.getPushOptions()); assertSame(pushOptions, receivePack.getPushOptions()); assertSame(RemoteRefUpdate.Status.OK, one.getStatus()); assertSame(RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED, two.getStatus()); }</code><technical_language>Name fit does</technical_language>

Target:
public void testNonAtomicPushWithOptions() throws Exception { PushResult r; server.setPerformsAtomicTransactions(false); List<String> pushOptions = Arrays.asList("Hello", "World!"); try (Transport tn = testProtocol.open(uri, client, "server")) { tn.setPushAtomic(false); tn.setPushOptions(pushOptions); Map<String, RemoteRefUpdate> updates = new HashMap<>(); for (RemoteRefUpdate rru : commands()) { updates.put(rru.getRemoteName(), rru); } r = tn.push(NullProgressMonitor.INSTANCE, commands()); } RemoteRefUpdate one = r.getRemoteUpdate("refs/heads/one"); RemoteRefUpdate two = r.getRemoteUpdate("refs/heads/two"); assertSame(RemoteRefUpdate.Status.OK, one.getStatus()); assertSame(RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED, two.getStatus()); assertEquals(pushOptions, baseReceivePack.getPushOptions()); }
Source:
<code>protected void containerExists() throws Exception { Assert.assertTrue(this.blobStore.containerExists(this.container), "Container SHOULD exist"); <START> Assert.assertTrue(!this.blobStore.containerExists(String.valueOf(Calendar.getInstance().getTimeInMillis())), <END> "Container SHOULD NOT exist"); }</code><technical_language>Personal preference: I prefer Assert.assertFalse(condition) compared Assert.assertTrue(!condition)</technical_language>

Target:
protected void containerExists() throws Exception { Assert.assertTrue(this.blobStore.containerExists(this.container), "Container SHOULD exist"); Assert.assertFalse(this.blobStore.containerExists(String.valueOf(Calendar.getInstance().getTimeInMillis())), "Container SHOULD NOT exist"); }
Source:
<code>public RsXslt(final Response rsp, final URIResolver resolver) { super( <START> new RsOf( <END> rsp::head, () -> RsXslt.transform(rsp.body(), resolver) ) ); }</code><technical_language>@fanifieiev above</technical_language>

Target:
public RsXslt(final Response rsp, final URIResolver resolver) { super( new ResponseOf( rsp::head, () -> RsXslt.transform(rsp.body(), resolver) ) ); }
Source:
<code>protected void onFilterConfigSet() throws Exception { super.onFilterConfigSet(); try { <START> keys = getPlexusContainer().lookupMap( NexusApiKey.class ).keySet(); <END> } catch ( final Exception ignore ) { } }</code><technical_language>Cool, is component "name" is Header</technical_language>

Target:
protected void onFilterConfigSet() throws Exception { super.onFilterConfigSet(); if ( null == apiKeys ) { apiKeys = getPlexusContainer().lookupMap( NexusApiKey.class ).keySet(); } }
Source:
<code>public String generateDoc(PsiElement element, PsiElement originalElement) { if (element instanceof GoImportSpec) { element = ((GoImportSpec)element).getImportString().resolve(); } if (element instanceof GoNamedElement) { GoTopLevelDeclaration topLevel = PsiTreeUtil.getParentOfType(element, GoTopLevelDeclaration.class); Collection<PsiElement> children = PsiTreeUtil.findChildrenOfType(topLevel, element.getClass()); boolean alone = children.size() == 1 && children.iterator().next().equals(element); String result = getSignature(element); if (result != "") { <START> result = "<p><b>"+result+"</b></p>\n"; <END> } List<PsiComment> comments = getPreviousNonWsComment(alone ? topLevel : element); if (!comments.isEmpty()) result += getCommentText(comments); return result; } else if (element instanceof PsiDirectory) { String comments = getPackageComment(((PsiDirectory)element).findFile("doc.go")); if (comments != null) return comments; return getPackageComment(((PsiDirectory)element).findFile(((PsiDirectory)element).getName() + ".go")); } return null; }</code><technical_language>code style</technical_language>

Target:
public String generateDoc(PsiElement element, PsiElement originalElement) { if (element instanceof GoImportSpec) { element = ((GoImportSpec)element).getImportString().resolve(); } if (element instanceof GoNamedElement) { GoTopLevelDeclaration topLevel = PsiTreeUtil.getParentOfType(element, GoTopLevelDeclaration.class); Collection<PsiElement> children = PsiTreeUtil.findChildrenOfType(topLevel, element.getClass()); boolean alone = children.size() == 1 && children.iterator().next().equals(element); String result = getSignature(element); if (!result.isEmpty()) { result = "<p><b>" + result + "</b></p>\n"; } List<PsiComment> comments = getPreviousNonWsComment(alone ? topLevel : element); if (!comments.isEmpty()) result += getCommentText(comments); return result; } else if (element instanceof PsiDirectory) { String comments = getPackageComment(((PsiDirectory)element).findFile("doc.go")); if (comments != null) return comments; return getPackageComment(((PsiDirectory)element).findFile(((PsiDirectory)element).getName() + ".go")); } return null; }
Source:
<code>public Void call() throws Exception { List<Change> openChanges; ReviewDb db = schemaFactory.open(); try { <START> openChanges = db.changes().byBranchOpenAll(new Branch.NameKey(project, ref)).toList(); <END> } finally { db.close(); } for (Change change : openChanges) { updateAsync(change); } return null; }</code><technical_language>This is a bit of a rat's nest. if a branch 2000 changes (see above) submit 2 changes in "rapid" succession? change put queue twice. For changes updated 2nd branch tip update, update is a (costly) no-op. Ideally enqueue change once. approximately once</technical_language>

Target:
public Void call() throws Exception { List<Change> openChanges; ReviewDb db = schemaFactory.open(); try { openChanges = db.changes().byBranchOpenAll(new Branch.NameKey(project, ref)).toList(); } finally { db.close(); } for (Change change : mergeabilityCheckQueue.addAll(openChanges)) { updateAsync(change); } return null; }
Source:
<code>public static Cache<String, CachableResponse> getMediatorCache() { if (mediatorCacheInit.get()) { return Caching.getCacheManagerFactory().getCacheManager(CachingConstants.CACHE_MANAGER) .getCache(CachingConstants.MEDIATOR_CACHE); } else { CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(CachingConstants.CACHE_MANAGER); <START> mediatorCacheInit.set(true); <END> return cacheManager.<String, CachableResponse>createCacheBuilder(CachingConstants.MEDIATOR_CACHE). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, CachingConstants.CACHE_INVALIDATION_TIME)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.Duration(TimeUnit.SECONDS,CachingConstants.CACHE_INVALIDATION_TIME)) .setStoreByValue(false).build(); } }</code><technical_language>this getAndSet() ensure atomic operation</technical_language>

Target:
public static Cache<String, CachableResponse> getMediatorCache() { if (mediatorCacheInit.get()) { return Caching.getCacheManagerFactory().getCacheManager(CachingConstants.CACHE_MANAGER) .getCache(CachingConstants.MEDIATOR_CACHE); } else { CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(CachingConstants.CACHE_MANAGER); mediatorCacheInit.getAndSet(true); return cacheManager.<String, CachableResponse>createCacheBuilder(CachingConstants.MEDIATOR_CACHE). setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS, CachingConstants.CACHE_INVALIDATION_TIME)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.Duration(TimeUnit.SECONDS,CachingConstants.CACHE_INVALIDATION_TIME)) .setStoreByValue(false).build(); } }
Source:
<code>void returnsNopLockWithoutExclusiveResources() { Collection<ExclusiveResource> resources = emptySet(); <START> List<Lock> locks = getLocks(lockManager, resources); <END> assertThat(locks).isEmpty(); }</code><technical_language>This assert a NopLock returned, for other tests</technical_language>

Target:
void returnsNopLockWithoutExclusiveResources() { Collection<ExclusiveResource> resources = emptySet(); List<Lock> locks = getLocks(resources, NopLock.class); assertThat(locks).isEmpty(); }
Source:
<code>private static Method[] populateSetters(Class<?> cls, String propertyName) { String setterName = ""; <START> if(propertyName != null && propertyName.length()>0){ <END> setterName = new StringBuilder("set").append(propertyName.substring(0, 1).toUpperCase(Locale.ENGLISH)) .append(propertyName.substring(1)).toString(); } List<Method> resultList = null; for (Method method: cls.getMethods()) { if (method.getName().equals(setterName)) { Class<?>[] clazzes = method.getParameterTypes(); if (clazzes.length != 1) { continue; } if (resultList == null) { resultList = new ArrayList<Method>(); } resultList.add(method); } } Method[] result = EMPTY_METHOD_ARRAY; if (resultList != null && !resultList.isEmpty()) { result = resultList.toArray(new Method[resultList.size()]); } Map<String, Method[]> classMap = SETTERS_METHODS_CACHE.get(cls); if (classMap == null) { classMap = new ConcurrentHashMap<String, Method[]>(); SETTERS_METHODS_CACHE.put(cls, classMap); } classMap.put(propertyName, result); return result; }</code><technical_language>code style</technical_language>

Target:
private static Method[] populateSetters(Class<?> cls, String propertyName) { String setterName = ""; if (propertyName != null && propertyName.length() > 0){ setterName = new StringBuilder("set").append(propertyName.substring(0, 1).toUpperCase(Locale.ENGLISH)) .append(propertyName.substring(1)).toString(); } List<Method> resultList = null; for (Method method : cls.getMethods()) { if (method.getName().equals(setterName)) { Class<?>[] clazzes = method.getParameterTypes(); if (clazzes.length != 1) continue; if (resultList == null) resultList = new ArrayList<Method>(); resultList.add(method); } } Method[] result = EMPTY_METHOD_ARRAY; if (resultList != null && !resultList.isEmpty()) result = resultList.toArray(new Method[resultList.size()]); Map<String, Method[]> classMap = SETTERS_METHODS_CACHE.get(cls); if (classMap == null) { classMap = new ConcurrentHashMap<String, Method[]>(); SETTERS_METHODS_CACHE.put(cls, classMap); } classMap.put(propertyName, result); return result; }
Source:
<code>public static TempFileSpace with(final Path baseDir, final String prefix) throws IOException { if (baseDir == null || prefix == null) { <START> throw new IllegalArgumentException("TempFileSpace is created with null."); <END> } if (!baseDir.isAbsolute()) { throw new IllegalArgumentException("TempFileSpace is created under a relative path."); } if (!Files.isDirectory(baseDir)) { throw new IOException("TempFileSpace is created under non-directory."); } return new TempFileSpace(true, baseDir, prefix, null); }</code><technical_language>nit: created is better, I think, created yet</technical_language>

Target:
public static TempFileSpace with(final Path baseDir, final String prefix) throws IOException { if (baseDir == null || prefix == null) { throw new IllegalArgumentException("TempFileSpace cannot be created with null."); } if (!baseDir.isAbsolute()) { throw new IllegalArgumentException("TempFileSpace cannot be created under a relative path."); } if (!Files.isDirectory(baseDir)) { throw new IOException("TempFileSpace cannot be created under non-directory."); } return new TempFileSpace(true, baseDir, prefix, null); }
Source:
<code>static Map<Aggregate, Object> getAggregates(String attributeName, FeatureCollection featureCollection, Aggregate... aggregates) { Map<Aggregate, Object> result = new HashMap<>(); PropertyName property = FF.property(attributeName); for (Aggregate aggregate : aggregates) { FeatureCalc featureCalc = aggregate.create(property); try { featureCollection.accepts(featureCalc, null); Object value = featureCalc.getResult().getValue(); result.put(aggregate, value); } catch (IOException e) { <START> throw new RuntimeException(e); <END> } } return result; }</code><technical_language>I a put a message aggregation failed, debug a failure</technical_language>

Target:
static Map<Aggregate, Object> getAggregates(String attributeName, FeatureCollection featureCollection, Aggregate... aggregates) { Map<Aggregate, Object> result = new HashMap<>(); PropertyName property = FF.property(attributeName); for (Aggregate aggregate : aggregates) { FeatureCalc featureCalc = aggregate.create(property); try { featureCollection.accepts(featureCalc, null); Object value = featureCalc.getResult().getValue(); result.put(aggregate, value); } catch (IOException e) { throw new RuntimeException("Failed to collect summary aggregates on attribute " + attributeName, e); } } return result; }
Source:
<code>PaxosQuorumCheckingCoalescingFunction<REQ, RESP, F> wrapWithRemotes( List<SERVICE> services, Map<SERVICE, ExecutorService> executors, int quorumSize, Function<SERVICE, F> functionFactory) { List<FunctionAndExecutor<F>> functionsAndExecutors = KeyedStream.of(services) .map(executors::get) .mapKeys(functionFactory) .entries() .<FunctionAndExecutor<F>>map(entry -> ImmutableFunctionAndExecutor.of(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); <START> return new PaxosQuorumCheckingCoalescingFunction<>(functionsAndExecutors, quorumSize); <END> }</code><technical_language>I a bit overboard fanciness fluent opposed suggestion List<F> functions = new ArrayList<>(services.size()); Map<F, ExecutorService> executorMap = new HashMap<>(services.size()); for (SERVICE service: services) { F function = functionFactory.apply(service); functions.add(function); executorMap.put(function, executors.get(service)); } return new PaxosQuorumCheckingCoalescingFunction<>(functions, executorMap, quorumSize);</technical_language>

Target:
PaxosQuorumCheckingCoalescingFunction<REQ, RESP, F> wrapWithRemotes( List<SERVICE> services, Map<SERVICE, ExecutorService> executors, int quorumSize, Function<SERVICE, F> functionFactory) { List<FunctionAndExecutor<F>> functionsAndExecutors = KeyedStream.of(services) .map(executors::get) .mapKeys(functionFactory) .entries() .<FunctionAndExecutor<F>>map(entry -> ImmutableFunctionAndExecutor.of(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); List<F> functions = new ArrayList<>(services.size()); Map<F, ExecutorService> executorMap = new HashMap<>(services.size()); for (SERVICE service: services) { F function = functionFactory.apply(service); functions.add(function); executorMap.put(function, executors.get(service)); } return new PaxosQuorumCheckingCoalescingFunction<>(functions, executorMap, quorumSize); }
Source:
<code>public void testAbortTransaction() { Map<String, Object> configs = new HashMap<>(); configs.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "some.id"); <START> configs.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 10000); <END> configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9000"); Time time = new MockTime(1); MetadataResponse initialUpdateResponse = TestUtils.metadataUpdateWith(1, singletonMap("topic", 1)); ProducerMetadata metadata = newMetadata(0, Long.MAX_VALUE); MockClient client = new MockClient(time, metadata); client.updateMetadata(initialUpdateResponse); client.prepareResponse(FindCoordinatorResponse.prepareResponse(Errors.NONE, host1)); client.prepareResponse(initProducerIdResponse(1L, (short) 5, Errors.NONE)); client.prepareResponse(endTxnResponse(Errors.NONE)); try (Producer<String, String> producer = new KafkaProducer<>(configs, new StringSerializer(), new StringSerializer(), metadata, client, null, time)) { producer.initTransactions(); producer.beginTransaction(); producer.abortTransaction(); } }</code><technical_language>do need set MAX_BLOCK_MS_CONFIG</technical_language>

Target:
public void testAbortTransaction() { Map<String, Object> configs = new HashMap<>(); configs.put(ProducerConfig.TRANSACTIONAL_ID_CONFIG, "some.id"); configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9000"); Time time = new MockTime(1); MetadataResponse initialUpdateResponse = TestUtils.metadataUpdateWith(1, singletonMap("topic", 1)); ProducerMetadata metadata = newMetadata(0, Long.MAX_VALUE); MockClient client = new MockClient(time, metadata); client.updateMetadata(initialUpdateResponse); client.prepareResponse(FindCoordinatorResponse.prepareResponse(Errors.NONE, host1)); client.prepareResponse(initProducerIdResponse(1L, (short) 5, Errors.NONE)); client.prepareResponse(endTxnResponse(Errors.NONE)); try (Producer<String, String> producer = new KafkaProducer<>(configs, new StringSerializer(), new StringSerializer(), metadata, client, null, time)) { producer.initTransactions(); producer.beginTransaction(); producer.abortTransaction(); } }
Source:
<code>public void requestResults(String query, Searcher searcher) { Matcher m = p.matcher(query); if (m.find()) { SearchPojo pojo = new SearchPojo(); pojo.id = "calculator://"; pojo.type = SearchPojo.CALCULATOR_QUERY; String operator = m.group(2); String result = ""; float lhs = Float.parseFloat(m.group(1)); float rhs = Float.parseFloat(m.group(3)); float floatResult = 0; <START> if (operator.equals("+")) { <END> floatResult = lhs + rhs; } if (operator.equals("-")) { floatResult = lhs - rhs; } if (operator.equals("*") || operator.equals("×")) { floatResult = lhs * rhs; } if (operator.equals("/") || operator.equals("÷")) { floatResult = lhs / rhs; } pojo.query = floatToString(lhs) + " " + operator + " " + floatToString(rhs) + " = " + floatToString(floatResult); pojo.relevance = 100; searcher.addResult(pojo); } }</code><technical_language>Hey thinking, if switch case suited? this works</technical_language>

Target:
public void requestResults(String query, Searcher searcher) { Matcher m = p.matcher(query); if (m.find()) { SearchPojo pojo = new SearchPojo(); pojo.id = "calculator://"; pojo.type = SearchPojo.CALCULATOR_QUERY; String operator = m.group(2); float lhs = Float.parseFloat(m.group(1)); float rhs = Float.parseFloat(m.group(3)); float floatResult = 0; switch (operator) { case "+": floatResult = lhs + rhs; break; case "-": floatResult = lhs - rhs; break; case "*": case "×": floatResult = lhs * rhs; break; case "/": case "÷": floatResult = lhs / rhs; break; default: floatResult = Float.POSITIVE_INFINITY; } pojo.query = floatToString(lhs) + " " + operator + " " + floatToString(rhs) + " = " + floatToString(floatResult); pojo.relevance = 100; searcher.addResult(pojo); } }
Source:
<code>public void handleRemoveEvent(CatalogRemoveEvent event) throws CatalogException { String resourceWorkSpaceName = null; CatalogInfo resourceInfo = event.getSource(); String resourceName = null; if (resourceInfo instanceof LayerInfo) { resourceWorkSpaceName = ((LayerInfo) resourceInfo).getResource().getStore().getWorkspace().getName(); resourceName = ((LayerInfo) resourceInfo).getName(); } else if (event.getSource() instanceof LayerGroupInfo) { resourceWorkSpaceName = ((LayerGroupInfo) resourceInfo).getWorkspace().getName(); resourceName = ((LayerGroupInfo) resourceInfo).getName(); } if (resourceWorkSpaceName != null && resourceInfo != null) { if (layerHasSecurityRule(resourceWorkSpaceName, resourceName)) { LOGGER.info( String.format( "Removing Security Rules for removed layer: %s", resourceName)); List<DataAccessRule> rulesToRemove = getDataAccessRule(resourceInfo, resourceName); for (DataAccessRule r : rulesToRemove) { dao.removeRule(r); } try { dao.storeRules(); } catch (IOException e) { <START> LOGGER.log(Level.SEVERE, e.getMessage(), e); <END> } } } }</code><technical_language>This throw exception IMHO</technical_language>

Target:
public void handleRemoveEvent(CatalogRemoveEvent event) throws CatalogException { String resourceWorkSpaceName = null; CatalogInfo resourceInfo = event.getSource(); String resourceName = null; if (resourceInfo instanceof LayerInfo) { resourceWorkSpaceName = ((LayerInfo) resourceInfo).getResource().getStore().getWorkspace().getName(); resourceName = ((LayerInfo) resourceInfo).getName(); } else if (event.getSource() instanceof LayerGroupInfo) { resourceWorkSpaceName = ((LayerGroupInfo) resourceInfo).getWorkspace().getName(); resourceName = ((LayerGroupInfo) resourceInfo).getName(); } if (resourceWorkSpaceName != null && resourceInfo != null) { if (layerHasSecurityRule(resourceWorkSpaceName, resourceName)) { LOGGER.info( String.format( "Removing Security Rules for removed layer: %s", resourceName)); List<DataAccessRule> rulesToRemove = getDataAccessRule(resourceInfo, resourceName); for (DataAccessRule r : rulesToRemove) { dao.removeRule(r); } try { dao.storeRules(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); throw new CatalogException(e); } } } }
Source:
<code>public void setAttribute(String key, String value) { if (key.equals(attributeKeyString)) { <START> String command[] = value.split(" "); <END> if (command.length == 3 && command[0].equals("add")) { while (command[1].charAt(command[1].length() - 1) == '/') { command[1] = command[1].substring(0, command[1].length() - 1); } this.prefixToOSDMap.put(command[1], command[2]); } else if (command.length >= 2 && command[0].equals("remove")) { this.prefixToOSDMap.remove(command[1]); } else if (command.length == 1 && command[0].equals("clear")) { this.prefixToOSDMap.clear(); } } }</code><technical_language>is null</technical_language>

Target:
public void setAttribute(String key, String value) { if (key.equals(attributeKeyString)) { String command[] = value.split(" "); if (command.length == 3 && command[0].equals("add")) { if (!(command[1].length() == 0 || command[2].length() == 0)) { this.prefixToOSDMap.put(removeLeadingTrailingSlashes(command[1]), command[2]); } } else if (command.length >= 2 && command[0].equals("remove")) { this.prefixToOSDMap.remove(removeLeadingTrailingSlashes (command[1])); } else if (command.length == 1 && command[0].equals("clear")) { this.prefixToOSDMap.clear(); } } }
Source:
<code>public void testToStringDefault() { DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS"); Date d0 = new Date(0); Date d1 = new Date(12345000L); Date d2 = new Date(1234500L); <START> Date d3 = new Date(1234500000L); <END> assertEquals("toString", df.format(d0) + " 000 000", ts0.toString()); assertEquals("toString", df.format(d1) + " 000 000", ts1.toString()); assertEquals("toString", df.format(d2) + " 000 000", ts2.toString()); assertEquals("toString", df.format(d3) + " 000 000", ts3.toString()); }</code><technical_language>prefer if Date initialized ts's getValue getScale converted ms</technical_language>

Target:
public void testToStringDefault() { DateFormat df = new SimpleDateFormat("HH:mm:ss.SSS"); Date d0 = new Date(ts0.getValue() * (long) Math.pow(10, ts0.getScale() + 3)); Date d1 = new Date(ts1.getValue() * (long) Math.pow(10, ts1.getScale() + 3)); Date d2 = new Date(ts2.getValue() * (long) Math.pow(10, ts2.getScale() + 3)); Date d3 = new Date(ts3.getValue() * (long) Math.pow(10, ts3.getScale() + 3)); assertEquals("toString", df.format(d0) + " 000 000", ts0.toString()); assertEquals("toString", df.format(d1) + " 000 000", ts1.toString()); assertEquals("toString", df.format(d2) + " 000 000", ts2.toString()); assertEquals("toString", df.format(d3) + " 000 000", ts3.toString()); }
Source:
<code>public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) { <START> return size; <END> } size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(1, continent_.getNumber()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, getCityBytes()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }</code><technical_language>4 spaces</technical_language>

Target:
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeEnumSize(1, continent_.getNumber()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, getCityBytes()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; }
Source:
<code>private void proposeLeadershipAfter(Optional<PaxosValue> value) { lock.lock(); try { if (!isLatestRound(value)) { return; } <START> long seq = value.map(val -> val.getRound() + 1).orElse(0L); <END> eventRecorder.recordProposalAttempt(seq); proposer.propose(seq, null); } catch (PaxosRoundFailureException e) { eventRecorder.recordProposalFailure(e); return; } finally { lock.unlock(); } }</code><technical_language>nit: PaxosAcceptor.NO_LOG_ENTRY for base case. + 1 apply cases, I write value.map(PaxosValue::getRound).orElse(PaxosAcceptor.NO_LOG_ENTRY) + 1</technical_language>

Target:
private void proposeLeadershipAfter(Optional<PaxosValue> value) { lock.lock(); try { if (!isLatestRound(value)) { return; } long seq = value.map(val -> val.getRound()).orElse(PaxosAcceptor.NO_LOG_ENTRY) + 1; eventRecorder.recordProposalAttempt(seq); proposer.propose(seq, null); } catch (PaxosRoundFailureException e) { eventRecorder.recordProposalFailure(e); return; } finally { lock.unlock(); } }
Source:
<code>public int hashCode() { <START> int result = bucket != null ? bucket.hashCode() : 0; <END> result = 31 * result + (id != null ? id.hashCode() : 0); result = 31 * result + (latest ? 1 : 0); result = 31 * result + (int) (length ^ (length >>> 32)); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (int) (offset ^ (offset >>> 32)); result = 31 * result + (physicalPlacement != null ? physicalPlacement.hashCode() : 0); result = 31 * result + (int) (version ^ (version >>> 32)); return result; }</code><technical_language>recommend of Objects.hash() instead of a custom hashing algorithm</technical_language>

Target:
public int hashCode() { return java.util.Objects.hash(bucket, id, latest, length, name, offset, physicalPlacement, version); }
Source:
<code>void testGenerateMsgId() { GelfMessage gelfMessage = new GelfMessage() { @Override long getRandomLong() { return 0x8040201008040201L; } @Override short getCurrentTimeMillis() { return 0x0603; } }; byte[] expectedBytes = { (byte) 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x06, 0x03 }; byte[] msgId = gelfMessage.generateMsgId(); <START> assertEquals(8, msgId.length); END> assertArrayEquals(expectedBytes, msgId); }</code><technical_language>stick AssertJ tests consistent</technical_language>

Target:
void testGenerateMsgId() { GelfMessage gelfMessage = new GelfMessage() { @Override long getRandomLong() { return 0x804020100804A201L; } @Override long getCurrentTimeMillis() { return 0x90C06030090C1683L; } }; assertThat(gelfMessage.generateMsgId()).isEqualTo(0x804020100804B683L); }
Source:
<code>public AgentInfo approve(Long id, boolean approve) { Optional<AgentInfo> found = agentManagerRepository.findOne(idEqual(id)); AgentInfo agentInfo = null; if (found.isPresent()) { agentInfo = found.get(); agentInfo.setApproved(approve); <START> agentManagerRepository.save(agentInfo); <END> expireLocalCache(); } return agentInfo; }</code><technical_language>check if explicit save is necessary</technical_language>

Target:
public AgentInfo approve(Long id, boolean approve) { Optional<AgentInfo> found = agentManagerRepository.findOne(idEqual(id)); AgentInfo agentInfo = null; if (found.isPresent()) { agentInfo = found.get(); agentInfo.setApproved(approve); expireLocalCache(); } return agentInfo; }
Source:
<code>public static synchronized String nextGlobal() { <START> return StandardCharsets.US_ASCII.decode(getInstance().next()).toString(); <END> }</code><technical_language>decode</technical_language>

Target:
public static synchronized String nextGlobal() { return getInstance().next(); }
Source:
<code>public Optional<DecorrelationResult> visitLimit(LimitNode node, Void context) { Optional<DecorrelationResult> childDecorrelationResultOptional = lookup.resolve(node.getSource()).accept(this, null); if (!childDecorrelationResultOptional.isPresent() || node.getCount() == 0) { return Optional.empty(); } DecorrelationResult childDecorrelationResult = childDecorrelationResultOptional.get(); if (childDecorrelationResult.atMostSingleRow) { return childDecorrelationResultOptional; } <START> if (correlation.isEmpty() || !childDecorrelationResult.getConstantSymbols().containsAll(node.getOutputSymbols())) { <END> return Optional.empty(); } childDecorrelationResultOptional = new AggregationNode( idAllocator.getNextId(), node.getSource(), ImmutableMap.of(), ImmutableList.of(ImmutableList.<Symbol>builder() .addAll(correlation) .addAll(node.getOutputSymbols()) .build()), AggregationNode.Step.SINGLE, Optional.empty(), Optional.empty()).accept(this, null); if (!childDecorrelationResultOptional.isPresent() || !childDecorrelationResultOptional.get().atMostSingleRow) { return Optional.empty(); } return childDecorrelationResultOptional; }</code><technical_language>do decorrelate decorrelated plans</technical_language>

Target:
public Optional<DecorrelationResult> visitLimit(LimitNode node, Void context) { Optional<DecorrelationResult> childDecorrelationResultOptional = lookup.resolve(node.getSource()).accept(this, null); if (!childDecorrelationResultOptional.isPresent() || node.getCount() == 0) { return Optional.empty(); } DecorrelationResult childDecorrelationResult = childDecorrelationResultOptional.get(); if (childDecorrelationResult.atMostSingleRow) { return childDecorrelationResultOptional; } if (node.getCount() != 1) { return Optional.empty(); } Set<Symbol> constantSymbols = childDecorrelationResult.getConstantSymbols(); PlanNode decorrelatedChildNode = childDecorrelationResult.node; if (constantSymbols.isEmpty() || !constantSymbols.containsAll(decorrelatedChildNode.getOutputSymbols())) { return Optional.empty(); } AggregationNode aggregationNode = new AggregationNode( idAllocator.getNextId(), decorrelatedChildNode, ImmutableMap.of(), ImmutableList.of(ImmutableList.<Symbol>builder() .addAll(decorrelatedChildNode.getOutputSymbols()) .build()), AggregationNode.Step.SINGLE, Optional.empty(), Optional.empty()); return Optional.of(new DecorrelationResult( aggregationNode, childDecorrelationResult.symbolsToPropagate, childDecorrelationResult.correlatedPredicates, childDecorrelationResult.correlatedSymbolsMapping, true)); }
Source:
<code>public PlanNode visitApply(ApplyNode node, RewriteContext<Set<Symbol>> context) { ImmutableSet.Builder<Symbol> subqueryAssignmentsSymbolsBuilder = ImmutableSet.builder(); Assignments.Builder subqueryAssignments = Assignments.builder(); for (Map.Entry<Symbol, Expression> entry : node.getSubqueryAssignments().getMap().entrySet()) { <START> Symbol output = entry.getKey(); <END> Expression expression = entry.getValue(); if (context.get().contains(output)) { subqueryAssignmentsSymbolsBuilder.addAll(SymbolsExtractor.extractUnique(expression)); subqueryAssignments.put(output, expression); } } Set<Symbol> subqueryAssignmentsSymbols = subqueryAssignmentsSymbolsBuilder.build(); PlanNode subquery = context.rewrite(node.getSubquery(), subqueryAssignmentsSymbols); Set<Symbol> subquerySymbols = SymbolsExtractor.extractUnique(subquery); List<Symbol> newCorrelation = node.getCorrelation().stream() .filter(subquerySymbols::contains) .collect(toImmutableList()); Set<Symbol> inputContext = ImmutableSet.<Symbol>builder() .addAll(context.get()) .addAll(newCorrelation) .addAll(subqueryAssignmentsSymbols) .build(); PlanNode input = context.rewrite(node.getInput(), inputContext); return new ApplyNode(node.getId(), input, subquery, subqueryAssignments.build(), newCorrelation); }</code><technical_language>I sense remove this migrated of pruning cases -- other pruning cases this code run</technical_language>

Target:
public PlanNode visitApply(ApplyNode node, RewriteContext<Set<Symbol>> context) { if (intersection(node.getSubqueryAssignments().getSymbols(), context.get()).isEmpty()) { return context.rewrite(node.getInput(), context.get()); } ImmutableSet.Builder<Symbol> subqueryAssignmentsSymbolsBuilder = ImmutableSet.builder(); Assignments.Builder subqueryAssignments = Assignments.builder(); for (Map.Entry<Symbol, Expression> entry : node.getSubqueryAssignments().getMap().entrySet()) { Symbol output = entry.getKey(); Expression expression = entry.getValue(); if (context.get().contains(output)) { subqueryAssignmentsSymbolsBuilder.addAll(SymbolsExtractor.extractUnique(expression)); subqueryAssignments.put(output, expression); } } Set<Symbol> subqueryAssignmentsSymbols = subqueryAssignmentsSymbolsBuilder.build(); PlanNode subquery = context.rewrite(node.getSubquery(), subqueryAssignmentsSymbols); Set<Symbol> subquerySymbols = SymbolsExtractor.extractUnique(subquery); List<Symbol> newCorrelation = node.getCorrelation().stream() .filter(subquerySymbols::contains) .collect(toImmutableList()); Set<Symbol> inputContext = ImmutableSet.<Symbol>builder() .addAll(context.get()) .addAll(newCorrelation) .addAll(subqueryAssignmentsSymbols) .build(); PlanNode input = context.rewrite(node.getInput(), inputContext); return new ApplyNode(node.getId(), input, subquery, subqueryAssignments.build(), newCorrelation); }