Re: got an exception



On Fri, 2005-05-06 at 15:33 +0200, Alexander Larsson wrote:
> On Fri, 2005-05-06 at 13:29 +0200, Alexander Larsson wrote:
> > When working on something else i noticed i got this in the server:
> > 
> > Exception in thread "Yarrr client Reaper" java.lang.NullPointerException
> >         at org.gnome.yarrr.HibernateUtil.addChangedObject(HibernateUtil.java:163)
> >         at org.gnome.yarrr.Monitor.queueSignalChanged(Monitor.java:56)
> >         at org.gnome.yarrr.ReferencableObject.signalChanged(ReferencableObject.java:70)
> >         at org.gnome.yarrr.ToplevelReferencableObject.clientInactive(ToplevelReferencableObject.java:124)
> >         at org.gnome.yarrr.ClientPoll.detectedInactive(ClientPoll.java:140)
> >         at org.gnome.yarrr.Yarrr$ClientReaper.reap(Yarrr.java:323)
> >         at org.gnome.yarrr.Yarrr$ClientReaper.run(Yarrr.java:334)
> > 
> > Maybe we broke reaping of inactive clients? 
> > 
> > I'll look at it in a while unless someone else gets to it first.
> 
> Ah, this is due to the change to queue signal notifications in a
> thread-local variable and emit them at transaction commit time. However,
> the reaper thread has no such thread-local variable.

How about this patch?


Index: .externalToolBuilders/Deploy To Local Tomcat Server.launch
===================================================================
RCS file: /cvs/gnome/yarrr/.externalToolBuilders/Deploy To Local Tomcat Server.launch,v
retrieving revision 1.7
diff -u -r1.7 Deploy To Local Tomcat Server.launch
--- .externalToolBuilders/Deploy To Local Tomcat Server.launch	14 Apr 2005 17:21:03 -0000	1.7
+++ .externalToolBuilders/Deploy To Local Tomcat Server.launch	6 May 2005 19:03:54 -0000
@@ -12,15 +12,15 @@
 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_TARGETS" value="package-servlet,undeploy,deploy,"/>
 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTY_FILES" value="${workspace_loc:/yarrr/web/tomcat-deploy.properties},"/>
 <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="yarrr"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">
+<mapEntry key="eclipse.running" value="true"/>
+</mapAttribute>
 <listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
 <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
 <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.antHome&quot;&gt;&#10;&lt;memento default=&quot;true&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
 <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/yarrr/lib/catalina-ant.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
 <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.ant.ui.classpathentry.extraClasspathEntries&quot;&gt;&#10;&lt;memento/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
 </listAttribute>
-<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">
-<mapEntry key="eclipse.running" value="true"/>
-</mapAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="yarrr"/>
 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc}/${project_path}/build.xml"/>
 </launchConfiguration>
Index: src/org/gnome/yarrr/HibernateUtil.java
===================================================================
RCS file: /cvs/gnome/yarrr/src/org/gnome/yarrr/HibernateUtil.java,v
retrieving revision 1.8
diff -u -r1.8 HibernateUtil.java
--- src/org/gnome/yarrr/HibernateUtil.java	6 May 2005 18:36:27 -0000	1.8
+++ src/org/gnome/yarrr/HibernateUtil.java	6 May 2005 19:03:54 -0000
@@ -110,6 +110,10 @@
     public static Transaction getTransaction() {
         return (Transaction) threadTransaction.get();
     }
+    
+    public static boolean isTransactionActive() {
+        return getTransaction() != null;
+    }
 	
 	/**
 	 * Commits the current transaction and begins a new transaction
Index: src/org/gnome/yarrr/Monitor.java
===================================================================
RCS file: /cvs/gnome/yarrr/src/org/gnome/yarrr/Monitor.java,v
retrieving revision 1.5
diff -u -r1.5 Monitor.java
--- src/org/gnome/yarrr/Monitor.java	4 May 2005 17:28:23 -0000	1.5
+++ src/org/gnome/yarrr/Monitor.java	6 May 2005 19:03:54 -0000
@@ -53,7 +53,11 @@
      * causes the clientside callbacks to be invoked)
      */
      public void queueSignalChanged() {
-         HibernateUtil.addChangedObject(this);
+         if (HibernateUtil.isTransactionActive()) {
+             HibernateUtil.addChangedObject(this);
+         } else {
+             commit();
+         }
      }
      
     /**
Index: src/org/gnome/yarrr/log4j.properties
===================================================================
RCS file: /cvs/gnome/yarrr/src/org/gnome/yarrr/log4j.properties,v
retrieving revision 1.6
diff -u -r1.6 log4j.properties
--- src/org/gnome/yarrr/log4j.properties	26 Apr 2005 05:50:49 -0000	1.6
+++ src/org/gnome/yarrr/log4j.properties	6 May 2005 19:03:54 -0000
@@ -17,7 +17,7 @@
 log4j.logger.org.gnome.yarrr=info, stdout
 
 log4j.logger.net.sf.ehcache=warn, stdout
-log4j.logger.org.hibernate=info, stdout
+log4j.logger.org.hibernate=debug, stdout
 #log4j.logger.org.hibernate.transaction.JDBCTransaction=debug, stdout
 log4j.logger.org.hibernate.SQL=info, stdout
 log4j.logger.org.hibernate.tool.hbm2ddl=debug, stdout


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]