dita-ot / dita-ot

DITA Open Toolkit — the open-source publishing engine for content authored in the Darwin Information Typing Architecture.
https://www.dita-ot.org
Apache License 2.0
403 stars 196 forks source link

NullPointerException in CleanPreprocessModule #2869

Open raducoravu opened 6 years ago

raducoravu commented 6 years ago

Attaching the sample DITA project I'm publishing to PDF using DITA OT 3.0.1:

npeCleanPreprocessModule.zip

The publishing breaks with:

        BUILD FAILED
        C:\Users\radu_coravu\Desktop\DITA OT newest\dita-ot-3.0.1\build.xml:45: The following error occurred while executing this line:
        C:\Users\radu_coravu\Desktop\DITA OT newest\dita-ot-3.0.1\plugins\org.dita.base\build_preprocess.xml:414: java.lang.NullPointerException
            at org.dita.dost.module.CleanPreprocessModule.getBaseDir(CleanPreprocessModule.java:134)
            at org.dita.dost.module.CleanPreprocessModule.execute(CleanPreprocessModule.java:59)
            at org.dita.dost.ant.ExtensibleAntInvoker.execute(ExtensibleAntInvoker.java:163)
            at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
            at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
            at org.apache.tools.ant.Task.perform(Task.java:348)
            at org.apache.tools.ant.Target.execute(Target.java:435)
            at org.apache.tools.ant.Target.performTasks(Target.java:456)

This used to work with DITA OT 2.x.

robander commented 6 years ago

Guessing this is the same NPE I noticed in #1550 -- getting it now with pdf2 with the original version of these: https://github.com/dita-ot/dita-ot/tree/hotfix/3.0.2/src/test/resources/ChunkModuleTest/src/with_non_dita

jelovirt commented 6 years ago

The issue is with

<map id="chapter.installation" title="Introduction">
  <topicref href="topics/introduction.dita" chunk="select-branch to-content"
    collection-type="unordered">
    <topicmeta>
      <data name="wh-menu">
        <data name="hide" value="yes"/>                
      </data>
    </topicmeta>
    <topicref href="topics/start.dita"/>
  </topicref>
  <topichead navtitle="TopicHead">
    <topicref href="topics/start.dita"/>
  </topichead>
</map>

and the select-branch chunk action. In this case it will never actually select anything, because the topicref points to a topic root.

A workaround is to remove the select-branch action.

Fixing the actual NPE can be done later.

jelovirt commented 6 years ago

One possible optimization is actually to remove chunk combinations that will never change the output. For example: