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 72CA317DC3 for ; Wed, 24 Jun 2015 14:52:05 +0000 (UTC) Received: (qmail 85818 invoked by uid 500); 24 Jun 2015 14:52:05 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 85774 invoked by uid 500); 24 Jun 2015 14:52:05 -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 85753 invoked by uid 99); 24 Jun 2015 14:52:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jun 2015 14:52:05 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=AC_DIV_BONANZA,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of hedhman@gmail.com designates 209.85.223.175 as permitted sender) Received: from [209.85.223.175] (HELO mail-ie0-f175.google.com) (209.85.223.175) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jun 2015 14:49:49 +0000 Received: by iebrt9 with SMTP id rt9so34786144ieb.2 for ; Wed, 24 Jun 2015 07:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=uGyv244R9+hJRxH6PmGBSrKoh59DwjQSObaM8bnXaEE=; b=0WjGZhB2fyP2tyFogzSTFLMfAYSqkE1OOHl8OUEQLXpHAqoAUXqYrypSiC0B5b1+17 mssoyuLaR2NhNo3hVoeWj35N5HZuCjMh2lWH/VERgK4U2gMDD6KKVP68GBtH3ipX3R4U zVz3x4qR9JJyuxUKVXb++2ewYe7zws8T5Z67BKb9WlH4obxIpoIPpSRtNyjRQOD20ly9 xyv2U86/nJUDbQ81YNHu9L2dDAsSDP6z3u4YFfkrolfaqKBJAuSGropy4sKORk7dPK5I dCnz+3Z1TmD/fK+JR4Jq+TtGLKz+K3zRSH1dzjotLz3p41IUwlkcERycefWvv7B5G1bR HnLA== X-Received: by 10.50.143.104 with SMTP id sd8mr3634801igb.14.1435157497641; Wed, 24 Jun 2015 07:51:37 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.36.98.18 with HTTP; Wed, 24 Jun 2015 07:51:18 -0700 (PDT) From: Niclas Hedhman Date: Wed, 24 Jun 2015 22:51:18 +0800 X-Google-Sender-Auth: 5jQZ4ZSzcLvf9ASoOeFQV-NrJ3c Message-ID: Subject: Bug found in UnitOfWork To: dev Content-Type: multipart/alternative; boundary=001a1135f1a6d800ab051944a4cf X-Virus-Checked: Checked by ClamAV on apache.org --001a1135f1a6d800ab051944a4cf Content-Type: text/plain; charset=UTF-8 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 --001a1135f1a6d800ab051944a4cf--