Not calling base.Initialize(documentInfo); results in a NRE

I realized that you *must* call base.Initialize(documentInfo); inside of the following override when inheriting from AbstractBilingualContentProcessor

public override void Initialize(IDocumentProperties documentInfo)
{
	base.Initialize(documentInfo);  // <--- This MUST be called
}

 

Here is a sample project that produces the bug:SDL Custom Batch Task Plug-in 20151.zip

And here is the bug report:

<SDLErrorDetails time="5/10/2016 12:48:54 PM">
  <ErrorMessage>Object reference not set to an instance of an object.</ErrorMessage>
  <Exception>
    <Type>System.NullReferenceException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Type>
    <HelpLink />
    <Source>Sdl.FileTypeSupport.Bilingual.SdlXliff</Source>
    <HResult>-2147467261</HResult>
    <StackTrace><![CDATA[   at Sdl.FileTypeSupport.Bilingual.SdlXliff.XliffWriter.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.Integration.AbstractBilingualProcessorContainer.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.BilingualApi.AbstractBilingualContentProcessor.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.Core.Utilities.BilingualApi.BilingualContentHandlerAdapter.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.Integration.AbstractBilingualProcessorContainer.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.Integration.MultiFileConverter.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.BilingualApi.AbstractBilingualContentProcessor.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Framework.Integration.AbstractBilingualProcessorContainer.SetFileProperties(IFileProperties fileInfo)
   at Sdl.FileTypeSupport.Bilingual.SdlXliff.XliffFileReader.OnEndFileHeader()
   at Sdl.FileTypeSupport.Bilingual.SdlXliff.SdlXliffFeeder.<ContinueScanning>b__4(ISdlXliffStreamContentHandler handler)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Sdl.FileTypeSupport.Bilingual.SdlXliff.SdlXliffFeeder.ContinueScanning()
   at Sdl.FileTypeSupport.Bilingual.SdlXliff.XliffFileReader.ContinueParsing()
   at Sdl.FileTypeSupport.Bilingual.SdlXliff.XliffFileReader.ParseNext()
   at Sdl.FileTypeSupport.Framework.Integration.FileExtractor.ParseNext()
   at Sdl.FileTypeSupport.Framework.Integration.MultiFileConverter.ParseNext()
   at Sdl.FileTypeSupport.Framework.Integration.MultiFileConverter.Parse()
   at Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.TaskFileExecuter.Parse(String targetFilePath)]]></StackTrace>
  </Exception>
  <Environment>
    <ProductName>SDL Trados Studio</ProductName>
    <ProductVersion>12.0.0.0</ProductVersion>
    <EntryAssemblyFileVersion>12.2.5099.5</EntryAssemblyFileVersion>
    <OperatingSystem>Microsoft Windows 7 Professional </OperatingSystem>
    <ServicePack>Service Pack 1</ServicePack>
    <OperatingSystemLanguage>1041</OperatingSystemLanguage>
    <CodePage>932</CodePage>
    <LoggedOnUser>ITP\jesse_good</LoggedOnUser>
    <DotNetFrameWork>4.0.30319.42000</DotNetFrameWork>
    <ComputerName>D6VHN4W1</ComputerName>
    <ConnectedToNetwork>True</ConnectedToNetwork>
    <PhysicalMemory>16661036 MB</PhysicalMemory>
  </Environment>
</SDLErrorDetails>

Is this intended behavior? I would not expect you have to call the base implementation for Abstract class.

Parents
  • Indeed AbstractBilingualContentProcessor is an abstract class but you are not implementing an abstract method rather you override a method from the base class which may or may not have an implementation (just an empty method). In this exact case the method from the base class does initialize the Output content handler. By removing the base call the Output is not initialize and this is why you get an exception. This means that if you no longer make the call to base method you need to initialize the Output, something like this:

    if(Output != null)
    {
       Output.Initialize(documentInfo);
    }

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

Reply
  • Indeed AbstractBilingualContentProcessor is an abstract class but you are not implementing an abstract method rather you override a method from the base class which may or may not have an implementation (just an empty method). In this exact case the method from the base class does initialize the Output content handler. By removing the base call the Output is not initialize and this is why you get an exception. This means that if you no longer make the call to base method you need to initialize the Output, something like this:

    if(Output != null)
    {
       Output.Initialize(documentInfo);
    }

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

Children