@@ -58,7 +58,6 @@ public class JsonStreamerEntity implements HttpEntity {
58
58
private static final byte [] STREAM_NAME = escape ("name" );
59
59
private static final byte [] STREAM_TYPE = escape ("type" );
60
60
private static final byte [] STREAM_CONTENTS = escape ("contents" );
61
- private static final byte [] STREAM_ELAPSED = escape ("_elapsed" );
62
61
63
62
private static final Header HEADER_JSON_CONTENT =
64
63
new BasicHeader (
@@ -76,14 +75,16 @@ public class JsonStreamerEntity implements HttpEntity {
76
75
// Whether to use gzip compression while uploading
77
76
private final Header contentEncoding ;
78
77
79
- private final String elapsedField ;
78
+ private final byte [] elapsedField ;
80
79
81
80
private final ResponseHandlerInterface progressHandler ;
82
81
83
82
public JsonStreamerEntity (ResponseHandlerInterface progressHandler , boolean useGZipCompression , String elapsedField ) {
84
83
this .progressHandler = progressHandler ;
85
84
this .contentEncoding = useGZipCompression ? HEADER_GZIP_ENCODING : null ;
86
- this .elapsedField = elapsedField ;
85
+ this .elapsedField = TextUtils .isEmpty (elapsedField )
86
+ ? null
87
+ : escape (elapsedField );
87
88
}
88
89
89
90
/**
@@ -146,7 +147,7 @@ public void writeTo(final OutputStream out) throws IOException {
146
147
147
148
// Use GZIP compression when sending streams, otherwise just use
148
149
// a buffered output stream to speed things up a bit.
149
- OutputStream os = null != contentEncoding
150
+ OutputStream os = contentEncoding != null
150
151
? new GZIPOutputStream (out , BUFFER_SIZE )
151
152
: out ;
152
153
@@ -216,7 +217,7 @@ public void writeTo(final OutputStream out) throws IOException {
216
217
}
217
218
} finally {
218
219
// Separate each K:V with a comma, except the last one.
219
- if (! TextUtils . isEmpty ( elapsedField ) || keysProcessed < keysCount ) {
220
+ if (elapsedField != null || keysProcessed < keysCount ) {
220
221
os .write (',' );
221
222
}
222
223
}
@@ -228,8 +229,8 @@ public void writeTo(final OutputStream out) throws IOException {
228
229
// Include the elapsed time taken to upload everything.
229
230
// This might be useful for somebody, but it serves us well since
230
231
// there will almost always be a ',' as the last sent character.
231
- if (! TextUtils . isEmpty ( elapsedField ) ) {
232
- os .write (STREAM_ELAPSED );
232
+ if (elapsedField != null ) {
233
+ os .write (elapsedField );
233
234
os .write (':' );
234
235
os .write ((elapsedTime + "" ).getBytes ());
235
236
}
0 commit comments