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

QoSFilter.setMaxRequests throws NullPointerException #7414

Closed
bu3 opened this issue Jan 18, 2022 · 2 comments · Fixed by #7506
Closed

QoSFilter.setMaxRequests throws NullPointerException #7414

bu3 opened this issue Jan 18, 2022 · 2 comments · Fixed by #7506
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@bu3
Copy link

bu3 commented Jan 18, 2022

Jetty version(s)
9.4.44
Java version/vendor (use: java -version)
openjdk version "11.0.10" 2021-01-19 LTS

OS type/version
macOS 11.6.2

Description
I'm trying to use the QosFilter into an existing Spring application but if I try to tune the filter calling setMaxRequests at configuration time, it throws the following NullPointer exception:

Caused by: java.lang.NullPointerException: null
	at org.eclipse.jetty.servlets.QoSFilter.setMaxRequests(QoSFilter.java:351)

this is the code I'm using to create a Spring Bean with the QosFilter:

@Bean
public QoSFilter sfdcJettyQualityOfServiceFilter(MyQoSProperties properties) {
    QoSFilter qoSFilter = new QoSFilter();
    qoSFilter.setSuspendMs(properties.getSuspendMs());
    qoSFilter.setWaitMs(properties.getWaitMs());
    qoSFilter.setMaxRequests(properties.getMaxRequests());

    return qoSFilter;
}

I think it blows up because QosFilter.init() method has not been called yet at that stage and the private property _passes is null here.

How to reproduce?

  • creating a SpringBoot application and trying to load the QosFilter in a @Configuration annotated class
@bu3 bu3 added the Bug For general bugs on Jetty side label Jan 18, 2022
@janbartel
Copy link
Contributor

@bu3 thanks for the report we'll take a look. In the meanwhile, as a workaround, I note that all our unit tests set these properties by calling setInitParam, eg:

        FilterHolder holder = new FilterHolder(QoSFilter.class);
        holder.setInitParameter(QoSFilter.MAX_REQUESTS_INIT_PARAM, x);

@bu3
Copy link
Author

bu3 commented Jan 19, 2022

Nice! I will give it a try. Thanks a million @janbartel

@janbartel janbartel self-assigned this Feb 1, 2022
janbartel added a commit that referenced this issue Feb 1, 2022
Signed-off-by: Jan Bartel <janb@webtide.com>
janbartel added a commit that referenced this issue Feb 7, 2022
janbartel added a commit that referenced this issue Feb 8, 2022
* Issue #7414 Deprecate QoSFilter setters

Signed-off-by: Jan Bartel <janb@webtide.com>
joakime pushed a commit that referenced this issue Feb 25, 2022
* Issue #7414 Deprecate QoSFilter setters

Signed-off-by: Jan Bartel <janb@webtide.com>
(cherry picked from commit c742c2e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants