<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mschipperheyn" rel="nofollow">marc schipperheyn</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9418?redirect=false" rel="nofollow">SPR-9418</a></strong> and commented</p>
<p dir="auto">I have been playing around with RedirectAttributes and although I like the FlashAttribute function, I don't really like the way it has been implemented.<br>
For me, FlashAttributes come into play in the GET/POST/Redirect/displayStatus chain. What I don't like is that FlashAttributes aren't a transparent part of the ModelMap but instead separated through RedirectAttributes. I would prefer to say</p>
<p dir="auto">model.addFlashAttribute(...) in stead of having the specify RedirectAttributes separately redirectAttributes.addFlashAttribute(...).</p>
<p dir="auto">Also, when I add a FlashAttribute to a Model/RedirectAttributes and I don't redirect, I expect the FlashAttribute to be treated as a normal model attribute. and because they are separate, it isn't.</p>
<p dir="auto">In the flow of a Controller, whether one redirects often depends on the context. And because RedirectAttributes are separate from ModelAttributes (when they are conceptually the same), I find myself having to duplicate certain actions, which is exactly what I want to avoid.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if(!member.isActive()){
   redirectAttributes.addFlashAttribute(&quot;status&quot;,&quot;Denied&quot;,RequestUtils.getLocale(request)));
   model.addAttribute(&quot;status&quot;,&quot;Denied&quot;,RequestUtils.getLocale(request)));
}

if(group.isHiddenToNonMembers()){
   return &quot;empty&quot;;
}else{
   return &quot;redirect:&quot; + URLUtils.getGroupUrl(group, request);
}"><pre class="notranslate"><code class="notranslate">if(!member.isActive()){
   redirectAttributes.addFlashAttribute("status","Denied",RequestUtils.getLocale(request)));
   model.addAttribute("status","Denied",RequestUtils.getLocale(request)));
}

if(group.isHiddenToNonMembers()){
   return "empty";
}else{
   return "redirect:" + URLUtils.getGroupUrl(group, request);
}
</code></pre></div>
<p dir="auto">What I would expect is to have a single action against the ModelMap<br>
model.addFlashAttribute(...)<br>
if the controller redirects, it is treated as a flash attribute<br>
if the controller doesn't redirect, it treated as a model attribute</p>
<hr>
<p dir="auto">No further details from <a href="https://jira.spring.io/browse/SPR-9418?redirect=false" rel="nofollow">SPR-9418</a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=bravesirrobin" rel="nofollow">Leigh Anderson</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9176?redirect=false" rel="nofollow">SPR-9176</a></strong> and commented</p>
<p dir="auto">New entries are added to dependentBeanMap and dependenciesForBean map every time that a new instance of the request-scoped bean is created. This is because the proxy object representing the HttpServletRequest has a bean name like "$Proxy10@XXXXX" where XXXXX changes for each request. These entries are never removed, and eventually fill up the old generation.</p>
<p dir="auto">Attached is a web application which demonstrates the issue. Visit "<a href="http://localhost:8080/leak" rel="nofollow">http://localhost:8080/leak</a>" repeatedly and watch the count increase.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/19566/dridi-spring-9176-quickfix.patch" rel="nofollow">dridi-spring-9176-quickfix.patch</a> (<em>1.74 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/19459/request-memory-leak.tar.gz" rel="nofollow">request-memory-leak.tar.gz</a> (<em>3.41 kB</em>)</li>
</ul>
<p dir="auto"><strong>Sub-tasks:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118859" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14000" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14000/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14000">#14000</a> Backport "Scoped-proxy memory leak w/ <code class="notranslate">@Resource</code> injection"</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398108894" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12420" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12420/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12420">#12420</a> memory leak occurs in SpringMVC(DefaultListableBeanFactory.dependentBeanMap, DefaultListableBeanFactory.dependenciesForBeanMap)  (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398152030" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14261" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14261/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14261">#14261</a> Regression: scoped beans being cached too aggressively</li>
</ul>
<p dir="auto">3 votes, 4 watchers</p>