Project

General

Profile

« Previous | Next » 

Revision 845

Added by Matt Jones over 22 years ago

Fixed problem with metacat handleReadAction where the OutputStream from the
response object was closed and an attempt to reopen a PrintWriter was made
on the same response, which is illegal. Now the OutputStream is converted
to a PrintWriter in order to write the XML error message back to the client.

Still may have a problem with determining why an exception is being thrown
in handleReadAction in the first place. Many exceptions are handled in this
try/catch block, and so we'll probably need to track it down when we can
reproduce the behavior.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatUtil.java
177 177
  
178 178
  /* Utility method to get a unused Connection object from the pool */
179 179
  public Connection getConnection()
180
                throws SQLException, ClassNotFoundException, Exception {
180
                throws SQLException, ClassNotFoundException, Exception 
181
  {
181 182

  
182 183
    Connection conn = null;
183 184
    Enumeration connections = connectionPool.keys();
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
739 739
        zout.close();  //close the zip stream
740 740
      }
741 741
      
742
        /*
743
    } catch (ClassNotFoundException cnfe) {
744
    } catch (IOException ioe1) {
745
    } catch (SQLException se) {
746
    } catch (McdbException mcdbe) {
742 747
    } catch (Exception e) {
748
      */
749
    } catch (Exception e) {
743 750
      try {
744
        if ( out != null ) { out.close(); }
751
        response.setContentType("text/xml"); //MIME type
752
        //PrintWriter pw = response.getWriter();
753
        if (out != null) {
754
            PrintWriter pw = new PrintWriter(out);
755
            pw.println("<?xml version=\"1.0\"?>");
756
            pw.println("<error>");
757
            pw.println(e.getMessage());
758
            pw.println("</error>");
759
            pw.close();
760
        }
761
        //if ( out != null ) { out.close(); }
745 762
        if ( zout != null ) { zout.close(); }
746
        response.setContentType("text/xml"); //MIME type
747
        PrintWriter pw = response.getWriter();
748
        pw.println(e.getMessage());
749 763
      } catch (IOException ioe) {
750 764
        System.out.println("Problem with the servlet output " +
751 765
                           "in MetacatServlet.handleReadAction: " +
build.xml
39 39
      <property name="release" value="1.0beta2"/>
40 40
      <property name="web-base-url" 
41 41
                value="http://knb.ecoinformatics.org"/>
42
      <property name="replication-path" value="//servlet/replication"/>
42
      <property name="replication-path" value="/servlet/replication"/>
43 43
      <property name="servlet-path" value="/jones/servlet/metacat"/>
44 44
      <property name="html-path" value="/jones"/>
45 45
      <property name="image-path" value="/img/jones" />

Also available in: Unified diff