Register valves at the engine level
Update `ServerProperties` to register `AccessLogValve` and `RemoteIpValve` at the engine level. Closes gh-6311
This commit is contained in:
parent
150aba2191
commit
3a8cf7ac8a
|
@ -851,7 +851,7 @@ public class ServerProperties
|
|||
valve.setPortHeader(getPortHeader());
|
||||
valve.setProtocolHeaderHttpsValue(getProtocolHeaderHttpsValue());
|
||||
// ... so it's safe to add this valve by default.
|
||||
factory.addContextValves(valve);
|
||||
factory.addEngineValves(valve);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -925,7 +925,7 @@ public class ServerProperties
|
|||
valve.setPrefix(this.accesslog.getPrefix());
|
||||
valve.setSuffix(this.accesslog.getSuffix());
|
||||
valve.setRenameOnRotate(this.accesslog.isRenameOnRotate());
|
||||
factory.addContextValves(valve);
|
||||
factory.addEngineValves(valve);
|
||||
}
|
||||
|
||||
private void customizeRedirectContextRoot(
|
||||
|
|
|
@ -339,7 +339,7 @@ public class ServerPropertiesTests {
|
|||
bindProperties(map);
|
||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
assertThat(container.getValves()).isEmpty();
|
||||
assertThat(container.getEngineValves()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -368,8 +368,8 @@ public class ServerPropertiesTests {
|
|||
private void testRemoteIpValveConfigured() {
|
||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
assertThat(container.getValves()).hasSize(1);
|
||||
Valve valve = container.getValves().iterator().next();
|
||||
assertThat(container.getEngineValves()).hasSize(1);
|
||||
Valve valve = container.getEngineValves().iterator().next();
|
||||
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
||||
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
||||
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("X-Forwarded-Proto");
|
||||
|
@ -398,8 +398,8 @@ public class ServerPropertiesTests {
|
|||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
||||
this.properties.customize(container);
|
||||
|
||||
assertThat(container.getValves()).hasSize(1);
|
||||
Valve valve = container.getValves().iterator().next();
|
||||
assertThat(container.getEngineValves()).hasSize(1);
|
||||
Valve valve = container.getEngineValves().iterator().next();
|
||||
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
||||
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
||||
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("x-my-protocol-header");
|
||||
|
|
Loading…
Reference in New Issue