Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C6898200BDA for ; Tue, 13 Dec 2016 13:40:12 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C53E4160B23; Tue, 13 Dec 2016 12:40:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3F480160B15 for ; Tue, 13 Dec 2016 13:40:12 +0100 (CET) Received: (qmail 52517 invoked by uid 500); 13 Dec 2016 12:40:11 -0000 Mailing-List: contact dev-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list dev@syncope.apache.org Received: (qmail 52506 invoked by uid 99); 13 Dec 2016 12:40:11 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2016 12:40:11 +0000 Received: from [192.168.0.7] (93-56-25-79.ip287.fastwebnet.it [93.56.25.79]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id A9C371A0055 for ; Tue, 13 Dec 2016 12:40:10 +0000 (UTC) Subject: Re: JPAConfDao ClassCastException To: dev@syncope.apache.org References: From: =?UTF-8?Q?Francesco_Chicchiricc=c3=b2?= Message-ID: Date: Tue, 13 Dec 2016 13:40:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit archived-at: Tue, 13 Dec 2016 12:40:13 -0000 On 13/12/2016 13:31, Colm O hEigeartaigh wrote: > The following case in JPAConfDao will result in a ClassCastException as > JPACPlainAttrValue does not implement the interface PlainAttrUniqueValue. > > JPACPlainAttrValue attrValue; > if (newAttr.getSchema().isUniqueConstraint()) { > attrValue = new JPACPlainAttrValue(); > ((PlainAttrUniqueValue) attrValue).setSchema(newAttr.getSchema()); > } > > What should this be instead? I guess you are referring to [1]; to me, the highlighted snippet should become PlainAttrValue attrValue; if (newAttr.getSchema().isUniqueConstraint()) { attrValue = new JPACPlainAttrUniqueValue(); ((PlainAttrUniqueValue) attrValue).setSchema(newAttr.getSchema()); } else { attrValue = new JPACPlainAttrValue(); } WDYT? [1] https://github.com/apache/syncope/blob/2_0_X/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAConfDAO.java#L71-L77 -- Francesco Chicchiriccò Tirasa - Open Source Excellence http://www.tirasa.net/ Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/