Skip to content

Commit f93d421

Browse files
committed
Sort members
1 parent a3e33e1 commit f93d421

File tree

4 files changed

+57
-57
lines changed

4 files changed

+57
-57
lines changed

src/main/java/org/apache/commons/io/input/Tailer.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,24 @@ public static Tailer create(final File file, final TailerListener tailerListener
718718
*/
719719
private final boolean ignoreTouch;
720720

721+
/**
722+
* Creates a Tailer for the given file, with a specified buffer size.
723+
*
724+
* @param builder holds construction data.
725+
*/
726+
private Tailer(final Builder builder) {
727+
this.tailable = Objects.requireNonNull(builder.tailable, "tailable");
728+
this.listener = Objects.requireNonNull(builder.tailerListener, "listener");
729+
this.delayDuration = builder.delayDuration;
730+
this.tailFromEnd = builder.tailFromEnd;
731+
this.inbuf = IOUtils.byteArray(builder.getBufferSize());
732+
// Save and prepare the listener
733+
listener.init(this);
734+
this.reOpen = builder.reOpen;
735+
this.charset = builder.getCharset();
736+
this.ignoreTouch = builder.ignoreTouch;
737+
}
738+
721739
/**
722740
* Creates a Tailer for the given file, with a specified buffer size.
723741
*
@@ -847,24 +865,6 @@ private Tailer(final Tailable tailable, final Charset charset, final TailerListe
847865
this.ignoreTouch = ignoreTouch;
848866
}
849867

850-
/**
851-
* Creates a Tailer for the given file, with a specified buffer size.
852-
*
853-
* @param builder holds construction data.
854-
*/
855-
private Tailer(final Builder builder) {
856-
this.tailable = Objects.requireNonNull(builder.tailable, "tailable");
857-
this.listener = Objects.requireNonNull(builder.tailerListener, "listener");
858-
this.delayDuration = builder.delayDuration;
859-
this.tailFromEnd = builder.tailFromEnd;
860-
this.inbuf = IOUtils.byteArray(builder.getBufferSize());
861-
// Save and prepare the listener
862-
listener.init(this);
863-
this.reOpen = builder.reOpen;
864-
this.charset = builder.getCharset();
865-
this.ignoreTouch = builder.ignoreTouch;
866-
}
867-
868868
/**
869869
* Requests the tailer to complete its current loop and return.
870870
*/

src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,21 @@ private static Path toPath(final Path file, final Supplier<Path> defaultPathSupp
254254
*/
255255
private boolean closed;
256256

257+
/**
258+
* Constructs an instance of this class which will trigger an event at the specified threshold, and save data either to a file beyond that point.
259+
*
260+
* @param builder The construction data source.
261+
*/
262+
private DeferredFileOutputStream(final Builder builder) {
263+
super(builder.threshold);
264+
this.outputPath = toPath(builder.outputFile, null);
265+
this.prefix = builder.prefix;
266+
this.suffix = builder.suffix;
267+
this.directory = toPath(builder.directory, PathUtils::getTempDirectory);
268+
this.memoryOutputStream = new ByteArrayOutputStream(checkBufferSize(builder.getBufferSize()));
269+
this.currentOutputStream = memoryOutputStream;
270+
}
271+
257272
/**
258273
* Constructs an instance of this class which will trigger an event at the specified threshold, and save data to a file beyond that point. The initial
259274
* buffer size will default to {@value AbstractByteArrayOutputStream#DEFAULT_SIZE} bytes which is ByteArrayOutputStream's default buffer size.
@@ -319,21 +334,6 @@ public DeferredFileOutputStream(final int threshold, final int initialBufferSize
319334
this(threshold, null, Objects.requireNonNull(prefix, "prefix"), suffix, directory, initialBufferSize);
320335
}
321336

322-
/**
323-
* Constructs an instance of this class which will trigger an event at the specified threshold, and save data either to a file beyond that point.
324-
*
325-
* @param builder The construction data source.
326-
*/
327-
private DeferredFileOutputStream(final Builder builder) {
328-
super(builder.threshold);
329-
this.outputPath = toPath(builder.outputFile, null);
330-
this.prefix = builder.prefix;
331-
this.suffix = builder.suffix;
332-
this.directory = toPath(builder.directory, PathUtils::getTempDirectory);
333-
this.memoryOutputStream = new ByteArrayOutputStream(checkBufferSize(builder.getBufferSize()));
334-
this.currentOutputStream = memoryOutputStream;
335-
}
336-
337337
/**
338338
* Constructs an instance of this class which will trigger an event at the specified threshold, and save data to a temporary file beyond that point. The
339339
* initial buffer size will default to 32 bytes which is ByteArrayOutputStream's default buffer size.

src/test/java/org/apache/commons/io/input/TailerTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ protected void createFile(final File file, final long size) throws IOException {
219219
assertEquals(size, file.length());
220220
}
221221

222+
private List<String> expectLinesWithLongTimeout(final TestTailerListener listener, final long minDelay, int count) throws Exception {
223+
for (int i = 0; i < count ; i++) {
224+
TestUtils.sleep(minDelay);
225+
final List<String> lines = listener.getLines();
226+
if (lines.size() > 0) {
227+
return lines;
228+
}
229+
}
230+
throw new RuntimeException("waiting for TestTailerListener.getLines() timed out after " + (count * minDelay) + " ms");
231+
}
232+
222233
@Test
223234
@SuppressWarnings("squid:S2699") // Suppress "Add at least one assertion to this test case"
224235
void testBufferBreak() throws Exception {
@@ -738,17 +749,6 @@ void testTailerIgnoreTouch() throws Exception {
738749
}
739750
}
740751

741-
private List<String> expectLinesWithLongTimeout(final TestTailerListener listener, final long minDelay, int count) throws Exception {
742-
for (int i = 0; i < count ; i++) {
743-
TestUtils.sleep(minDelay);
744-
final List<String> lines = listener.getLines();
745-
if (lines.size() > 0) {
746-
return lines;
747-
}
748-
}
749-
throw new RuntimeException("waiting for TestTailerListener.getLines() timed out after " + (count * minDelay) + " ms");
750-
}
751-
752752
@Test
753753
void testTailerReissueOnTouch() throws Exception {
754754
// Create & start the Tailer

src/test/java/org/apache/commons/io/test/TestUtils.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,6 @@ public static void sleep(final long millis) throws InterruptedException {
251251
ThreadUtils.sleep(Duration.ofMillis(millis));
252252
}
253253

254-
/**
255-
* Sleeps till the next full second.
256-
*
257-
* This method is useful when you want to set a guaranteed newer file system timestamp.
258-
* Posix file systems only guarantee one second resolution, and e.g.
259-
* some mac os x filesystems only offer that.
260-
*
261-
* @throws InterruptedException if interrupted.
262-
*/
263-
public static void sleepTillNextFullSecond() throws InterruptedException {
264-
sleep(1001 - (System.currentTimeMillis() % 1000));
265-
}
266-
267254
/**
268255
* Sleeps and swallows InterruptedException.
269256
*
@@ -277,6 +264,19 @@ public static void sleepQuietly(final long millis) {
277264
}
278265
}
279266

267+
/**
268+
* Sleeps till the next full second.
269+
*
270+
* This method is useful when you want to set a guaranteed newer file system timestamp.
271+
* Posix file systems only guarantee one second resolution, and e.g.
272+
* some mac os x filesystems only offer that.
273+
*
274+
* @throws InterruptedException if interrupted.
275+
*/
276+
public static void sleepTillNextFullSecond() throws InterruptedException {
277+
sleep(1001 - (System.currentTimeMillis() % 1000));
278+
}
279+
280280
private TestUtils() {
281281

282282
}

0 commit comments

Comments
 (0)