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:
Christoffer Sawicki 2016-07-18 15:24:17 -07:00 committed by Phillip Webb
parent 150aba2191
commit 3a8cf7ac8a
2 changed files with 7 additions and 7 deletions

View File

@ -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(

View File

@ -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");