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/util/XMLTools.java

    r30869 r31776  
    733733    static public StringBuffer readXMLStream(InputStream input_stream)
    734734    {
     735        StringBuffer xml = new StringBuffer("");
     736        try {
     737        InputStreamReader isr = new InputStreamReader(input_stream, "UTF-8");
     738        xml = XMLTools.readXMLStream(new InputStreamReader(input_stream, "UTF-8"));
     739        } catch (UnsupportedEncodingException error) {
     740        System.err.println("Failed when trying to parse XML stream");
     741        error.printStackTrace();
     742        }
     743       
     744        return xml;
     745    }
     746
     747    static public StringBuffer readXMLStream(String s) {
     748    return XMLTools.readXMLStream(new StringReader(s));
     749    }
     750
     751
     752    static public StringBuffer readXMLStream(Reader reader)
     753    {
    735754        StringBuffer xml = new StringBuffer("");
    736755
    737756        try
    738757        {
    739             InputStreamReader isr = new InputStreamReader(input_stream, "UTF-8");
    740             BufferedReader buffered_in = new BufferedReader(isr);
     758            BufferedReader buffered_in = new BufferedReader(reader);
    741759
    742760            String line = "";
Note: See TracChangeset for help on using the changeset viewer.