You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/05/10 16:10:09 UTC
[commons-io] branch master updated (8814b6d7 -> ce20baf6)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
from 8814b6d7 Replace "Invalid" with "Illegal" in some exception messages
new 8ec68f42 Rename internal methods and field
new a56fcff4 Javadoc
new ce20baf6 Setting builder delay duration to null acts as a reset.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/main/java/org/apache/commons/io/CopyUtils.java | 2 +-
src/main/java/org/apache/commons/io/IOUtils.java | 26 +++++++++++-----------
.../java/org/apache/commons/io/input/Tailer.java | 14 +++++++-----
3 files changed, 22 insertions(+), 20 deletions(-)
[commons-io] 02/03: Javadoc
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit a56fcff406b30ce77b9b327a4770f31831f92f08
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed May 10 12:06:05 2023 -0400
Javadoc
---
src/main/java/org/apache/commons/io/input/Tailer.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/input/Tailer.java b/src/main/java/org/apache/commons/io/input/Tailer.java
index a58d20f2..a8339705 100644
--- a/src/main/java/org/apache/commons/io/input/Tailer.java
+++ b/src/main/java/org/apache/commons/io/input/Tailer.java
@@ -223,9 +223,9 @@ public class Tailer implements Runnable, AutoCloseable {
}
/**
- * Sets an executor service to use when startThread is true.
+ * Sets the executor service to use when startThread is true.
*
- * @param executorService
+ * @param executorService the executor service to use when startThread is true.
* @return this
*/
public Builder setExecutorService(final ExecutorService executorService) {
[commons-io] 01/03: Rename internal methods and field
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 8ec68f42fd2763e67232e89558328ba5cf933d44
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed May 10 12:04:23 2023 -0400
Rename internal methods and field
These are not just for "skipping"
---
src/main/java/org/apache/commons/io/CopyUtils.java | 2 +-
src/main/java/org/apache/commons/io/IOUtils.java | 26 +++++++++++-----------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/CopyUtils.java b/src/main/java/org/apache/commons/io/CopyUtils.java
index 133cc8e4..dd4003c5 100644
--- a/src/main/java/org/apache/commons/io/CopyUtils.java
+++ b/src/main/java/org/apache/commons/io/CopyUtils.java
@@ -266,7 +266,7 @@ public class CopyUtils {
final Reader input,
final Writer output)
throws IOException {
- final char[] buffer = IOUtils.getCharArray();
+ final char[] buffer = IOUtils.getScratchCharArray();
int count = 0;
int n;
while (EOF != (n = input.read(buffer))) {
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index 194dceaa..58fb5521 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -195,12 +195,12 @@ public class IOUtils {
/**
* Internal byte array buffer.
*/
- private static final ThreadLocal<byte[]> SKIP_BYTE_BUFFER = ThreadLocal.withInitial(IOUtils::byteArray);
+ private static final ThreadLocal<byte[]> SCRATCH_BYTE_BUFFER = ThreadLocal.withInitial(IOUtils::byteArray);
/**
* Internal byte array buffer.
*/
- private static final ThreadLocal<char[]> SKIP_CHAR_BUFFER = ThreadLocal.withInitial(IOUtils::charArray);
+ private static final ThreadLocal<char[]> SCRATCH_CHAR_BUFFER = ThreadLocal.withInitial(IOUtils::charArray);
/**
* Returns the given InputStream if it is already a {@link BufferedInputStream}, otherwise creates a
@@ -879,7 +879,7 @@ public class IOUtils {
}
// reuse one
- final byte[] array1 = getByteArray();
+ final byte[] array1 = getScratchByteArray();
// allocate another
final byte[] array2 = byteArray();
int pos1;
@@ -950,7 +950,7 @@ public class IOUtils {
}
// reuse one
- final char[] array1 = getCharArray();
+ final char[] array1 = getScratchCharArray();
// but allocate another
final char[] array2 = charArray();
int pos1;
@@ -1489,7 +1489,7 @@ public class IOUtils {
*/
public static long copyLarge(final InputStream input, final OutputStream output, final long inputOffset,
final long length) throws IOException {
- return copyLarge(input, output, inputOffset, length, getByteArray());
+ return copyLarge(input, output, inputOffset, length, getScratchByteArray());
}
/**
@@ -1560,7 +1560,7 @@ public class IOUtils {
* @since 1.3
*/
public static long copyLarge(final Reader reader, final Writer writer) throws IOException {
- return copyLarge(reader, writer, getCharArray());
+ return copyLarge(reader, writer, getScratchCharArray());
}
/**
@@ -1611,7 +1611,7 @@ public class IOUtils {
*/
public static long copyLarge(final Reader reader, final Writer writer, final long inputOffset, final long length)
throws IOException {
- return copyLarge(reader, writer, inputOffset, length, getCharArray());
+ return copyLarge(reader, writer, inputOffset, length, getScratchCharArray());
}
/**
@@ -1664,8 +1664,8 @@ public class IOUtils {
*
* @return the thread local byte array.
*/
- static byte[] getByteArray() {
- return SKIP_BYTE_BUFFER.get();
+ static byte[] getScratchByteArray() {
+ return SCRATCH_BYTE_BUFFER.get();
}
/**
@@ -1673,8 +1673,8 @@ public class IOUtils {
*
* @return the thread local char array.
*/
- static char[] getCharArray() {
- return SKIP_CHAR_BUFFER.get();
+ static char[] getScratchCharArray() {
+ return SCRATCH_CHAR_BUFFER.get();
}
/**
@@ -2300,7 +2300,7 @@ public class IOUtils {
long remain = toSkip;
while (remain > 0) {
// See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip()
- final byte[] byteArray = getByteArray();
+ final byte[] byteArray = getScratchByteArray();
final long n = input.read(byteArray, 0, (int) Math.min(remain, byteArray.length));
if (n < 0) { // EOF
break;
@@ -2368,7 +2368,7 @@ public class IOUtils {
long remain = toSkip;
while (remain > 0) {
// See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip()
- final char[] charArray = getCharArray();
+ final char[] charArray = getScratchCharArray();
final long n = reader.read(charArray, 0, (int) Math.min(remain, charArray.length));
if (n < 0) { // EOF
break;
[commons-io] 03/03: Setting builder delay duration to null acts as a reset.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit ce20baf6033cc123f9732de59ec09d83bb4ddd43
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed May 10 12:09:57 2023 -0400
Setting builder delay duration to null acts as a reset.
---
src/main/java/org/apache/commons/io/input/Tailer.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/input/Tailer.java b/src/main/java/org/apache/commons/io/input/Tailer.java
index a8339705..1693b0a1 100644
--- a/src/main/java/org/apache/commons/io/input/Tailer.java
+++ b/src/main/java/org/apache/commons/io/input/Tailer.java
@@ -175,6 +175,8 @@ public class Tailer implements Runnable, AutoCloseable {
*/
public static class Builder extends AbstractStreamBuilder<Tailer, Builder> {
+ private static final Duration DEFAULT_DELAY_DURATION = Duration.ofMillis(DEFAULT_DELAY_MILLIS);
+
/**
* Creates a new daemon thread.
*
@@ -189,7 +191,7 @@ public class Tailer implements Runnable, AutoCloseable {
private Tailable tailable;
private TailerListener tailerListener;
- private Duration delayDuration = Duration.ofMillis(DEFAULT_DELAY_MILLIS);
+ private Duration delayDuration = DEFAULT_DELAY_DURATION;
private boolean end;
private boolean reOpen;
private boolean startThread = true;
@@ -212,13 +214,13 @@ public class Tailer implements Runnable, AutoCloseable {
}
/**
- * Sets the delay duration.
+ * Sets the delay duration. null resets to the default delay of one second.
*
* @param delayDuration the delay between checks of the file for new content.
* @return this
*/
public Builder setDelayDuration(final Duration delayDuration) {
- this.delayDuration = Objects.requireNonNull(delayDuration, "delayDuration");
+ this.delayDuration = delayDuration != null ? delayDuration : DEFAULT_DELAY_DURATION;
return this;
}
@@ -229,7 +231,7 @@ public class Tailer implements Runnable, AutoCloseable {
* @return this
*/
public Builder setExecutorService(final ExecutorService executorService) {
- this.executorService = executorService;
+ this.executorService = Objects.requireNonNull(executorService, "executorService");;
return this;
}