Fork me on GitHub
#interceptors
<
2023-05-26
Matthew Davidson (kingmob)04:05:01

Cross-posting this from elsewhere. Someone asked about the history of interceptors, so I did a little digging. Enjoy! *Matthew Davidson (kingmob)* [2:18 PM] Interceptors are at least twenty years old, though I can't tell who originated it. It's probable the pattern is even older than that under different names (e.g., audio/video processing pipelines). The first printed reference I can find for the interceptor is from _<https://en.wikipedia.org/wiki/Pattern-Oriented_Software_Architecture#POSA2|Pattern-Oriented Software Architecture, 2nd Ed>._ from 2000. (Ed. 1 doesn't list the pattern.) The POSA2 book pattern is quite general. The first reference I can find to it being used for _web_ requests is the "intercepting filter". Here's a <https://web.archive.org/web/20021001190923/http://java.sun.com/blueprints/corej2eepatterns/Patterns/InterceptingFilter.html|Sun page> on the topic from 2002. *Daniel Gerson* [8:46 PM] <@U10EC98F5> I skimmed the link you referenced, but at least two considerations appear absent. 1) That the executor handles asynchronous filters protecting other filters from the mess that is asynchronous nesting. 2) That the interceptor filters queued and stack run are available for manipulation on the context itself! No doubt that the lineage of the Interceptor pattern derives from this prior art, but in my mind it deserves a 2.0 status with these criteria met. Begs the question how old 2.0 is? *Matthew Davidson (kingmob)* [9:29 PM] <@U03B2SRNYTY> Not sure which link you're referring to, but the Sun page on the InterceptingFilter talks about dynamically altering the interceptor list. I think that meets your criterium #2 iiuc. I know for sure that Netty's ChannelPipeline meets both criteria, and it dates back to 2008, predating Pedestal by 5 years. Netty itself dates back to 2004, so it's possible interceptors existed even earlier in a different file. (And I'm not even sure that's the oldest async usage. E.g., Tomcat has interceptors and was started back in 1998, but I'm not very familiar with it)

🧑‍🎓 2
gratitude 2
🐢 2
nice 1