### Question:
TextInputFormat extends DelimitedInputFormat { @Override public void configure(Configuration parameters) { super.configure(parameters); String charsetName = parameters.getString(CHARSET_NAME, DEFAULT_CHARSET_NAME); if (charsetName == null || !Charset.isSupported(charsetName)) { throw new RuntimeException("Unsupported charset: " + charsetName); } if (charsetName.equals("ISO-8859-1") || charsetName.equalsIgnoreCase("ASCII")) { this.ascii = true; } else { this.decoder = Charset.forName(charsetName).newDecoder(); this.byteWrapper = ByteBuffer.allocate(1); } this.pos = parameters.getInteger(FIELD_POS, 0); if (this.pos < 0) { throw new RuntimeException("Illegal configuration value for the target position: " + this.pos); } }  @Override void configure(Configuration parameters); Record readRecord(Record reuse, byte[] bytes, int offset, int numBytes); static final String CHARSET_NAME; static final String FIELD_POS; static final String DEFAULT_CHARSET_NAME; }### Answer:
@Test public void testPositionBug() { final String FIRST = "First line"; final String SECOND = "Second line"; try { File tempFile = File.createTempFile("TextInputFormatTest", "tmp"); tempFile.deleteOnExit(); tempFile.setWritable(true); FileWriter writer = new FileWriter(tempFile); writer.append(FIRST).append('\n'); writer.append(SECOND).append('\n'); writer.close(); TextInputFormat inputFormat = new TextInputFormat(); inputFormat.setFilePath(tempFile.toURI().toString()); Configuration parameters = new Configuration(); inputFormat.configure(parameters); FileInputSplit[] splits = inputFormat.createInputSplits(1); assertTrue("expected at least one input split", splits.length >= 1); inputFormat.open(splits[0]); Record r = new Record(); assertNotNull("Expecting first record here", inputFormat.nextRecord(r)); assertEquals(FIRST, r.getField(0, StringValue.class).getValue()); assertNotNull("Expecting second record here",inputFormat.nextRecord(r )); assertEquals(SECOND, r.getField(0, StringValue.class).getValue()); assertNull("The input file is over", inputFormat.nextRecord(r)); } catch (Throwable t) { System.err.println("test failed with exception: " + t.getMessage()); t.printStackTrace(System.err); fail("Test erroneous"); } }