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 4BD1D200C73 for ; Wed, 10 May 2017 11:20:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 49B20160BA8; Wed, 10 May 2017 09:20: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 6968A160BCC for ; Wed, 10 May 2017 11:20:09 +0200 (CEST) Received: (qmail 53273 invoked by uid 500); 10 May 2017 09:20:08 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 53262 invoked by uid 99); 10 May 2017 09:20:08 -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, 10 May 2017 09:20:08 +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 292CFC0922 for ; Wed, 10 May 2017 09:20:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id KR0wBAX7wG9y for ; Wed, 10 May 2017 09:20:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 876655FD21 for ; Wed, 10 May 2017 09:20:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 34B77E0942 for ; Wed, 10 May 2017 09:20:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4FE8821E14 for ; Wed, 10 May 2017 09:20:04 +0000 (UTC) Date: Wed, 10 May 2017 09:20:04 +0000 (UTC) From: "Aled Sage (JIRA)" To: dev@brooklyn.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BROOKLYN-345) NPE on rebind of enricher ServiceStateLogic$ComputeServiceState MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 10 May 2017 09:20:10 -0000 [ https://issues.apache.org/jira/browse/BROOKLYN-345?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16004358#comment-16004358 ] Aled Sage commented on BROOKLYN-345: ------------------------------------ Note that we may still see this exception with the latest Brooklyn if trying to rebind to persisted state generated with 0.9.0 or older. In 0.10.0, we fixed the persistence to include the dynamically added config keys. For example, with 0.9.0 a persisted catalog item docker-engine-with-resilience_2.1.0-20161208.1801 declares: {noformat} brooklyn.parameters: - name: docker.recovery.stabilizationDelay label: "Stabilization Delay" description: | Time period for which the service must be consistently in the same state to trigger an action. Should be long enough that a restart will not trigger failure type: org.apache.brooklyn.util.time.Duration default: 5m {noformat} and: {noformat} brooklyn.enrichers: - type: org.apache.brooklyn.policy.ha.ServiceFailureDetector brooklyn.config: serviceOnFire.stabilizationDelay: $brooklyn:config("docker.recovery.stabilizationDelay") {noformat} But the entity (kv1zwls75t) did not persist that config key, so doesn't know the default value! In this example, after rebind, it evaluates {{$brooklyn:config("docker.recovery.stabilizationDelay")}}, which returns null. Before rebind, it correctly returned the config key's default value. > NPE on rebind of enricher ServiceStateLogic$ComputeServiceState > --------------------------------------------------------------- > > Key: BROOKLYN-345 > URL: https://issues.apache.org/jira/browse/BROOKLYN-345 > Project: Brooklyn > Issue Type: Bug > Reporter: Aled Sage > Fix For: 0.10.0 > > > Using Brooklyn 0.10.0-SNAPSHOT (e.g. brooklyn-server commit 66b9b1c)... > When rebinding to existing persisted state, it failed to create the enricher {{ServiceStateLogic$ComputeServiceState}} with the NPE shown below (but then continued, so this is otherwise benign): > {noformat} > 2016-09-09 09:31:03,850 WARN o.a.b.c.m.r.RebindExceptionHandlerImpl [brooklyn-execmanager-VtZheMDn-0]: problem adding enricher cdoy70m1hv (ServiceFailureDetector{name=org.apache.brooklyn.policy.ha.ServiceFailureDetector, uniqueTag=service.state.actual, running=true, entity=VanillaSoftwareProcessImpl{id=pwz8z4pbyp}, id=cdoy70m1hv}) to entity pwz8z4pbyp (VanillaSoftwareProcessImpl{id=pwz8z4pbyp}); continuing > java.lang.NullPointerException: null > at org.apache.brooklyn.policy.ha.ServiceFailureDetector.setActualState(ServiceFailureDetector.java:188) ~[brooklyn-policy-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.onEvent(ServiceStateLogic.java:288) ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.policy.ha.ServiceFailureDetector.onEvent(ServiceFailureDetector.java:159) ~[brooklyn-policy-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic$ComputeServiceState.setEntity(ServiceStateLogic.java:274) ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.entity.AbstractEntity$BasicEnricherSupport.add(AbstractEntity.java:1788) ~[brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:145) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport.addEnrichers(BasicEntityRebindSupport.java:47) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.associateAdjunctsWithEntities(RebindIteration.java:650) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.doRun(RebindIteration.java:244) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindIteration.run(RebindIteration.java:266) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:558) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:508) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.core.mgmt.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:506) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519) [brooklyn-core-0.10.0-20160907.0931.jar:0.10.0-20160907.0931] > at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_95] > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_95] > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_95] > at java.lang.Thread.run(Thread.java:745) [na:1.7.0_95] > {noformat} > The line throwing the NPE is executing {{setEntityOnFireTime = now + getConfig(SERVICE_ON_FIRE_STABILIZATION_DELAY).toMilliseconds()}}. That suggests we got null for the config value, even though there is a default value of zero for it. > The enricher persisted state contains: > {noformat} > > > > > THIS > > swarm.recovery.stabilizationDelay > > > {noformat} > And the owning entity has: > {noformat} > brooklyn.parameters: > - name: swarm.recovery.stabilizationDelay > label: Stabilization Delay > description: | > Time period for which the service must be consistently in the same state to trigger an action > # A restart shouldn't trigger failure > type: org.apache.brooklyn.util.time.Duration > default: 5m > {noformat} > There are a few things we should think about fixing: > 1. guard against the NPE in {{ServiceFailureDetector.setActualState}} (i.e. handle when the config returns null) - but unclear what value it should then default to. > 2. avoid calling this code on rebind. for example, instead of {{ComputeServiceState.setEntity}} immediately calling {{onEvent(null)}}, it could subscribe with "notifyOfInitialValue" so that it gets a callback (in the right thread, at the right time). > 3. investigate further why the config lookup returned null - e.g. is it because entity wasn't fully initialised, or because the DSL didn't find the default value defined in brooklyn.parameters? -- This message was sent by Atlassian JIRA (v6.3.15#6346)