|
From: Dave B. <bla...@us...> - 2012-11-05 23:04:20
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http
In directory vz-cvs-3.sog:/tmp/cvs-serv9454/src/org/sblim/cimclient/internal/http
Modified Files:
Tag: Experimental
HttpMethod.java HttpClient.java
Log Message:
3557283 Print full response when get EOF from CIMOM
Index: HttpMethod.java
===================================================================
RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/HttpMethod.java,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -u -d -r1.3.2.4 -r1.3.2.5
--- HttpMethod.java 10 Apr 2009 16:01:10 -0000 1.3.2.4
+++ HttpMethod.java 5 Nov 2012 23:04:18 -0000 1.3.2.5
@@ -1,5 +1,5 @@
/**
- * (C) Copyright IBM Corp. 2005, 2009
+ * (C) Copyright IBM Corp. 2005, 2012
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
@@ -22,12 +22,16 @@
* 2204488 2008-10-28 raman_arora Fix code to remove compiler warnings
* 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
* 2750520 2009-04-10 blaschke-oss Code cleanup from empty statement et al
+ * 3557283 2012-11-05 blaschke-oss Print full response when get EOF from CIMOM
*/
package org.sblim.cimclient.internal.http;
import java.io.IOException;
import java.io.InputStream;
+import java.util.logging.Level;
+
+import org.sblim.cimclient.internal.logging.LogAndTraceBroker;
/**
* Class HttpMethod provides a method to read a line from a given input stream
@@ -75,7 +79,14 @@
buffer = tmp;
}
}
- if (flag) throw new IOException("Unexpected EOF");
+ if (flag) {
+ LogAndTraceBroker
+ .getBroker()
+ .trace(
+ Level.WARNING,
+ "Unexpected EOF trying to read line from input stream - CIMOM closed its end of socket, check it for connection issues");
+ throw new IOException("Unexpected EOF");
+ }
for (; used > 0 && buffer[used - 1] <= ' '; used--) {
// back up over blanks and non-printables at end of line
Index: HttpClient.java
===================================================================
RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/HttpClient.java,v
retrieving revision 1.12.2.31
retrieving revision 1.12.2.32
diff -u -d -r1.12.2.31 -r1.12.2.32
--- HttpClient.java 6 Jun 2012 14:43:13 -0000 1.12.2.31
+++ HttpClient.java 5 Nov 2012 23:04:18 -0000 1.12.2.32
@@ -65,6 +65,7 @@
* 3504304 2012-03-14 blaschke-oss Rename socket timeout variables
* 3523918 2012-05-06 blaschke-oss "java.io.IOException: Unexpected EOF" returned as HTTP 401
* 3524050 2012-06-06 blaschke-oss Improve WWW-Authenticate in HTTPClient.java
+ * 3557283 2012-11-05 blaschke-oss Print full response when get EOF from CIMOM
*/
package org.sblim.cimclient.internal.http;
@@ -361,6 +362,8 @@
private URI iUrl;
+ private long iPreviousResponseTime = -1;
+
/**
* Ctor.
*
@@ -533,6 +536,7 @@
LogAndTraceBroker logger = LogAndTraceBroker.getBroker();
logger.entry();
try {
+ long ResponseTime = -1;
Exception delayedException = null;
if (this.iReset && this.iResponse == null) {
boolean authFailed = false;
@@ -541,6 +545,8 @@
do {
logger.trace(Level.FINER, "Attempting http request (retry counters:" + IoRetry
+ "/" + AuthentificationRetry + ")");
+ long RequestTime = System.currentTimeMillis();
+ ResponseTime = -1;
resetSocket();
this.iReset = false;
try {
@@ -666,6 +672,7 @@
this.iResponse = new HttpClientMethod(this.iIStream);
logger.trace(Level.FINER, "HTTP Response= " + this.iResponse);
+ ResponseTime = System.currentTimeMillis();
this.iResponseHeaders = new HttpHeader(this.iIStream);
this.iKeepAlive = false;
@@ -725,6 +732,7 @@
if (this.iServerOutput != null) this.iServerOutput = null;
+ this.iPreviousResponseTime = ResponseTime;
return HttpURLConnection.HTTP_OK;
case HttpURLConnection.HTTP_UNAUTHORIZED:
@@ -788,6 +796,7 @@
int status = this.iResponse.getStatus();
if (!this.iKeepAlive) closeConnection();
else this.iServerInput.close();
+ this.iPreviousResponseTime = ResponseTime;
return status;
}
} catch (SocketTimeoutException e) {
@@ -795,7 +804,20 @@
} catch (IOException e) {
logger.message(Messages.HTTP_CONNECTION_FAILED, new Object[] { this.iUrl,
e.getMessage() });
- logger.trace(Level.FINER, "Http connection failed", e);
+ StringBuilder msg = new StringBuilder("Http connection failed ");
+ if (ResponseTime != -1) {
+ msg.append("after");
+ msg.append(ResponseTime - RequestTime);
+ msg.append(" milliseconds");
+ } else {
+ msg.append("before response received");
+ }
+ if (this.iPreviousResponseTime != -1) {
+ msg.append(", ");
+ msg.append(System.currentTimeMillis() - this.iPreviousResponseTime);
+ msg.append(" milliseconds after previous response on same socket");
+ }
+ logger.trace(Level.WARNING, msg.toString(), e);
delayedException = e;
if (this.iSocket != null && !this.iSocket.isClosed()) {
try {
@@ -816,6 +838,7 @@
if (this.iResponse != null) {
logger.trace(Level.FINER, "http response code=" + this.iResponse.getStatus());
+ if (ResponseTime != -1) this.iPreviousResponseTime = ResponseTime;
return this.iResponse.getStatus();
}
throw (IOException) (delayedException != null ? delayedException : new Exception(
@@ -1055,6 +1078,7 @@
throw new IOException("Socket factory did not create socket");
}
+ this.iPreviousResponseTime = -1;
this.iSocket.setTcpNoDelay(true);
this.iSocket.setKeepAlive(true);
this.iSocket.setSoTimeout(httpTimeout);
|