A Legacy Notes Developer's journey into madness.

Error 500 -HTTP Web Server: Command Not Handled Exception; or how to choke a server JVM with a single line of code

Devin Olson  October 10 2012 03:28:16 PM
When creating your own Java objects to feed repeat controls, it is useful to implement the Java Collection Interface with a values() method.

HOWEVER - you should be very careful when doing this that you don't do something incredibly stupid.  Do as I say, not as I do, I say.  

For example, let us assume you want to create a Java object that will do all kinds of way cool stuff.  You could perhaps create something like this:

package
com.azlighthouse.sandbox;
import
java.io.Serializable;

public
class MyWayCoolJavaClass implements Serializable {
   private static final long serialVersionUID = 12345L;

   /*
    * Default Constructor
    */
   public MyWayCoolJavaClass() {
   }

   /*
    * Lots of way cool code goes here
    */
} // MyWayCoolJavaClass



Let us further assume you have an XPage, and on this XPage is a repeat control, and you want to allow the repeat control to use a set of your way cool objects.  You could then perhaps create some sort of map to carry the objects and allow you to do all kinds of interesting things to them.  You might want to use this map to "feed" your repeat control by giving it a values property that returns a collection.   You could perhaps then create (as I did) something like this:

package
com.azlighthouse.sandbox;

import
java.io.Serializable;
import
java.util.Collection;
import
java.util.LinkedHashMap;

public
class DemoMap implements Serializable {
   private static final long serialVersionUID = 67890L;
   private LinkedHashMap<String, MyWayCoolJavaClass> _entries;

   /*
    * Default Constructor
    */
   public DemoMap() {
           this.initialize();
   }

   private void initialize() {
           this._entries = new LinkedHashMap<String, MyWayCoolJavaClass>();
   }

   public Collection<MyWayCoolJavaClass> values() {
           return this.values();
   }

    /*
    * Lots of other code goes here
    */
} // DemoMap




Did you spot my mistake?   I missed it at first, and spent quite a bit of time hunting it down.  Once I discovered it, the fix was incredibly simple:
return
this._entries.values();


Without the fix my code went into an ugly recursion loop and just spun there consuming resources until the JVM threw up.  I have to admit I am surprised (in a good way) about the resilience of the Domino server itself.  No restart was required.  In fact, NOTHING was required -the server simply puked out the 500 error and kept working just fine.  

"Bad developer -No Jolt for you!"
-Devin.
Comments
No Comments Found

Discussion for this entry is now closed.