<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic A.E: race conditions because no synchronization possible? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/a-e-race-conditions-because-no-synchronization-possible/m-p/136880#M96001</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everybody, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i look at &lt;/SPAN&gt;&lt;A href="https://github.com/Activiti/Activiti/blob/master/modules/activiti-explorer/src/main/java/org/activiti/explorer/ExplorerApp.java" rel="nofollow noopener noreferrer"&gt;org.activiti.explorer.ExplorerApp&lt;/A&gt;&lt;SPAN&gt; class&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;public class ExplorerApp extends Application implements HttpServletRequestListener {&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; private static final long serialVersionUID = -1L;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; // Thread local storage of instance for each user&lt;BR /&gt;&amp;nbsp; protected static ThreadLocal&amp;lt;ExplorerApp&amp;gt; current = new ThreadLocal&amp;lt;ExplorerApp&amp;gt;();&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; protected String environment;&lt;BR /&gt;&amp;nbsp; protected UserCache userCache;&lt;BR /&gt;&amp;nbsp; protected MainWindow mainWindow;&lt;BR /&gt;&amp;nbsp; protected ViewManager viewManager;&lt;BR /&gt;&amp;nbsp; protected NotificationManager notificationManager;&lt;BR /&gt;&amp;nbsp; protected I18nManager i18nManager;&lt;BR /&gt;&amp;nbsp; protected AttachmentRendererManager attachmentRendererManager;&lt;BR /&gt;&amp;nbsp; protected FormPropertyRendererManager formPropertyRendererManager;&lt;BR /&gt;&amp;nbsp; protected VariableRendererManager variableRendererManager;&lt;BR /&gt;&amp;nbsp; protected LoginHandler loginHandler;&lt;BR /&gt;&amp;nbsp; protected WorkflowDefinitionConversionFactory workflowDefinitionConversionFactory;&lt;BR /&gt;&amp;nbsp; protected ComponentFactories componentFactories;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and think about whether race conditions&amp;nbsp; (RCs) are possible, beacause no synchronization for protected varibales exist. Only ThreadLocal is used to get a access (for each registered thread) on components of ExplorerApp.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Theoretically RCs should not exist after call of the "activiti-explorer" uri in browser, beacuse:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;At first time the org.activiti.explorer.servlet.ExplorerApplicationServlet will be created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That Servlet will be injected into first thread, that process the servlet. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The method "service() will be called. Within of that method the application will be created using spring's &lt;/SPAN&gt;&lt;A href="http://static.springsource.org/spring/docs/1.2.9/reference/webintegration.html" rel="nofollow noopener noreferrer"&gt;WebApplicationContextUtils&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp; @Override&lt;BR /&gt;&amp;nbsp; public void init(ServletConfig servletConfig) throws ServletException {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; super.init(servletConfig);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletConfig.getServletContext());&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; @Override&lt;BR /&gt;&amp;nbsp; protected Class&amp;lt; ? extends Application&amp;gt; getApplicationClass() throws ClassNotFoundException {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ExplorerApp.class;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; @Override&lt;BR /&gt;&amp;nbsp; protected Application getNewApplication(HttpServletRequest request) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (Application) applicationContext.getBean(ExplorerApp.class);&lt;BR /&gt;&amp;nbsp; }&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;The WebApplicationContextUtils should be used same thread context, that was created during GET-Request.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If the second GET-Request occurs, so the thread from &lt;/SPAN&gt;&lt;A href="http://www.codestyle.org/java/servlets/faq-Threads.shtml" rel="nofollow noopener noreferrer"&gt;thread poll will be used&lt;/A&gt;&lt;SPAN&gt;. (That may be new thread).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, the application will be loaded i&lt;/SPAN&gt;&lt;STRONG&gt;n another thread &lt;/STRONG&gt;&lt;SPAN&gt;context.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So quasi &lt;/SPAN&gt;&lt;STRONG&gt;single thread model for each user &lt;/STRONG&gt;&lt;SPAN&gt;exists…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But this is only theory…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your replays!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Feb 2013 12:51:07 GMT</pubDate>
    <dc:creator>udoderk</dc:creator>
    <dc:date>2013-02-17T12:51:07Z</dc:date>
    <item>
      <title>A.E: race conditions because no synchronization possible?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/a-e-race-conditions-because-no-synchronization-possible/m-p/136880#M96001</link>
      <description>Hi everybody, i look at org.activiti.explorer.ExplorerApp classpublic class ExplorerApp extends Application implements HttpServletRequestListener {&amp;nbsp; &amp;nbsp; private static final long serialVersionUID = -1L;&amp;nbsp; // Thread local storage of instance for each user&amp;nbsp; protected static ThreadLocal&amp;lt;ExplorerApp&amp;gt;</description>
      <pubDate>Sun, 17 Feb 2013 12:51:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/a-e-race-conditions-because-no-synchronization-possible/m-p/136880#M96001</guid>
      <dc:creator>udoderk</dc:creator>
      <dc:date>2013-02-17T12:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: A.E: race conditions because no synchronization possible?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/a-e-race-conditions-because-no-synchronization-possible/m-p/136881#M96002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That makes sense… if we add "load-on-statup" parameter in web.xml, the web-application-context will be initialize when he container starts so the servlet init will be called once before the servlet actually starts serving.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive 128 integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-start-up value.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I imagine the most containers to have a mechanism that prevents the init() to be called twice for the same servlet (when multiple incoming HTTP-calls are done to it when not yet initialized). This is a servlet-specific issue and is independent of the way we handle the thread-local storage of the ExplorerApplication.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 08:51:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/a-e-race-conditions-because-no-synchronization-possible/m-p/136881#M96002</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2013-02-18T08:51:00Z</dc:date>
    </item>
  </channel>
</rss>

