[MGNLREST-369] BadRequestException is swallowed Created: 06/May/22  Updated: 23/Oct/23  Resolved: 18/Apr/23

Status: Closed
Project: Magnolia REST Framework
Component/s: None
Affects Version/s: 2.2
Fix Version/s: 2.2.18

Type: Bug Priority: Neutral
Reporter: Phong Le Quoc Assignee: Marek Strucka
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
relation
is related to PAGES-588 Language tag in spa renderer misses t... Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLREST-674 Implementation Sub-task Completed Marek Strucka  
MGNLREST-675 Review Sub-task Completed Dai Ha  
MGNLREST-676 PiQA Sub-task Completed Dai Ha  
MGNLREST-677 QA Sub-task Completed Milan Divilek  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Epic Link: Headless Phase 2
Sprint: DevX 35
Story Points: 2
Team: DeveloperX
Work Started:
Approved:
Yes

 Description   

If the lang param is invalid, I18nContainerRequestFilter throws BadRequestException, however, this exception is swallowed by PreMatchContainerRequestContext. The class expects the exception should be a child of IOException.

public class I18nContainerRequestFilter implements ContainerRequestFilter {
private Locale determineLocaleFromQueryParameter(MultivaluedMap<String, String> queryParameters) {
    ...
    if (!isValidLanguageTag(localeString)) {
        throw new BadRequestException(String.format("Language parameter: %s is not allowed", localeString));
    }
    ...
}
} 

And

class PreMatchContainerRequestContext ...{
public synchronized BuiltResponse filter() {
    RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(this.httpRequest);
    long totalTimestamp = tracingLogger.timestamp("REQUEST_FILTER_SUMMARY");    while(this.requestFilters != null && this.currentFilter < this.requestFilters.length) {
        ContainerRequestFilter filter = this.requestFilters[this.currentFilter++];        try {
            this.suspended = false;
            this.response = null;
            this.throwable = null;
            this.inFilter = true;
            long timestamp = tracingLogger.timestamp("REQUEST_FILTER");
            filter.filter(this);
            tracingLogger.logDuration("REQUEST_FILTER", timestamp, new Object[]{filter});
        } catch (IOException var10) {
            throw new ApplicationException(var10);
        } finally {
            this.inFilter = false;
        }
...
}

Generated at Mon Feb 12 06:59:15 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.