關於 class Chain,setSuccessor 如果回傳 ‵this‵ ,以文中的舉例:

chainRequest400

.setSuccessor(chainRequest401)

.setSuccessor(chainRequest403)

.setSuccessor(chainRequest404);

會導致一直 overwrite 自己的 successor,也就是說最後的結果會是 chainReqeust400 有一個 chainRequest404 的 successor,401 跟 403 會命中不了。

應該要 return this.successor 才能一步一步串接下去,看了之後發現有這個問題,有錯的話再麻煩糾正XDD。

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store