}
}
- private static final Supplier<org.opendaylight.restconf.api.ApiPathParser> URL_FACTORY;
+ private static final Supplier<@NonNull ApiPathParser> URL_FACTORY;
static {
// Select the correct parser implementation where consecutive slashes are concerned. We default to lenient
// interpretation and treat them as a single slash, but allow this to be overridden through a system property.
final String prop = System.getProperty("org.opendaylight.restconf.url.consecutive-slashes", "reject");
final String treatment;
- switch (prop) {
- case "allow":
+ URL_FACTORY = switch (prop) {
+ case "allow" -> {
treatment = "are treated as a single slash";
- URL_FACTORY = Lenient::new;
- break;
- case "debug":
+ yield Lenient::new;
+ }
+ case "debug" -> {
treatment = "are treated as a single slash and will be logged";
- URL_FACTORY = () -> new Logging(LOG::debug);
- break;
- case "warn":
+ yield () -> new Logging(LOG::debug);
+ }
+ case "warn" -> {
treatment = "are treated as a single slash and will be warned about";
- URL_FACTORY = () -> new Logging(LOG::warn);
- break;
- case "reject":
+ yield () -> new Logging(LOG::warn);
+ }
+ case "reject" -> {
treatment = "will be rejected";
- URL_FACTORY = ApiPathParser::new;
- break;
- default:
+ yield ApiPathParser::new;
+ }
+ default -> {
LOG.warn("Unknown property value '{}', assuming 'reject'", prop);
treatment = "will be rejected";
- URL_FACTORY = ApiPathParser::new;
- }
+ yield ApiPathParser::new;
+ }
+ };
LOG.info("Consecutive slashes in REST URLs {}", treatment);
}