Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#366 NPE when normalises the zip file with custom FileNamer

6.1.0
closed-fixed
Normaliser (38)
5
2013-08-01
2012-04-05
Wisanu Promthong
No

When we specify the ActiveFileNamer, it will cause NPE when trying to normalise the zip file.

//-----Code snippet------
xena = new Xena();
//load the plugins
xena.loadPlugins(new File(config.getPlugin_path()));
//specify the custom FileNamer
xena.setActiveFileNamer(new DAFileNamer());

// initialize inputFile and destinationDir here

//must use zip file as an input to produce the error
NormaliserResults res = xena.normalise(new XenaInputSource(inputFile), new File(destinationDir), true);

//------End Code snippet ----
Result:
java.lang.NullPointerException
at au.gov.naa.digipres.xena.kernel.filenamer.AbstractFileNamer.makeNewOpenFile(AbstractFileNamer.java:110)
at au.gov.naa.digipres.xena.plugin.archive.ArchiveNormaliser.parse(ArchiveNormaliser.java:113)
at au.gov.naa.digipres.xena.kernel.normalise.NormaliserManager.parse(NormaliserManager.java:877)
at au.gov.naa.digipres.xena.kernel.normalise.NormaliserManager.normalise(NormaliserManager.java:1255)
at au.gov.naa.digipres.xena.core.Xena.normalise(Xena.java:742)
at au.gov.naa.digipres.xena.core.Xena.normalise(Xena.java:610)

Per my rough investigation, the root cause is the foreign FileNamer that XENA accept through setActiveFileNamer isn't get the FileNamerManger assigned (in FileNamerManager class) and subsequently case NPE when try to process the zip file.

Discussion

  • Terry O'Neill
    Terry O'Neill
    2012-07-30

    Thank you Wisanu.

    Attempting to reproduce.

     
  • Terry O'Neill
    Terry O'Neill
    2012-07-30

    • assigned_to: nobody --> terryoneill
     
  • Terry O'Neill
    Terry O'Neill
    2012-08-01

    • assigned_to: terryoneill --> kirtic
    • status: open --> open-fixed
     
  • Terry O'Neill
    Terry O'Neill
    2012-08-01

    Reproduced and Fixed in Testing branch. Seems that there were issues with more files than just zip files. Fixed to correctly use the assigned active file namer. Also added the method "public File makeNewOpenFile(XenaInputSource input, File destinationDir) throws XenaException" to allow for renaming files when the file would otherwise just be copied (as occurs when performing a Convert on a file that Xena does not know a way to convert or already considers a good archival format).

    Assigned to Kirti for testing. Kirti you may need my help to test this. Have added the class au.gov.naa.digipres.xena.core.test.CustomFileNamerTest.java for testing this issue but this is mostly hardcoded at the moment.

     
  • Thank you Terry

     
  • Terry O'Neill
    Terry O'Neill
    2013-08-01

    • status: open-fixed --> closed-fixed
    • Group: --> 6.1.0