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 32453109F4 for ; Fri, 30 May 2014 10:28:02 +0000 (UTC) Received: (qmail 61018 invoked by uid 500); 30 May 2014 10:28:01 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 60911 invoked by uid 500); 30 May 2014 10:28:01 -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 60903 invoked by uid 99); 30 May 2014 10:28:01 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 May 2014 10:28:01 +0000 Date: Fri, 30 May 2014 10:28:01 +0000 (UTC) From: "Bhanupavansingh (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (COLLECTIONS-532) MapUtils.predicatedMap(map, keypredicate,valuepredicate) is not working as expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Bhanupavansingh created COLLECTIONS-532: ------------------------------------------- Summary: MapUtils.predicatedMap(map, keypredicate,valuepredicate) is not working as expected Key: COLLECTIONS-532 URL: https://issues.apache.org/jira/browse/COLLECTIONS-532 Project: Commons Collections Issue Type: Bug Components: Collection, Map Affects Versions: 4.0 Environment: ubuntu/java8 Reporter: Bhanupavansingh I expected that MapUtils.predicatedMap() includes those entries of the specified map that match the specified key-predicate and specified value-predicate.I expected that entries that do not match either of the predicates not included i the returned map. But in as per the code of org.apache.commons.collections4.map. PredicatedMap.validate() protected void validate(final K key, final V value) { if (keyPredicate != null && keyPredicate.evaluate(key) == false) { throw new IllegalArgumentException("Cannot add key - Predicate rejected it"); } if (valuePredicate != null && valuePredicate.evaluate(value) == false) { throw new IllegalArgumentException("Cannot add value - Predicate rejected it"); } } if evaluation of key or value predicate fails an IllegalArgumentException is thrown. Predicates are passed to input map to test if an entry is to be included or not. If the evaluation of this predicate itself throws an exception based on result of predicate, then this method is useless and cannot be used to filter entries of a map(using predicates) -- This message was sent by Atlassian JIRA (v6.2#6252)