From user-return-31098-archive-asf-public=cust-asf.ponee.io@commons.apache.org Thu Feb 1 10:27:10 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 6DFD3180652 for ; Thu, 1 Feb 2018 10:27:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5D7E6160C56; Thu, 1 Feb 2018 09:27:10 +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 A57A1160C44 for ; Thu, 1 Feb 2018 10:27:09 +0100 (CET) Received: (qmail 39622 invoked by uid 500); 1 Feb 2018 09:27:08 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 39137 invoked by uid 99); 1 Feb 2018 09:27:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Feb 2018 09:27:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 1D021C340B for ; Thu, 1 Feb 2018 09:27:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.999 X-Spam-Level: * X-Spam-Status: No, score=1.999 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=wellnerbou-de.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id oKDW2uw-CQGB for ; Thu, 1 Feb 2018 09:27:05 +0000 (UTC) Received: from mail-oi0-f47.google.com (mail-oi0-f47.google.com [209.85.218.47]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 139975FB9E for ; Thu, 1 Feb 2018 09:27:05 +0000 (UTC) Received: by mail-oi0-f47.google.com with SMTP id l8so12850133oig.0 for ; Thu, 01 Feb 2018 01:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wellnerbou-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=MPeI22A/sX12rOQgV+1kroH6no0uylEnW1xDtkUrw8c=; b=YUWc+V6vOrdS4IYWgUQjNppAL9Pzj7tYG7zCn7CNYc9m4YkR6WgKZA6yaYxcPmvXO9 qg/103sf3sb2uVTg0AVJie6yB8Rqhyn0o/Y1Mma1fkKkiSce2OjDw45grCB7wtFyncE+ /XCSAFjqZw6oEvUu+1M0VLqEPc1PftlQcqunjPWb/4Gg1x+iUuUO/XmSUKRmKs9tpe9s iynFp9TxaUIrQ12l090crwW0vSDAQNcSlFw6YMf1yGf6q7GYS4IPJBI4Oha+/s6Xvuf4 SBuJunwi4Sj5wjVI31kKC9xLy99KjzUmbq84It8nayk8o3VOCasqm+RuV6STLXose19/ /S9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=MPeI22A/sX12rOQgV+1kroH6no0uylEnW1xDtkUrw8c=; b=bLzkL8cjMS0aOj1j+FIV1iGLKG0EtdgRLmvkttCO1fhylNIlliJGnZAXdQm9I1ZPKn cvRo1o3ksKGnP8x2RhV4ek/1f5u/hmSw8Lla4pStaHwyQqoRtXwOMlVyXucaOFLfZMvW dYNdTTFvVA9oiWEBgR5vcGZSF1YUpTNJILtvz0vsODtMtql3hlHUb0HZrJinkVMt77cB Yi1VCxbVD0wTT4p3HkB95XyNab1YvmP6e68iVX/IQnH1RRnTjGSi0YOq3jnCxo3jYzre Hwug/PdaEAgR3YMM/XGLXZIvRILxX7Y+7hg6n1R3uEg/H2z3ZyRl0viDSoHc3rRFA5Ck tV4A== X-Gm-Message-State: AKwxyte/UAlVVsDdwVNPLkvLaC5PVYMZGXu8c13MU0mRY1GUYLjpiS0s DfVrgu6/pnI34FoFPLPjD7IYnQGF+2UiQIL/SoSMwQ== X-Google-Smtp-Source: AH8x2253FrvDT5qOI3it7K11pTFzh9wSnT9MC97SBRSzi/M/6u9B0xZOn419+bsqpfdWYYFV3dcUVKVIuPIuuRBpJs4= X-Received: by 10.202.25.15 with SMTP id l15mr10782164oii.212.1517477223543; Thu, 01 Feb 2018 01:27:03 -0800 (PST) MIME-Version: 1.0 References: <34fc5a7f-97d3-0ac5-1c62-bba82121b30a@oliver-heger.de> In-Reply-To: <34fc5a7f-97d3-0ac5-1c62-bba82121b30a@oliver-heger.de> From: Paul Wellner Bou Date: Thu, 01 Feb 2018 09:26:53 +0000 Message-ID: Subject: Re: [configuration] Reloading properties does not work as expected To: Commons Users List Content-Type: multipart/alternative; boundary="f4f5e808c66cdd497405642332f3" --f4f5e808c66cdd497405642332f3 Content-Type: text/plain; charset="UTF-8" Hi, thank you very much. Yes, this helps. This is more or less what I found out as well. That's why I introduced the 6 seconds delay in my original example, to wait for this 5s timeout. I tried to call getProperty more than once, too, because I noticed debugging that the check time is only filled after the first call. But somehow I wrote my test code in a way, that the reloading time was the same as the time the file changed (which may happen in unit tests, its the same millisecond). So the test failed again. Now I reordered the statements a bit, and it works now. I just need to add a call in the very beginning of the test. The timeouts I introduced in the first approach are already enough. So it works now. Thanks very much! https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7 > i am trying to implement a reloadable property using commons-reloading2 > > (2.2), without success. I tried to follow the (outdated) examples on > > > https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations > > (both of them). > > Could you be a bit more specific about what is outdated, so that we can > update the examples? > Sure: https://gist.github.com/paulwellnerbou/3e309535a8a516477dc2bede478f79f2/revisions Maybe you could add that commons-beanutils:1.9.3 is required to avoid the NoClassDefFoundException ( https://stackoverflow.com/questions/16266047/very-simple-apache-commons-configuration-example-throws-noclassdeffounderror ). Cheers, Paul. > > > Now I created a unit test against this API which I would expect it to > pass, > > but it doesn't: > > https://gist.github.com/paulwellnerbou/dfed371d67e2f19a699b248ebf5c62d7 > > > > Any idea what I am doing wrong? > > I had a deeper look at the test and the implementation, and here is what > I found out: > > The class for checking whether a reload of a file is required is > FileHandlerReloadingDetector. The class records the time of the last > check and has a refreshDelay property; it only checks again after the > time configured for the delay is elapsed. The default refreshDelay is 5 > seconds. This is one reason why your test does not pass; you need to > decrease this delay or wait longer. > > The other reason is that there is indeed a problem in the implementation > that causes the first call to getConfiguration() to get missed by the > reload checker. The CONFIGURATION_REQUEST event is already fired before > the file to be loaded is properly initialized, and therefore, the > checker cannot set its last check time. This is initialized only at the > second call to getConfiguration(). So the test would only be successful > if getConfiguration() was called another time (taking the refresh delay > into account). > > This can be considered a bug, but is probably not very problematic in > practice when the configuration is accessed on a regular basis. > > HTH > Oliver > > --f4f5e808c66cdd497405642332f3--