Ignore:
Timestamp:
2017-07-05T20:43:44+12:00 (7 years ago)
Author:
ak19
Message:

Kathy described a problem on the mailing list about the AutoLoadConverters msg appearing before XML content when connecting with a client-GLI to a remote GS3, which breaks parsing of the XML. (I found it was present in my GS3 installation from 4 May 2016.) I've narrowed it down to running client-gli with the debug flag turned on, which seemed related to the same problem I'd seen when running gli -debug after the change to SafeProcess in Plugins.java, which I fixed by removing lines preceding XML content before parsing the XML. For client-gli, SafeProcess isn't used which is also why the problem with client-gli is much older, but I'm now using a common and existing solution for both: doing what Plugins.java used to do before the change to SafeProcess, which is call XMLTools.readXMLStream(), which would parse out content before XML. The RemoteGreenstoneServer should only call this method if it actually has some XML content it's dealing with. Could have solved this in RemoteGreenstoneServerAction.java's GetScriptOptions, but am solving it in RemoteGreenstoneServer's sendCommandToServerInternal, since there may be many Actions returning XML, not just GetScriptOptions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/greenstone/Plugins.java

    r31641 r31776  
    165165        // Create the process.
    166166        SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { }));
     167        process.setSplitStdErrorNewLines(true);
    167168
    168169        // run the SafeProcess
     
    174175        // get the result: We expect XML to have come out of the process std error stream.
    175176        pluginfo_xml = process.getStdError();
     177        // make sure to have parsed out any lines preceding the XML content
     178        pluginfo_xml = XMLTools.readXMLStream(pluginfo_xml).toString();
    176179        ///System.err.println("*********\nPluginInfo, got:\n" + pluginfo_xml + "\n**********\n");
    177180        }
     
    236239        args.add("-listall");
    237240        args.add("-xml");
    238 
     241       
    239242        // Run the pluginfo.pl process:
    240243        // Create the process.
    241244        SafeProcess process = new SafeProcess((String[]) args.toArray(new String[] { }));
     245        process.setSplitStdErrorNewLines(true);
    242246
    243247        // run the SafeProcess
     
    249253        // get the result: We expect XML to have come out of the process std error stream. 
    250254        xml = process.getStdError();
    251 
     255        // make sure to parse out any lines before the XML content, else running "gli -debug" results in an XML error:
    252256        // for pluginfo.pl -listall, we see a "AutoloadConverters" (PDFBox) message
    253         // before actual XML output, which breaks XML parsing. Get rid of output before "<?xml"
    254         int startIndex = xml.indexOf("<?xml");
    255         if(startIndex != 0) {
    256             xml = xml.substring(startIndex);
    257         }
     257        // before actual XML output, which breaks XML parsing.
     258        // This gets rid of output before "<?xml" in the way that the code did before the change to SafeProcess
     259        // Then we can call the same from method RemoteGreenstoneServer.java, so that running "client-gli -debug"
     260        // will work too.
     261        xml = XMLTools.readXMLStream(xml).toString();
     262       
    258263        ///System.err.println("*********\nPluginsList, got:\n" + xml + "\n**********\n");
    259264        }
Note: See TracChangeset for help on using the changeset viewer.