Stackoverflow: Recursive call in namepatternFilter

I’m new to eclipse development and I’m working on a custom namepatternfilter for Jface tree viewer. I have the below code in my filter which recursively goes through children of a node element.

public boolean isChildMatch(final Object element) {
    boolean value = false;

    // Object[] children = this.contentProvider.getChildren(element);
    Object[] items = null;
    if (((HashMap<Object, String>) getTreeMap().get(element)) == null) {
      final Object[] children = this.contentProvider.getChildren(element);
      items = children;
      new Thread(new Runnable() {

        public void run() {
          final HashMap<Object, String> childrenMap = new HashMap<Object, String>();
          for (Object object : children) {
            childrenMap.put(object, null);
          NamePatternFilter.this.getTreeMap().put(element, childrenMap);
    else {
      items = ((HashMap<Object, String>) getTreeMap().get(element)).keySet().toArray();
    for (Object child : items) {
      if (isElementMatch(child)) {
        value = true;
      else if (isChildMatch(child)) {
        value = true;

    return value;


When i run the code, I’m getting stackoverflow exception

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.StackOverflowError)
    at org.eclipse.swt.SWT.error(
    at org.eclipse.swt.SWT.error(
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(
    at org.eclipse.swt.widgets.Display.runAsyncMessages(
    at org.eclipse.swt.widgets.Display.readAndDispatch(

What am I missing here?

Source: eclipse

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.