File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
hadoop-common-project/hadoop-common/src
main/java/org/apache/hadoop/io
test/java/org/apache/hadoop/io Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ public int find(String what, int start) {
200200 while (tgt .hasRemaining ()) {
201201 if (!src .hasRemaining ()) { // src expired first
202202 // the remaining bytes in src will always smaller than tgt,
203- // so we can return -1 directory
203+ // so we can return -1 directly
204204 return -1 ;
205205 }
206206 if (!(tgt .get () == src .get ())) {
Original file line number Diff line number Diff line change 2222import java .nio .BufferUnderflowException ;
2323import java .nio .ByteBuffer ;
2424import java .nio .charset .CharacterCodingException ;
25+ import java .util .Arrays ;
2526import java .util .Random ;
2627import org .apache .hadoop .thirdparty .com .google .common .base .Charsets ;
2728import org .apache .hadoop .thirdparty .com .google .common .primitives .Bytes ;
@@ -241,6 +242,17 @@ public void testFind() throws Exception {
241242 assertThat (text .find ("cd\u20ac q" )).isEqualTo (-1 );
242243 }
243244
245+ @ Test (timeout = 10000 )
246+ public void testFindWithTimeout () throws Exception {
247+ byte [] bytes = new byte [1000000 ];
248+ Arrays .fill (bytes , (byte ) 97 );
249+ String what = new String (bytes );
250+ bytes [0 ] = (byte ) 98 ;
251+ Text text = new Text (bytes );
252+
253+ assertThat (text .find (what )).isEqualTo (-1 );
254+ }
255+
244256 @ Test
245257 public void testFindAfterUpdatingContents () throws Exception {
246258 Text text = new Text ("abcd" );
You can’t perform that action at this time.
0 commit comments