2828import microsoft .exchange .webservices .data .core .ExchangeService ;
2929import microsoft .exchange .webservices .data .core .enumeration .misc .HangingRequestDisconnectReason ;
3030import microsoft .exchange .webservices .data .core .enumeration .misc .TraceFlags ;
31- import microsoft .exchange .webservices .data .core .exception .misc .ArgumentException ;
3231import microsoft .exchange .webservices .data .core .exception .http .EWSHttpException ;
33- import microsoft .exchange .webservices .data .core .exception .service .local .ServiceLocalException ;
34- import microsoft .exchange .webservices .data .core .exception .service .remote .ServiceRequestException ;
32+ import microsoft .exchange .webservices .data .core .exception .misc .ArgumentException ;
3533import microsoft .exchange .webservices .data .core .exception .service .local .ServiceVersionException ;
3634import microsoft .exchange .webservices .data .core .exception .service .local .ServiceXmlDeserializationException ;
35+ import microsoft .exchange .webservices .data .core .exception .service .remote .ServiceRequestException ;
3736import microsoft .exchange .webservices .data .core .exception .xml .XmlException ;
3837import microsoft .exchange .webservices .data .misc .HangingTraceStream ;
3938import microsoft .exchange .webservices .data .security .XmlNodeType ;
@@ -62,6 +61,7 @@ public abstract class HangingServiceRequestBase<T> extends ServiceRequestBase<T>
6261
6362 private static final Log LOG = LogFactory .getLog (HangingServiceRequestBase .class );
6463
64+
6565 public interface IHandleResponseObject {
6666
6767 /**
@@ -74,13 +74,13 @@ public interface IHandleResponseObject {
7474 }
7575
7676
77- private static final int BufferSize = 4096 ;
77+ public static final int BUFFER_SIZE = 4096 ;
7878
7979 /**
8080 * Test switch to log all bytes that come across the wire.
8181 * Helpful when parsing fails before certain bytes hit the trace logs.
8282 */
83- public static boolean logAllWireBytes = false ;
83+ private static boolean logAllWireBytes = false ;
8484
8585 /**
8686 * Callback delegate to handle response objects
@@ -92,16 +92,6 @@ public interface IHandleResponseObject {
9292 */
9393 private HttpWebRequest response ;
9494
95- /**
96- * Request to the server.
97- */
98- private HttpWebRequest request ;
99-
100- /**
101- * Xml reader used to parse the response.
102- */
103- private EwsServiceMultiResponseXmlReader ewsXmlReader ;
104-
10595 /**
10696 * Expected minimum frequency in response, in milliseconds.
10797 */
@@ -122,6 +112,14 @@ void hangingRequestDisconnectHandler(Object sender,
122112 }
123113
124114
115+ public static boolean isLogAllWireBytes () {
116+ return logAllWireBytes ;
117+ }
118+
119+ public static void setLogAllWireBytes (final boolean logAllWireBytes ) {
120+ HangingServiceRequestBase .logAllWireBytes = logAllWireBytes ;
121+ }
122+
125123 /**
126124 * Disconnect events Occur when the hanging request is disconnected.
127125 */
@@ -172,7 +170,7 @@ protected HangingServiceRequestBase(ExchangeService service,
172170 /**
173171 * Exectures the request.
174172 */
175- public void internalExecute () throws ServiceLocalException , Exception {
173+ public void internalExecute () throws Exception {
176174 synchronized (this ) {
177175 this .response = this .validateAndEmitRequest ();
178176 this .internalOnConnect ();
@@ -200,30 +198,15 @@ private void parseResponses() {
200198 tracingStream .setResponseCopy (responseCopy );
201199 }
202200
203- //EwsServiceMultiResponseXmlReader ewsXmlReader = EwsServiceMultiResponseXmlReader.create(tracingStream, getService());
204-
205-
206-
207201 while (this .isConnected ()) {
208- T responseObject = null ;
202+ T responseObject ;
209203 if (traceEWSResponse ) {
210- /*try{*/
211204 EwsServiceMultiResponseXmlReader ewsXmlReader =
212205 EwsServiceMultiResponseXmlReader .create (tracingStream , getService ());
213206 responseObject = this .readResponse (ewsXmlReader );
214207 this .responseHandler .handleResponseObject (responseObject );
215- /* }catch(Exception ex){
216- this.disconnect(HangingRequestDisconnectReason.Exception, ex);
217- return;
218-
219- }
220- finally{
221- this.getService().traceXml(TraceFlags.EwsResponse,responseCopy);
222- if(responseObject!=null)
223- this.responseHandler.handleResponseObject(responseObject);
224- }*/
225- // reset the stream collector.
226208
209+ // reset the stream collector.
227210 responseCopy .close ();
228211 responseCopy = new ByteArrayOutputStream ();
229212 tracingStream .setResponseCopy (responseCopy );
@@ -238,31 +221,25 @@ private void parseResponses() {
238221 } catch (SocketTimeoutException ex ) {
239222 // The connection timed out.
240223 this .disconnect (HangingRequestDisconnectReason .Timeout , ex );
241- return ;
242224 } catch (UnknownServiceException ex ) {
243225 // Stream is closed, so disconnect.
244226 this .disconnect (HangingRequestDisconnectReason .Exception , ex );
245- return ;
246227 } catch (ObjectStreamException ex ) {
247228 // Stream is closed, so disconnect.
248229 this .disconnect (HangingRequestDisconnectReason .Exception , ex );
249- return ;
250230 } catch (IOException ex ) {
251231 // Stream is closed, so disconnect.
252232 this .disconnect (HangingRequestDisconnectReason .Exception , ex );
253- return ;
254233 } catch (UnsupportedOperationException ex ) {
255234 LOG .error (ex );
256235 // This is thrown if we close the stream during a
257236 //read operation due to a user method call.
258237 // Trying to delay closing until the read finishes
259238 //simply results in a long-running connection.
260239 this .disconnect (HangingRequestDisconnectReason .UserInitiated , null );
261- return ;
262240 } catch (Exception ex ) {
263241 // Stream is closed, so disconnect.
264242 this .disconnect (HangingRequestDisconnectReason .Exception , ex );
265- return ;
266243 } finally {
267244 if (responseCopy != null ) {
268245 try {
0 commit comments