Skip to content

NullPointerException if a parsed file has no Intents and ICC_SHOW_VARS is enabled #4

@jeandersonbc

Description

@jeandersonbc

In case a parsed file has no Intents AND the flag ICC_SHOW_VARS is set to TRUE, then the application throws a runtime exception (NullPointerException) at line 110 from Main.java.

The exception occurs because if there's no intents, the first loop will be skipped. By skipping the loop on intents.entrySet(), the reference info is never initialized.

Consequentially, if the following if-statement if (ICC_SHOW_VARS) is enabled, the System.out.printf command is going to reference info.type, halting the execution.

See the following lines for reference:

Main.java

      // printing the intents
      Map<String, IntentInfo> intents = resultsEntry.getValue().intentsST.getMap();
      IntentInfo info = null;

      for(Map.Entry<String, IntentInfo> intentEntry : intents.entrySet())
      {
        info = intentEntry.getValue();

        if ((info.isExplicit() && ICC_SHOW_EXPLICIT_INTENTS) ||
            (!info.isExplicit() && ICC_SHOW_IMPLICIT_INTENTS))
        {
          System.out.println(String.format("%s:\n%s\n----------", intentEntry.getKey(), intentEntry.getValue()));
        }
      }

      // printing the vars
      if (ICC_SHOW_VARS)
      {
        Map<String, VarInfo> vars = resultsEntry.getValue().varsST.getMap();

        for(Map.Entry<String, VarInfo> varEntry : vars.entrySet())
        {
          String name = varEntry.getKey();
          VarInfo varInfo = varEntry.getValue();

          System.out.printf("%s %s = %s\n", info.type, name, varInfo.value);
        }
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions