LoginSignup
21
9

More than 3 years have passed since last update.

[5.2.1で解決済み] Spring Security 5.2.0.RELEASEには、リリースノートに書かれていない非互換性があります

Last updated at Posted at 2019-10-18

対象

  • spring-security-config 5.2.0.RELEASE

何が非互換性か

WebSecurityConfigurerAdapterconfigure(WebSecurity) メソッドの定義から、 throws Exception が削除されています。

コミット差分はこちらWebSecurityConfigurerAdapter 以外にも、同様の変更がされたクラスがいっぱいありますね。

これにより、5.1.xから5.2.0.RELEASEにライブラリをアップグレードすると、WebSecurityConfigurerAdapter のサブクラスでコンパイルエラーが発生します。オーバーライド元に throws Exception が無いからです。

WebSecurityConfigurerAdapterサブクラスの例(変更前)
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    // このメソッドでコンパイルエラーが発生
    @Override
    public configure(WebSecurity web) throws Exception {
        // ...
    }
}

[2019/11/07追記] Spring Security 5.2.1.RELEASEで、削除された throws Exception が元に戻りました! -> コミット履歴

対策

configure(WebSecurity) メソッドから、 throws Exception を削除しましょう。

WebSecurityConfigurerAdapterサブクラスの例(変更後)
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    // これでコンパイルエラーは発生しない
    @Override
    public configure(WebSecurity web) {
        // ...
    }
}

前述のコミットログによると、他にも多数のメソッドから throws Exception が削除されているようです。

これらのメソッドを利用している場合は、すべて同様の作業が必要になります。

[2019/11/07追記] 5.2.0でこの対策をされた方は、5.2.1にアップグレードされた際、 throws Exception を追加する必要は無いはずです。

しかし・・・

こーゆーことはしないでほしいですねえ。。。

Spring SecurityのIssueに上げてあります。

21
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
9