13
13
import org .elasticsearch .TransportVersion ;
14
14
import org .elasticsearch .TransportVersions ;
15
15
import org .elasticsearch .common .bytes .BytesReference ;
16
- import org .elasticsearch .common .compress .CompressorFactory ;
17
16
import org .elasticsearch .common .io .stream .StreamInput ;
18
17
import org .elasticsearch .common .util .concurrent .ThreadContext ;
19
18
import org .elasticsearch .core .IOUtils ;
@@ -30,7 +29,7 @@ static void logInboundMessage(TcpChannel channel, BytesReference message) {
30
29
try {
31
30
String logMessage = format (channel , message , "READ" );
32
31
logger .trace (logMessage );
33
- } catch (IOException e ) {
32
+ } catch (Exception e ) {
34
33
logger .warn ("an exception occurred formatting a READ trace message" , e );
35
34
}
36
35
}
@@ -41,7 +40,7 @@ static void logInboundMessage(TcpChannel channel, InboundMessage message) {
41
40
try {
42
41
String logMessage = format (channel , message , "READ" );
43
42
logger .trace (logMessage );
44
- } catch (IOException e ) {
43
+ } catch (Exception e ) {
45
44
logger .warn ("an exception occurred formatting a READ trace message" , e );
46
45
}
47
46
}
@@ -57,7 +56,7 @@ static void logOutboundMessage(TcpChannel channel, BytesReference message) {
57
56
BytesReference withoutHeader = message .slice (HEADER_SIZE , message .length () - HEADER_SIZE );
58
57
String logMessage = format (channel , withoutHeader , "WRITE" );
59
58
logger .trace (logMessage );
60
- } catch (IOException e ) {
59
+ } catch (Exception e ) {
61
60
logger .warn ("an exception occurred formatting a WRITE trace message" , e );
62
61
}
63
62
}
@@ -111,55 +110,32 @@ private static String format(TcpChannel channel, BytesReference message, String
111
110
return sb .toString ();
112
111
}
113
112
114
- private static String format (TcpChannel channel , InboundMessage message , String event ) throws IOException {
113
+ private static String format (TcpChannel channel , InboundMessage message , String event ) {
115
114
final StringBuilder sb = new StringBuilder ();
116
115
sb .append (channel );
117
116
118
117
if (message .isPing ()) {
119
118
sb .append (" [ping]" ).append (' ' ).append (event ).append (": " ).append (6 ).append ('B' );
120
119
} else {
121
- boolean success = false ;
122
120
Header header = message .getHeader ();
123
121
int networkMessageSize = header .getNetworkMessageSize ();
124
122
int messageLengthWithHeader = HEADER_SIZE + networkMessageSize ;
125
- StreamInput streamInput = message .openOrGetStreamInput ();
126
- try {
127
- final long requestId = header .getRequestId ();
128
- final boolean isRequest = header .isRequest ();
129
- final String type = isRequest ? "request" : "response" ;
130
- final String version = header .getVersion ().toString ();
131
- sb .append (" [length: " ).append (messageLengthWithHeader );
132
- sb .append (", request id: " ).append (requestId );
133
- sb .append (", type: " ).append (type );
134
- sb .append (", version: " ).append (version );
123
+ final long requestId = header .getRequestId ();
124
+ final boolean isRequest = header .isRequest ();
125
+ final String type = isRequest ? "request" : "response" ;
126
+ final String version = header .getVersion ().toString ();
127
+ sb .append (" [length: " ).append (messageLengthWithHeader );
128
+ sb .append (", request id: " ).append (requestId );
129
+ sb .append (", type: " ).append (type );
130
+ sb .append (", version: " ).append (version );
135
131
136
- // TODO: Maybe Fix for BWC
137
- if (header .needsToReadVariableHeader () == false && isRequest ) {
138
- sb .append (", action: " ).append (header .getActionName ());
139
- }
140
- sb .append (']' );
141
- sb .append (' ' ).append (event ).append (": " ).append (messageLengthWithHeader ).append ('B' );
142
- success = true ;
143
- } finally {
144
- if (success ) {
145
- IOUtils .close (streamInput );
146
- } else {
147
- IOUtils .closeWhileHandlingException (streamInput );
148
- }
132
+ // TODO: Maybe Fix for BWC
133
+ if (header .needsToReadVariableHeader () == false && isRequest ) {
134
+ sb .append (", action: " ).append (header .getActionName ());
149
135
}
136
+ sb .append (']' );
137
+ sb .append (' ' ).append (event ).append (": " ).append (messageLengthWithHeader ).append ('B' );
150
138
}
151
139
return sb .toString ();
152
140
}
153
-
154
- private static StreamInput decompressingStream (byte status , StreamInput streamInput ) throws IOException {
155
- if (TransportStatus .isCompress (status ) && streamInput .available () > 0 ) {
156
- try {
157
- return CompressorFactory .COMPRESSOR .threadLocalStreamInput (streamInput );
158
- } catch (IllegalArgumentException e ) {
159
- throw new IllegalStateException ("stream marked as compressed, but is missing deflate header" );
160
- }
161
- } else {
162
- return streamInput ;
163
- }
164
- }
165
141
}
0 commit comments