Return-Path: X-Original-To: apmail-zest-dev-archive@minotaur.apache.org Delivered-To: apmail-zest-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F8D017FAC for ; Wed, 24 Jun 2015 15:41:11 +0000 (UTC) Received: (qmail 12633 invoked by uid 500); 24 Jun 2015 15:41:11 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 12596 invoked by uid 500); 24 Jun 2015 15:41:11 -0000 Mailing-List: contact dev-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list dev@zest.apache.org Received: (qmail 12582 invoked by uid 99); 24 Jun 2015 15:41:10 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jun 2015 15:41:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 865AD18195D for ; Wed, 24 Jun 2015 15:41:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.982 X-Spam-Level: ** X-Spam-Status: No, score=2.982 tagged_above=-999 required=6.31 tests=[AC_DIV_BONANZA=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 8pyIkLODwE7l for ; Wed, 24 Jun 2015 15:41:04 +0000 (UTC) Received: from mail-ig0-f177.google.com (mail-ig0-f177.google.com [209.85.213.177]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 1C854262B0 for ; Wed, 24 Jun 2015 15:41:03 +0000 (UTC) Received: by igbqq3 with SMTP id qq3so117151398igb.0 for ; Wed, 24 Jun 2015 08:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=+uK4b7lBq8gcT6zPLgoRQo4NGT2EdbzThFhhNtcSBGs=; b=gFZhFCMtQ4hLKHj5cVOGIf7J4iss0182pTBDET6EZoS+L9Fc6sqv5qLunSF8+FLpcD 9/gt0ajF39OzoigrfVMRcY3iumi43NCmzWYMr1NaAy3ixmHV77DY8Lzv5EBarqQF3VAq eni9egMYidsul5vPUpbjuqnkLqZegffv1wcC+dzHFc92vChKrTk9Cw+XWUsWxkEEWXAK sLADRMq2HaLmmxMSBL0c9URImHLoGcnAhgEkWD++Ot8dWyHPQUiNlkTgrwey9ufTPrtr kC/mi2in0sU/S4gAWm+he9x26Y2QkIZc8fM1svkcWECL0QXuM7RtOur6bc/tDy/0O0P+ j2Ig== X-Received: by 10.43.151.83 with SMTP id kr19mr38000860icc.3.1435160456438; Wed, 24 Jun 2015 08:40:56 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.36.98.18 with HTTP; Wed, 24 Jun 2015 08:40:37 -0700 (PDT) In-Reply-To: References: From: Niclas Hedhman Date: Wed, 24 Jun 2015 23:40:37 +0800 X-Google-Sender-Auth: 5BtuSGl51Nw2EAHTZdCNej3nlNU Message-ID: Subject: Re: Bug found in UnitOfWork To: dev Content-Type: multipart/alternative; boundary=001a11c2fd9e33adfa05194555c4 --001a11c2fd9e33adfa05194555c4 Content-Type: text/plain; charset=UTF-8 Follow-up; The case when it gets wrong is more complex than my list, and I am not able to create a testcase for this... On Wed, Jun 24, 2015 at 10:51 PM, Niclas Hedhman wrote: > Gang, > > I have found a fairly sophisticated bug, which is rather severe and > possibly hard to fix without breaking applications, that might depend on > wrong behavior... > > It manifests itself as not having the right Visibility of entities, and > the reason is because the EntityStoreUnitOfWork may be set up incorrectly > sometimes. > > I think it happens if the following sequence occurs; > > a. Creation of a UnitOfWork > b. Accessing entity E in module M > c. Entity E calls service S in module N. > d. Service S tries to access entity F in module N. > > internally, the EntityStoreUnitOfWork will have been initialized with the > Module M, and uses that to find entity F, which is not seen > (Visibility.module). > > This is very similar to a design flaw a long time ago, where the > visibility was effectively in the wrong Layer, and that is when the "split" > UnitOfWork concept was introduced (2008?). > > The issue manifests itself in UnitOfWorkInstance in the following method; > > public EntityStoreUnitOfWork getEntityStoreUnitOfWork( EntityStore store, Module module ) > { > EntityStoreUnitOfWork uow = storeUnitOfWork.get( store ); > if( uow == null ) > { > uow = store.newUnitOfWork( usecase, module, currentTime ); > storeUnitOfWork.put( store, uow ); > } > return uow; > } > > as the EntityStoreUnitOfWork will have been created with the wrong module. > > I think the solution is that the Module must also be part of the cache > key, and that this would solve it. However, I am very anxious that this may > break something else very badly, as it is fairly central to the entire > UnitOfWork flow. > > The reason I say that it might break applications is that, the called > Service has access to the entities in the modules calling it, and someone > might depend on that. But I think, we should be allowed to break bug > compatibility... Or?? > > BTW, this touches on the "multiple entitystore" feature that came up > during the discussion of the Messaging abstraction. > > Cheers > -- > Niclas Hedhman, Software Developer > http://zest.apache.org - New Energy for Java > -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java --001a11c2fd9e33adfa05194555c4--