Skip to content

Commit 40f7457

Browse files
author
shodan
committed
proper string send over network
git-svn-id: svn://svn.sphinxsearch.com/sphinx/trunk@1462 406a0c4d-033a-0410-8de8-e80135713968
1 parent f6901f6 commit 40f7457

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

‎api/java/SphinxClient.java‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,14 @@ private static void writeNetUTF8 ( DataOutputStream ostream, String str ) throws
214214
if ( str==null )
215215
{
216216
ostream.writeInt ( 0 );
217-
} else
218-
{
219-
ostream.writeShort ( 0 );
220-
int THRESH = 65536 / 3;
221-
int iLen = str.length();
222-
if ( iLen<=THRESH )
223-
{
224-
ostream.writeUTF ( str );
225-
} else
226-
{
227-
for ( int i=0; i<(iLen+THRESH-1)/THRESH; i++ )
228-
ostream.writeUTF ( str.substring ( i*THRESH, Math.min ( i*THRESH+THRESH-1, iLen-1 ) ) );
229-
}
217+
return;
230218
}
219+
220+
byte[] sBytes = str.getBytes ( "UTF-8" );
221+
int iLen = sBytes.length;
222+
223+
ostream.writeInt ( iLen );
224+
ostream.write ( sBytes );
231225
}
232226

233227
/** Internal method. String IO helper. */

0 commit comments

Comments
 (0)