Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 399E818F91 for ; Sun, 25 Oct 2015 19:36:34 +0000 (UTC) Received: (qmail 88968 invoked by uid 500); 25 Oct 2015 19:36:27 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 88874 invoked by uid 500); 25 Oct 2015 19:36:27 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 88863 invoked by uid 99); 25 Oct 2015 19:36:27 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Oct 2015 19:36:27 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id A55E82C033A for ; Sun, 25 Oct 2015 19:36:27 +0000 (UTC) Date: Sun, 25 Oct 2015 19:36:27 +0000 (UTC) From: "Anthony Whitford (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (POOL-306) BaseGenericObjectPool IdentityWrapper equals violates Java spec MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Anthony Whitford created POOL-306: ------------------------------------- Summary: BaseGenericObjectPool IdentityWrapper equals violates Java spec Key: POOL-306 URL: https://issues.apache.org/jira/browse/POOL-306 Project: Commons Pool Issue Type: Bug Affects Versions: 2.4.2 Reporter: Anthony Whitford Priority: Minor Noticed that the {{equals}} implementation assumes the {{other}} parameter can be successfully cast to {{IdentityWrapper}}: {code} @Override @SuppressWarnings("rawtypes") public boolean equals(Object other) { return ((IdentityWrapper) other).instance == instance; } {code} (There is a chance that this could throw a {{ClassCastException}}.) See [BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS|http://findbugs.sourceforge.net/bugDescriptions.html#BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS]. I recommend: {code} @Override @SuppressWarnings("rawtypes") public boolean equals(Object other) { return other instanceof IdentityWrapper && ((IdentityWrapper) other).instance == instance; } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)