PageParameters.hashCode is inconsistent with equals for named parameters in a different order

オープン 初心者向け
#1,866 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

Javaソースコードで PageParameters.equals と PageParameters.hashCode を見つけ、その実装と近くにあるテストを読んでください。異なる順序で挿入された同じ名前付きパラメーターを対象とするテストを追加または更新し、それらのハッシュコードが一致することを確認してください。issueでは、ペアのハッシュコードを合計する方法が1つの案として説明されています。

索引モデルが issue の本文から書いたものです。

説明

PageParameters.equals and PageParameters.hashCode disagree about the named parameters, so two PageParameters that are equal can have different hash codes. That breaks the contract of Object.hashCode.

equals compares the named parameters regardless of their order: the lists must hold the same pairs, each the same number of times. hashCode uses namedParameters.hashCode(), the order-sensitive hash of the List<NamedPair>.

PageParameters a = new PageParameters().add("a", "1").add("b", "2");
PageParameters b = new PageParameters().add("b", "2").add("a", "1");

a.equals(b);                    // true
a.hashCode() == b.hashCode();   // false

Anything that puts PageParameters in a hash-based collection, or in a key that includes them, can treat these two as different. The fix is to make hashCode order-insensitive for the named parameters, for example by summing the hash codes of the pairs.

主要言語
Java
スター
799
フォーク
420
平均マージ
18時間 37分
マージ済み PR(30日)
140

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/wicket のほかの issue

apache/wicket の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。