Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpSessionRequiredException should have a getter for 'expected session attribute' [SPR-14206] #18780

Closed
spring-issuemaster opened this issue Apr 22, 2016 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 22, 2016

Sola opened SPR-14206 and commented

HttpSessionRequiredException should have a getter for 'missing session attribute',It can bring more convince to exception handling.

ideal code snippet:

@ExceptionHandler(HttpSessionRequiredException.class)
ResponseEntity<Error> unauthorizedException(HttpSessionRequiredException e) {
	if(e.getAttributeName().equals("username")){
		//do something else,
	}
	return //something
}

Affects: 4.2.5, 4.3 RC1

Reference URL: https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/web/HttpSessionRequiredException.java

Referenced from: commits e5d52a9

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 26, 2016

Juergen Hoeller commented

Good idea! I've added a corresponding getExpectedAttribute() method, populated when the exception comes out of our ModelFactory (where we are looking for a specific attribute).

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 26, 2016

Sola commented

thanks for your awesome work!;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.