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 E2F35200C62 for ; Wed, 26 Apr 2017 12:20:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E16C7160BA8; Wed, 26 Apr 2017 10:20:05 +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 0A147160B95 for ; Wed, 26 Apr 2017 12:20:04 +0200 (CEST) Received: (qmail 39282 invoked by uid 500); 26 Apr 2017 10:20:04 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 39272 invoked by uid 99); 26 Apr 2017 10:20:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2017 10:20:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B3A44C0787 for ; Wed, 26 Apr 2017 10:20:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 76aO23rxP2nt for ; Wed, 26 Apr 2017 10:20:01 +0000 (UTC) Received: from mail-ua0-f169.google.com (mail-ua0-f169.google.com [209.85.217.169]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id EDF5B5F297 for ; Wed, 26 Apr 2017 10:20:00 +0000 (UTC) Received: by mail-ua0-f169.google.com with SMTP id f10so146318990uaa.2 for ; Wed, 26 Apr 2017 03:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=zckhBZ2Po6AZnPAicXrfS+aVIyw+MRIAVrtUrJ3QJ2s=; b=WDN4AFn39uTW9JK7QLHs8z3OiYaCDgB0tlOq+qEiNRLybQnVz6xgB87Bq7O4h7N9Lr ZOzuXs25wOJ1I79I0Xa8AXnnZRs5dCsd9UzN2XbvZSTl2dDYKzvXUlI7N4BHXxGBm6r/ +rVapAhcb/R+2FFxUMCD8Zod5iFH/c8UcdN9VTO0yUbRH1QI3a2FI3k0fKk7Cq6V0D1M zkA8Qvxp8ioZWHRJUjYPj8L4nh8chnq3xEtw2mjnN39FzJzbD42towSEYCwY4S1zf/AP cHiVBGtiBPiMf/MVB8WufUWbOZpSq340L4haZCF/gCS0vQ5o6ZnZXalmmmXC2dBldDGb YirQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=zckhBZ2Po6AZnPAicXrfS+aVIyw+MRIAVrtUrJ3QJ2s=; b=LxS/q4rrMkQPWQ7gBZ2pAGwKw8uKIDFV3RG+zHVCUSBa4IefbuhxoFTqiQInYR6bZ9 LArVVG6WxEw8R0TvXa620XBy3EbEHSoOtjP2A+6cY65BgnIQIhwSlv05MX4jMuh1kzex iH3rVUXOJU04PRmRlxwCgLvRQ/siTXAUjBWfxys2bvXU/ynikD+HpsiI5YKiIIztG95D YtsvvVBT7slnAWlvRcjQlunXAdIijbnA2MpxhIMZ3ODYHx7rjVoLJ+C4lQvf+S7khjVw fcxYxrfJ9lEEq0HrU58dXp6UYlG/txt13IZlGwfhWAhOcz8NwFZNme8Q9ZmEMsR3PPzO LWkw== X-Gm-Message-State: AN3rC/4iB6+1z9ewJ0hAHCLoXlZflyLJsNQT6FCP9AjOJMb0u3atr6fr 1AD8/CUCZS2xhASx7hfQb2O6rB7Tut3y X-Received: by 10.176.9.196 with SMTP id e4mr19026301uah.34.1493201993556; Wed, 26 Apr 2017 03:19:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.7.136 with HTTP; Wed, 26 Apr 2017 03:19:53 -0700 (PDT) In-Reply-To: References: From: Andrey Mashenkov Date: Wed, 26 Apr 2017 13:19:53 +0300 Message-ID: Subject: Re: Weird behaviour about enum with methods To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=f403043ed32c67688c054e0f2e34 archived-at: Wed, 26 Apr 2017 10:20:06 -0000 --f403043ed32c67688c054e0f2e34 Content-Type: text/plain; charset=UTF-8 Hi David, Looks like a bug. As a workaround, you can either use optimized marshaller or compare enum ordinal. I've created an issue IGNITE-5087 [1]. [1] https://issues.apache.org/jira/browse/IGNITE-5087 On Mon, Apr 24, 2017 at 10:57 AM, David Li wrote: > Hi all, > > I encountered something weird about enum value in the object stored in > ignite cache. > > for example: > > class definition: > > public class Application { > private long id; > private String name; > private ApplicationType type; > } > > enum definition: > > public enum ApplicationType { > TX { > @Override > public boolean isSupported() { > return true; > } > }, > API { > @Override > public boolean isSupported() { > return true; > } > }; > > public abstract boolean isSupported(); > } > > then have a cache like: > > IgniteCache cache > > When get back the Application instance from cache, the value of the type > > property will not equal to the enum value in the enum class, i found their > > hash code is different, even though they have same class name. > > for example, > > Application app = new Application(1L, "app 1", ApplicationType.API); > > app.getType() == ApplicationType.API is true > > app.getType().getClass().getName() is ApplicationType$2, hash code is 251520863 > > > Application appFound = cache.get(app.getId()); > > appFound.getType() == Application.API is false > > appFound.getType().getClass().getName() is ApplicationType$2, hash code is 331596257 > > > ApplicationType.API.hashCode() is 251520863 > > > I tried an enum without any method definitions, then no issue. Any idea about this? > > > BRs, > > David > > > -- Best regards, Andrey V. Mashenkov --f403043ed32c67688c054e0f2e34 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi David,

Looks like a bug. As a workar= ound, you can either use optimized marshaller or compare enum ordinal.
I've created an issue IGNITE-5087 [1].


On Mon, Apr 24, 2017 at 10:57 AM= , David Li <david.li.sg@gmail.com> wrote:
Hi all,

I encounter= ed something weird about enum value in the object stored in ignite cache.

for example:

class definit= ion:
public class Application {
p= rivate long i= d;
privat= e String name= ;
private= ApplicationType type;
}
enum definition:
public enum A=
pplicationType {
TX {
@Override
public boolean isSupported() {
return true;
}
},
API {
= @Override
public boolean isSupported() {
return true
;
= }
};

public abstract boolean isSupported();
}
then have a cache like:
IgniteCache<Long, Application> cache
When get back the Application instance from cache, the value of the type <=
/span>
property will not equal to the enum value=
 in the enum class, i found their
hash co=
de is different, even though they have same class name.
for example, 
Application app =3D =
new Application(1L, "app 1", App=
licationType.API);
app.getType() =3D=3D ApplicationType.API is true
a=
pp.getType().getClass().getName() is ApplicationType$2, hash code is 2=
51520863

Application appFound =3D cache.g= et(app.getId());
appFou=
nd.getType() =3D=3D Application.API is false
appFound.getType().getClass().getName() is Appli=
cationType$2, hash code is 331596257

ApplicationType.API.hashCode() is 251520863

I tried an e=
num without any method definitions, then no issue. Any idea about this?

BRs,
David

=



--
Best regards,
Andrey V. Mashenkov
--f403043ed32c67688c054e0f2e34--