40
40
public class TestSeekBug {
41
41
static final long seed = 0xDEADBEEFL ;
42
42
static final int ONEMB = 1 << 20 ;
43
-
43
+
44
44
private void checkAndEraseData (byte [] actual , int from , byte [] expected , String message ) {
45
45
for (int idx = 0 ; idx < actual .length ; idx ++) {
46
46
assertEquals (actual [idx ], expected [from + idx ], message + " byte " + (from + idx )
47
47
+ " differs. expected " + expected [from + idx ] + " actual " + actual [idx ]);
48
48
actual [idx ] = 0 ;
49
49
}
50
50
}
51
-
51
+
52
52
private void seekReadFile (FileSystem fileSys , Path name ) throws IOException {
53
53
FSDataInputStream stm = fileSys .open (name , 4096 );
54
54
byte [] expected = new byte [ONEMB ];
55
55
Random rand = new Random (seed );
56
56
rand .nextBytes (expected );
57
-
57
+
58
58
// First read 128 bytes to set count in BufferedInputStream
59
59
byte [] actual = new byte [128 ];
60
60
stm .read (actual , 0 , actual .length );
@@ -83,7 +83,7 @@ private void smallReadSeek(FileSystem fileSys, Path name) throws IOException {
83
83
byte [] expected = new byte [ONEMB ];
84
84
Random rand = new Random (seed );
85
85
rand .nextBytes (expected );
86
-
86
+
87
87
// Issue a simple read first.
88
88
byte [] actual = new byte [128 ];
89
89
stmRaw .seek (100000 );
@@ -105,13 +105,13 @@ private void smallReadSeek(FileSystem fileSys, Path name) throws IOException {
105
105
// all done
106
106
stmRaw .close ();
107
107
}
108
-
108
+
109
109
private void cleanupFile (FileSystem fileSys , Path name ) throws IOException {
110
110
assertTrue (fileSys .exists (name ));
111
111
fileSys .delete (name , true );
112
112
assertTrue (!fileSys .exists (name ));
113
113
}
114
-
114
+
115
115
/**
116
116
* Test if the seek bug exists in FSDataInputStream in DFS.
117
117
*/
@@ -139,7 +139,7 @@ public void testSeekBugDFS() throws IOException {
139
139
* <code>FSDataInpuStream#seek</code> argument
140
140
*/
141
141
@ Test
142
- public void testNegativeSeek () throws IOException {
142
+ public void testNegativeSeek () throws IOException {
143
143
Assertions .assertThrows (IOException .class , () -> {
144
144
Configuration conf = new HdfsConfiguration ();
145
145
MiniDFSCluster cluster = new MiniDFSCluster .Builder (conf ).build ();
@@ -165,14 +165,14 @@ public void testNegativeSeek() throws IOException {
165
165
cluster .shutdown ();
166
166
}
167
167
});
168
- }
168
+ }
169
169
170
170
/**
171
171
* Test (expected to throw IOE) for <code>FSDataInpuStream#seek</code>
172
172
* when the position argument is larger than the file size.
173
173
*/
174
174
@ Test
175
- public void testSeekPastFileSize () throws IOException {
175
+ public void testSeekPastFileSize () throws IOException {
176
176
Assertions .assertThrows (IOException .class , () -> {
177
177
Configuration conf = new HdfsConfiguration ();
178
178
MiniDFSCluster cluster = new MiniDFSCluster .Builder (conf ).build ();
@@ -198,8 +198,8 @@ public void testSeekPastFileSize() throws IOException {
198
198
cluster .shutdown ();
199
199
}
200
200
});
201
- }
202
-
201
+ }
202
+
203
203
/**
204
204
* Tests if the seek bug exists in FSDataInputStream in LocalFS.
205
205
*/
0 commit comments