Issue 1:
Dave Syer opened SPR-7192 and commented

Example from Chris's DIStyles presentation:

AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TellerUI.class, InMemoryAccountRepository.class, TransferServiceImpl.class, FlatFeePolicy.class);

TransferService transferService = context.getBean(TransferService.class);

This works fine now if all the types have explicitly @Autowired constructors, it would be great if those components could just be autowirable (implicitly). All we would need would be to optimistically register a bean definition for any class where we don't find explicit @Autowired instructions.

Issue Links:

#16883 Make @Autowired optional on a single constructor of a class decorated with @Component ("duplicates")

1 votes, 2 watchers

Issue 2:
Wim De Clercq opened SPR-9646 and commented

Using "RedirectAttributes flash"

and

flash.addFlashAttribute("flash_msg", "letter");

Can sometimes cause this flashmap to somehow get a bit buggy and only make the attribute available after the 2nd redirect / request.

This bug is reproducable by doing the following:

You need a double submit to a controller which will add to the flashmap.

(I use fiddler2 to block 2 requests, and then send them simultaniously)

The controller will:

1st request: add something to flashmap and return "redirect:/whatever";

2nd request: add something to flashmap and return "viewname" (no redirect);

It's a bit of a thread race, but usually the 2nd is later, and your browser will not redirect from the 1st request, but instead show the page of the 2nd.

From that moment, the flashmap is lagging 1 request behind for me.

I've added a small test project which will cause the bug to happen for me:

In essence, the JSP is:

<c:if test="${not empty flash_msg}">
<strong><c:out value="${flash_msg}"/></strong>
</c:if>

Controller is straightforward, and it will do what I've just said to reproduce the problem (new2 method): 1st request> redirect, 2nd request show page.

@Controller
@RequestMapping(value = "/messages")
public class MessageController {
boolean beenThere = false;

@RequestMapping(method = RequestMethod.GET)
public ModelAndView doGet(ModelAndView mav) {
mav.setViewName("display-message");
return mav;
}

@RequestMapping(value="/new", method = RequestMethod.POST)
public ModelAndView createNewMessage(ModelAndView mav, RedirectAttributes flash) {
flash.addFlashAttribute("flash_msg", "number");
mav.setViewName("redirect:/messages");
return mav;
}

@RequestMapping(value="/new2", method = RequestMethod.POST)
public ModelAndView createNewMessage2(ModelAndView mav, RedirectAttributes flash) {
flash.addFlashAttribute("flash_msg", "letter");
if(!beenThere){
mav.setViewName("redirect:/messages");
} else {
mav.setViewName("display-message");
}
beenThere = !beenThere;
return mav;
}
}

So if I click button "number", I end up at "new" method, and "number" appears on my screen.

HOWEVER, after new2 is called twice with a double submit, I expect that if I click on the "number", "number" will be displayed on the page. But instead "letter" is displayed. And on the next request "number" is in the scope. So basically my flash scope has turned into a scope which makes attributes available for the 2nd request.

I attached the war from this project, and a zip of the project.

No weird configurations are used as far as I can tell.

—

Wim De Clercq

Affects: 3.1.1

Attachments:

flashmessage.war (3.49 MB)

SpringTest.zip (5.47 kB)

Referenced from: commits spring-attic/spring-framework-issues@7c4ddd5