From dev-return-92972-archive-asf-public=cust-asf.ponee.io@sling.apache.org Fri Oct 26 14:46:10 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id AC82C180647 for ; Fri, 26 Oct 2018 14:46:09 +0200 (CEST) Received: (qmail 89444 invoked by uid 500); 26 Oct 2018 12:46:03 -0000 Mailing-List: contact dev-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list dev@sling.apache.org Received: (qmail 89433 invoked by uid 99); 26 Oct 2018 12:46:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2018 12:46:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 183031A4E4D for ; Fri, 26 Oct 2018 12:46:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.3 X-Spam-Level: X-Spam-Status: No, score=-110.3 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id MYrf3bdZq1EQ for ; Fri, 26 Oct 2018 12:46:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 440D15F476 for ; Fri, 26 Oct 2018 12:46:01 +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 9566BE0E87 for ; Fri, 26 Oct 2018 12:46:00 +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 48D7723F98 for ; Fri, 26 Oct 2018 12:46:00 +0000 (UTC) Date: Fri, 26 Oct 2018 12:46:00 +0000 (UTC) From: "Julian Sedding (JIRA)" To: dev@sling.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SLING-8051) Timing issue in SlingMainServlet MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SLING-8051?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1666= 5126#comment-16665126 ]=20 Julian Sedding commented on SLING-8051: --------------------------------------- I pushed a proposed fix to my [fork of Sling Engine|https://github.com/jsed= ding/sling-org-apache-sling-engine/commit/19675762e48604e4cde0a3ebac754d73d= d879334]. First tests look promising, but I'll need more time to test also = on stand-alone deployments. [~cziegeler], [~rombert] I would appreciate if you could review my changes. > Timing issue in SlingMainServlet > -------------------------------- > > Key: SLING-8051 > URL: https://issues.apache.org/jira/browse/SLING-8051 > Project: Sling > Issue Type: Improvement > Components: Engine > Affects Versions: Engine 2.6.14 > Reporter: Julian Sedding > Assignee: Julian Sedding > Priority: Major > Attachments: SLING-8051-stack-trace.txt > > > There seems to be a timing issue in the {{SlingMainServlet}}, which is ro= oted in the fact that it is subject to OSGi's DS life-cycle, as well as the= {{Servlet}} life-cycle (as implemented in teh HTTP whiteboard. > In its {{activate}} method the {{SlingMainServlet}} registers itself as a= {{Servlet}} via the HTTP whiteboard. At this point it assumes that the whi= teboard immediately calls its {{init()}} method. > Directly afterwards it registers a {{SlingServletContext}} instance as a = {{ServletContext}} in the service registry, which in turn contains a refere= nce to the {{SlingMainServlet}} instance. > However, it may happen (I have observed this on Tomcat, i.e. not in stand= alone mode), that the HTTP whiteboard is only registered after the {{SlingM= ainServlet}} has been activated. This leaves a large time window, i.e. betw= een {{SlingMainServlet.activate}} and the registration of the HTTP whiteboa= rd, which eventually leads to {{SlingMainServlet.init(ServletConfig)}} bein= g called. Within this time window, other DS components may pick up a refere= nce e.g. to the {{SlingServletContext}}, which is backed by an activated bu= t uninitialized {{SlingMainServlet}}. > The {{SlingServletResolver}} has a static reference to the {{SlingServlet= Context}}, and starts initializing (Sling-)Servlets immediately, passing a = {{SlingServletConfig}} backed by the {{SlingServletContext}} instance to th= eir {{#init(ServletContext)}} method. > Now any init method that happens to call the wrong method on {{SlingServl= etConfig}} is prone to {{NullPointerException}}s because {{SlingServletConf= ig.getServletContext().getServletConfig() =3D=3D null}}. > This was observed with the {{SlingWebDavServlet}} that (via inheritance f= rom Jackrabbit's {{SimpleWebdavServlet}}) calls {{this.getServletContext().= setAttribute()}}. Attached is [^SLING-8051-stack-trace.txt] . > =C2=A0 > cc [~cziegeler], [~joerghoh] -- This message was sent by Atlassian JIRA (v7.6.3#76005)