This is an automated email from the ASF dual-hosted git repository.
psomogyi pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new ddc31b8f779 HBASE-29543 Fix TestFileChangeWatcher Java 8 time
granularity issue (#7241)
ddc31b8f779 is described below
commit ddc31b8f7799447d6f0e04dce7f2a2ca6ebcf90a
Author: Peter Somogyi <[email protected]>
AuthorDate: Mon Aug 25 09:38:58 2025 +0200
HBASE-29543 Fix TestFileChangeWatcher Java 8 time granularity issue (#7241)
Signed-off-by: Andor Molnár <[email protected]>
---
.../java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java | 9 +++++----
.../apache/hadoop/hbase/security/TestNettyTLSIPCFileWatcher.java | 4 ++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git
a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
index c24e96f8da6..484a3de3143 100644
---
a/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
+++
b/hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestFileChangeWatcher.java
@@ -125,7 +125,7 @@ public class TestFileChangeWatcher {
});
watcher.start();
watcher.waitForState(FileChangeWatcher.State.RUNNING);
- Thread.sleep(1000L); // TODO hack
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
assertEquals("Should not have been notified", 0, notifiedPaths.size());
} finally {
if (watcher != null) {
@@ -149,8 +149,8 @@ public class TestFileChangeWatcher {
});
watcher.start();
watcher.waitForState(FileChangeWatcher.State.RUNNING);
- Thread.sleep(1000L); // TODO hack
for (int i = 0; i < 3; i++) {
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
LOG.info("Modifying file, attempt {}", (i + 1));
FileUtils.writeStringToFile(tempFile, "Hello world " + i + "\n",
StandardCharsets.UTF_8,
true);
@@ -185,7 +185,7 @@ public class TestFileChangeWatcher {
});
watcher.start();
watcher.waitForState(FileChangeWatcher.State.RUNNING);
- Thread.sleep(1000L); // TODO hack
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
LOG.info("Touching file");
FileUtils.touch(tempFile);
synchronized (notifiedPaths) {
@@ -223,7 +223,7 @@ public class TestFileChangeWatcher {
});
watcher.start();
watcher.waitForState(FileChangeWatcher.State.RUNNING);
- Thread.sleep(1000L); // TODO hack
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
LOG.info("Modifying file");
FileUtils.writeStringToFile(tempFile, "Hello world\n",
StandardCharsets.UTF_8, true);
synchronized (callCount) {
@@ -231,6 +231,7 @@ public class TestFileChangeWatcher {
callCount.wait(FS_TIMEOUT);
}
}
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
LOG.info("Modifying file again");
FileUtils.writeStringToFile(tempFile, "Hello world again\n",
StandardCharsets.UTF_8, true);
synchronized (callCount) {
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTLSIPCFileWatcher.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTLSIPCFileWatcher.java
index ede88169c3b..6d9fa5f6751 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTLSIPCFileWatcher.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTLSIPCFileWatcher.java
@@ -190,6 +190,8 @@ public class TestNettyTLSIPCFileWatcher {
final Path trustStorePath =
Paths.get(CONF.get(X509Util.TLS_CONFIG_TRUSTSTORE_LOCATION));
createAndStartFileWatcher(trustStorePath, latch, Duration.ofMillis(20));
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
+
// Replace keystore
x509TestContext.regenerateStores(keyType, keyType, storeFileType,
storeFileType);
@@ -240,6 +242,8 @@ public class TestNettyTLSIPCFileWatcher {
final Path trustStorePath =
Paths.get(CONF.get(X509Util.TLS_CONFIG_TRUSTSTORE_LOCATION));
createAndStartFileWatcher(trustStorePath, latch,
Duration.ofMillis(20));
+ Thread.sleep(1100L); // Ensure mtime changes on Java 8 (second
granularity)
+
// Replace keystore and cancel client connections
x509TestContext.regenerateStores(keyType, keyType, storeFileType,
storeFileType);
client.cancelConnections(