Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-17433

Null pointer exception in Freemarker IDE when empty macro name typed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 4.2.0.Beta3
    • None
    • freemarker
    • None
    • Hide

      1. Install Freemarker IDE from Eclipse Marketplace / JBoss Tools (version 1.3.100.Final-v20130717-0627-B14)
      2. Create new test.ftl file in any project
      3. Type the following text:
      <#macro a>
      <#macro>

      4. You will see the "Exception occured" window with exception.

      Show
      1. Install Freemarker IDE from Eclipse Marketplace / JBoss Tools (version 1.3.100.Final-v20130717-0627-B14) 2. Create new test.ftl file in any project 3. Type the following text: <#macro a> <#macro> 4. You will see the "Exception occured" window with exception.

      NullPointerException occurs

      java.lang.NullPointerException
      	at org.jboss.ide.eclipse.freemarker.model.MacroDirective.compareTo(MacroDirective.java:128)
      	at java.util.ComparableTimSort.countRunAndMakeAscending(Unknown Source)
      	at java.util.ComparableTimSort.sort(Unknown Source)
      	at java.util.ComparableTimSort.sort(Unknown Source)
      	at java.util.Arrays.sort(Unknown Source)
      	at java.util.Collections.sort(Unknown Source)
      	at org.jboss.ide.eclipse.freemarker.model.ItemSet.parse(ItemSet.java:169)
      	at org.jboss.ide.eclipse.freemarker.model.ItemSet.<init>(ItemSet.java:64)
      	at org.jboss.ide.eclipse.freemarker.editor.Editor.getItemSet(Editor.java:277)
      	at org.jboss.ide.eclipse.freemarker.editor.Editor.getSelectedItem(Editor.java:249)
      	at org.jboss.ide.eclipse.freemarker.editor.Editor.keyReleased(Editor.java:374)
      	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:174)
      	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
      	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
      	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1108)
      	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
      	at org.eclipse.swt.widgets.Widget.wmKeyUp(Widget.java:1927)
      	at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:4979)
      	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4644)
      	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
      	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
      	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
      	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
      	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
      	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
      	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
      	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
      	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
      	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
      	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
      	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
      	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
      	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
      	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
      

      when editing FTL file in Freemarker IDE due to problem in compareTo function in org.jboss.ide.eclipse.freemarker.model.MacroDirective. Proposed fix:

              public int compareTo(Object arg0) {
      -               if (arg0 instanceof MacroDirective)
      -                       return (getName().compareTo(((MacroDirective) arg0).getName()));
      +               if (arg0 instanceof MacroDirective) {
      +                       String name = getName();
      +                       String otherName = ((MacroDirective) arg0).getName();
      +                       if(null == name)
      +                               name = "";
      +                       if(null == otherName)
      +                               otherName = "";
      +                       return (name.compareTo(otherName));
      +        }
                      else
                              return 0;
              }
      

            jpeterka_jira Jiri Peterka (Inactive)
            amaembo Tagir Valeev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: