[AAA-34] Stop creating static exception instances Created: 01/Jun/15 Updated: 21/Mar/19 Resolved: 21/Jul/15 |
|
| Status: | Resolved |
| Project: | aaa |
| Component/s: | General |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Devin Avery | Assignee: | Ryan Goulding |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| External issue ID: | 3519 |
| Description |
|
I found that the TokenAuthFilter.java class creates a static exception: private static final WebApplicationException UNAVAILABLE_EX = new WebApplicationException( ") It seems that the intent was to deduplicate the amount of code written inline with statics. While this is fine for a static Response message, by creating the exception object here and not inline you get incorrect trace information when the exception is thrown. We should change this so that the exception is not created here, but just the response (i.e. the response is static). Then when we throw the exception in the constructor we should create the new WebApplicationException object. This way the exception will have the proper trace and you get the reusable response. While this is a single example, there are other cases in this same file and other files that should be reviewed and fixed as well. NOTE: If we are intentionally doing this for some reason then the code should be commented to describe why. |
| Comments |
| Comment by Ryan Goulding [ 20/Jul/15 ] |