I've a very simple spring boot application with only 1 controller and 1 endpoint. This application is not available on internet and it should only be accessed through intranet by few known systems.
But somehow i'm getting an error message in the logs that show that someone is misusing it.
As this system is heavly used I dont want to log every single request arriving, I would like to catch only the misplaced requests and try to debug from there who is misusing it.
The error i get is very simple:
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x000x850x010x000x000x810x030x03M0xf4C0xf00x140xfb0xf00xfb0xda0x110xff0xb70xce0x97.0xe80xf580xee0xe10xff0xa3V:0x880x8030x8f0xe50x1c0x1390x000x00 ]. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:419) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:271) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.65.jar!/:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.65.jar!/:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
according to this thread: Tomcat: java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
this error happens because some client is calling the endpoint through https when it is only read to deal http requests. i made a simulation and this exact error happened, so some client was misconfigured and is sending https requests to this system when it shouldn't.
Again, I would like to catch this exception, so i could extract more information from the request as the ip address or anything else that help me to track down who is the misplaced consumer
how can i capture these internal tomcat exceptions in an spring boot application