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 17A5018875 for ; Wed, 10 Jun 2015 20:13:01 +0000 (UTC) Received: (qmail 18451 invoked by uid 500); 10 Jun 2015 20:13:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 18353 invoked by uid 500); 10 Jun 2015 20:13:00 -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 18341 invoked by uid 99); 10 Jun 2015 20:13:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Jun 2015 20:13:00 +0000 Date: Wed, 10 Jun 2015 20:13:00 +0000 (UTC) From: "Waldemar Maier (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (LANG-1144) Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Waldemar Maier updated LANG-1144: --------------------------------- Summary: Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible (was: Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize()) > Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible > ----------------------------------------------------------------------------------------------- > > Key: LANG-1144 > URL: https://issues.apache.org/jira/browse/LANG-1144 > Project: Commons Lang > Issue Type: Bug > Components: lang.concurrent.* > Affects Versions: 3.4 > Environment: Java 1.8 on Windows 7 x64 > Reporter: Waldemar Maier > Priority: Critical > > It is possible to create a construct, that allows multiple calls of LazyInitializer.initialize, when calculations (which can be very expensive) return null as result. > The Junit Test can be something like this: > {code:java} > package edu.test; > import static org.junit.Assert.assertEquals; > import org.apache.commons.lang3.concurrent.ConcurrentException; > import org.apache.commons.lang3.concurrent.LazyInitializer; > import org.junit.Test; > public class LazyInitializerTest { > private int lazyinitCounter = 0; > private LazyInitializer lazyIinit = new LazyInitializer() { > @Override > protected Object initialize() throws ConcurrentException { > lazyinitCounter++; > return doSomeVeryExpensiveOperations(); > } > }; > > > private Object doSomeVeryExpensiveOperations() { > // do db calls > // do some complex math calculations > // the result of them all is null > return null; > } > > > @Test > public void testInitialization() throws Exception { > lazyIinit.get(); > lazyIinit.get(); > assertEquals("Multiple call of LazyInitializer#initialize", 1, lazyinitCounter); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)