|
From: Dave B. <bla...@us...> - 2010-11-09 22:42:30
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29496/src/org/sblim/cimclient/internal/http/io Modified Files: DebugInputStream.java Log Message: 3062747 - SblimCIMClient does not log all CIM-XML responces. Index: DebugInputStream.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io/DebugInputStream.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- DebugInputStream.java 5 Mar 2009 16:59:23 -0000 1.6 +++ DebugInputStream.java 9 Nov 2010 22:42:20 -0000 1.7 @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2005, 2009 + * (C) Copyright IBM Corp. 2005, 2010 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE @@ -19,6 +19,7 @@ * 1565892 2006-11-28 lupusalex Make SBLIM client JSR48 compliant * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1) + * 3062747 2010-09-21 blaschke-oss SblimCIMClient does not log all CIM-XML responces. */ package org.sblim.cimclient.internal.http.io; @@ -27,6 +28,8 @@ import java.io.InputStream; import java.io.OutputStream; +import org.sblim.cimclient.internal.logging.TimeStamp; + /** * Class DebugInputStream is for debugging purposes * @@ -59,22 +62,37 @@ private void buffer() throws IOException { this.iBuffered = true; int total; - while ((total = this.in.read(this.iBuf, this.iMaxLen, this.iBuf.length - this.iMaxLen)) > -1) { - this.iMaxLen += total; - if (this.iMaxLen == this.iBuf.length) { - byte b[] = new byte[this.iBuf.length << 1]; - System.arraycopy(this.iBuf, 0, b, 0, this.iBuf.length); - this.iBuf = b; + try { + while ((total = this.in.read(this.iBuf, this.iMaxLen, this.iBuf.length - this.iMaxLen)) > -1) { + this.iMaxLen += total; + if (this.iMaxLen == this.iBuf.length) { + byte b[] = new byte[this.iBuf.length << 1]; + System.arraycopy(this.iBuf, 0, b, 0, this.iBuf.length); + this.iBuf = b; + } + } + } catch (TrailerException e) { + // TrailerException indicates complete response BUT error in trailer + if (this.iStream != null) { + writeBuffer("response begin (TrailerException occurred)"); } + throw e; } if (this.iStream != null) { - this.iStream.write("<--- response begin ----\n".getBytes()); - this.iStream.write(this.iBuf, 0, this.iMaxLen); - this.iStream.write("\n".getBytes()); - this.iStream.write("---- response end ----->\n".getBytes()); + writeBuffer("response begin"); } } + private void writeBuffer(String header) throws IOException { + this.iStream.write("<--- ".getBytes()); + this.iStream.write(header.getBytes()); + this.iStream.write(" ".getBytes()); + this.iStream.write(TimeStamp.formatWithMillis(System.currentTimeMillis()).getBytes()); + this.iStream.write(" ----\n".getBytes()); + this.iStream.write(this.iBuf, 0, this.iMaxLen); + this.iStream.write("---- response end ----->\n".getBytes()); + } + @Override public synchronized int read() throws IOException { if (!this.iBuffered) buffer(); |