[Git][java-team/jboss-xnio][master] 6 commits: New upstream version 3.8.10
Markus Koschany (@apo)
gitlab at salsa.debian.org
Wed Sep 13 14:44:41 BST 2023
Markus Koschany pushed to branch master at Debian Java Maintainers / jboss-xnio
Commits:
cb131012 by Markus Koschany at 2023-09-13T15:33:13+02:00
New upstream version 3.8.10
- - - - -
f34a7c8d by Markus Koschany at 2023-09-13T15:33:15+02:00
Update upstream source from tag 'upstream/3.8.10'
Update to upstream version '3.8.10'
with Debian dir 2f1b5021c6f3d3caf6d5c0c38d8bcdf8d478edd7
- - - - -
4bcefdac by Markus Koschany at 2023-09-13T15:33:36+02:00
Update copyright years.
- - - - -
94e28423 by Markus Koschany at 2023-09-13T15:34:28+02:00
Mark binary package Multi-Arch: foreign.
- - - - -
d379083b by Markus Koschany at 2023-09-13T15:34:51+02:00
Declare compliance with Debian Policy 4.6.2.
- - - - -
e93c4e89 by Markus Koschany at 2023-09-13T15:36:31+02:00
Update changelog
- - - - -
11 changed files:
- api/pom.xml
- api/src/main/java/org/xnio/ChannelListeners.java
- api/src/main/java/org/xnio/_private/Messages.java
- debian/changelog
- debian/control
- debian/copyright
- nio-impl/pom.xml
- nio-impl/src/main/java/org/xnio/nio/WatchServiceFileSystemWatcher.java
- nio-impl/src/test/java/org/xnio/nio/test/FileSystemWatcherTestCase.java
- nio-impl/src/test/java/org/xnio/nio/test/XnioWorkerTestCase.java
- pom.xml
Changes:
=====================================
api/pom.xml
=====================================
@@ -37,7 +37,7 @@
<parent>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-all</artifactId>
- <version>3.8.8.Final</version>
+ <version>3.8.10.Final</version>
</parent>
<dependencies>
=====================================
api/src/main/java/org/xnio/ChannelListeners.java
=====================================
@@ -106,7 +106,7 @@ public final class ChannelListeners {
* @param <T> the channel type
*/
public static <T extends Channel> void invokeChannelListener(Executor executor, T channel, ChannelListener<? super T> channelListener) {
- try {
+ if (channelListener != null) try {
executor.execute(getChannelListenerTask(channel, channelListener));
} catch (RejectedExecutionException ree) {
invokeChannelListener(channel, channelListener);
@@ -122,7 +122,7 @@ public final class ChannelListeners {
* @param <T> the exception type
*/
public static <T extends Channel> void invokeChannelExceptionHandler(final T channel, final ChannelExceptionHandler<? super T> exceptionHandler, final IOException exception) {
- try {
+ if (exceptionHandler != null) try {
exceptionHandler.handleException(channel, exception);
} catch (Throwable t) {
listenerMsg.exceptionHandlerException(t);
=====================================
api/src/main/java/org/xnio/_private/Messages.java
=====================================
@@ -242,7 +242,7 @@ public interface Messages extends BasicLogger {
IllegalArgumentException notFromThisProvider();
@Message(id = 307, value = "Failed to close ssl engine when handling exception %s")
- @LogMessage(level = WARN)
+ @LogMessage(level = DEBUG)
void failedToCloseSSLEngine(@Cause Throwable cause, Exception originalException);
// I/O errors
=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+jboss-xnio (3.8.10-1) unstable; urgency=medium
+
+ * New upstream version 3.8.10.
+ * Mark binary package Multi-Arch: foreign.
+ * Declare compliance with Debian Policy 4.6.2.
+
+ -- Markus Koschany <apo at debian.org> Wed, 13 Sep 2023 15:36:18 +0200
+
jboss-xnio (3.8.8-1) unstable; urgency=medium
* New upstream version 3.8.8.
=====================================
debian/control
=====================================
@@ -20,12 +20,13 @@ Build-Depends:
libwildfly-client-config-java,
libwildfly-common-java,
maven-debian-helper (>= 1.5)
-Standards-Version: 4.6.1
+Standards-Version: 4.6.2
Vcs-Git: https://salsa.debian.org/java-team/jboss-xnio.git
Vcs-Browser: https://salsa.debian.org/java-team/jboss-xnio
Homepage: https://xnio.jboss.org/
Package: libjboss-xnio-java
+Multi-Arch: foreign
Architecture: all
Depends:
${maven:Depends},
=====================================
debian/copyright
=====================================
@@ -3,7 +3,7 @@ Upstream-Name: Jboss XNIO
Source: https://github.com/xnio/xnio
Files: *
-Copyright: 2015-2022, Red Hat, Inc.
+Copyright: 2015-2023, Red Hat, Inc.
License: Apache-2.0
Files: nio-impl/src/test/java/org/xnio/nio/test/NioHalfDuplexChannelPipeTestCase.java
@@ -17,7 +17,7 @@ Copyright: 2010-2015, Red Hat, Inc
License: LGPL-2.1+
Files: debian/*
-Copyright: 2015-2022, Markus Koschany <apo at debian.org>
+Copyright: 2015-2023, Markus Koschany <apo at debian.org>
License: Apache-2.0 or LGPL-2.1+
License: Apache-2.0
=====================================
nio-impl/pom.xml
=====================================
@@ -31,7 +31,7 @@
<parent>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-all</artifactId>
- <version>3.8.8.Final</version>
+ <version>3.8.10.Final</version>
</parent>
<properties>
=====================================
nio-impl/src/main/java/org/xnio/nio/WatchServiceFileSystemWatcher.java
=====================================
@@ -117,7 +117,6 @@ class WatchServiceFileSystemWatcher implements FileSystemWatcher, Runnable {
}
results.add(new FileChangeEvent(targetFile, type));
}
- key.pollEvents().clear();
//now we need to prune the results, to remove duplicates
//e.g. if the file is modified after creation we only want to
=====================================
nio-impl/src/test/java/org/xnio/nio/test/FileSystemWatcherTestCase.java
=====================================
@@ -35,12 +35,16 @@ import org.xnio.channels.ConnectedStreamChannel;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
-import static org.xnio.FileChangeEvent.Type.ADDED;
import static org.xnio.FileChangeEvent.Type.MODIFIED;
import static org.xnio.FileChangeEvent.Type.REMOVED;
@@ -54,8 +58,12 @@ public class FileSystemWatcherTestCase {
public static final String EXISTING_FILE_NAME = "a.txt";
public static final String EXISTING_DIR = "existingDir";
- private final BlockingDeque<Collection<FileChangeEvent>> results = new LinkedBlockingDeque<Collection<FileChangeEvent>>();
- private final BlockingDeque<Collection<FileChangeEvent>> secondResults = new LinkedBlockingDeque<Collection<FileChangeEvent>>();
+ private static final int WAIT_SECONDS = 20;
+ private static final int NUM_THREADS = 5;
+ private static final int NUM_FILES = 6;
+
+ private final BlockingDeque<Collection<FileChangeEvent>> results = new LinkedBlockingDeque<>();
+ private final BlockingDeque<Collection<FileChangeEvent>> secondResults = new LinkedBlockingDeque<>();
File rootDir;
File existingSubDir;
@@ -98,8 +106,7 @@ public class FileSystemWatcherTestCase {
@Test
public void testFileSystemWatcher() throws Exception {
- FileSystemWatcher watcher = createXnio().createFileSystemWatcher("testWatcher", OptionMap.create(Options.WATCHER_POLL_INTERVAL, 10));
- try {
+ try (FileSystemWatcher watcher = createXnio().createFileSystemWatcher("testWatcher", OptionMap.create(Options.WATCHER_POLL_INTERVAL, 10))) {
watcher.watchPath(rootDir, new FileChangeCallback() {
@Override
public void handleChanges(Collection<FileChangeEvent> changes) {
@@ -144,65 +151,71 @@ public class FileSystemWatcherTestCase {
added.delete();
Thread.sleep(1);
checkResult(added, REMOVED);
-
-
- } finally {
- watcher.close();
}
-
+ results.clear();
+ secondResults.clear();
}
- private void checkResult(File file, FileChangeEvent.Type type) throws InterruptedException {
- Collection<FileChangeEvent> results = this.results.poll(20, TimeUnit.SECONDS);
- Collection<FileChangeEvent> secondResults = this.secondResults.poll(20, TimeUnit.SECONDS);
- Assert.assertNotNull(results);
- Assert.assertEquals(1, results.size());
- Assert.assertEquals(1, secondResults.size());
- FileChangeEvent res = results.iterator().next();
- FileChangeEvent res2 = secondResults.iterator().next();
-
- //sometime OS's will give a MODIFIED event before the REMOVED one
- //We consume these events here
- long endTime = System.currentTimeMillis() + 10000;
- while (type == REMOVED
- && (res.getType() == MODIFIED || res2.getType() == MODIFIED)
- && System.currentTimeMillis() < endTime) {
- FileChangeEvent[] nextEvents = consumeEvents();
- res = nextEvents[0];
- res2 = nextEvents[1];
- }
+ @Test
+ public void testMultiThread() throws Exception {
+ try (FileSystemWatcher watcher = createXnio().createFileSystemWatcher(
+ "testWatcher", OptionMap.create(Options.WATCHER_POLL_INTERVAL, 10))) {
+ watcher.watchPath(rootDir, new FileChangeCallback() {
+ @Override
+ public void handleChanges(Collection<FileChangeEvent> changes) {
+ results.add(changes);
+ }
+ });
+
+ Thread[] array = new Thread[NUM_THREADS];
+ for (int i = 0; i< array.length; i++) {
+ array[i] = new Thread(new FileAdder(i));
+ array[i].start();
+ }
- //sometime OS's will give a MODIFIED event on its parent folder before the ADDED one
- //We consume these events here
- endTime = System.currentTimeMillis() + 10000;
- while (type == ADDED
- && (res.getType() == MODIFIED || res2.getType() == MODIFIED)
- && (res.getFile().equals(file.getParentFile()) || res2.getFile().equals(file.getParentFile()))
- && !file.isDirectory()
- && System.currentTimeMillis() < endTime) {
- FileChangeEvent[] nextEvents = consumeEvents();
- res = nextEvents[0];
- res2 = nextEvents[1];
+ // mark each file received in a set
+ Set<String> files = new HashSet<>(NUM_THREADS * NUM_FILES);
+ // get changes until all the adds are in the set
+ Collection<FileChangeEvent> events = this.results.poll(WAIT_SECONDS, TimeUnit.SECONDS);
+ while (files.size() < NUM_THREADS * NUM_FILES && events != null) {
+ for (FileChangeEvent e : events) {
+ if (e.getType() == FileChangeEvent.Type.ADDED) {
+ files.add(e.getFile().getName());
+ }
+ }
+ if (files.size() < NUM_THREADS * NUM_FILES) {
+ events = this.results.poll(WAIT_SECONDS, TimeUnit.SECONDS);
+ }
+ }
+ // check the files created are all received
+ for (int i = 0; i < NUM_THREADS; i++) {
+ for (int j = 0; j < NUM_FILES; j++) {
+ Assert.assertTrue("Add for file [" + i + "," + j + "] was not received",
+ files.contains("thread-" + i + "-" + j));
+ }
+ }
}
+ results.clear();
+ }
- Assert.assertEquals(file, res.getFile());
- Assert.assertEquals(type, res.getType());
- Assert.assertEquals(file, res2.getFile());
- Assert.assertEquals(type, res2.getType());
+ private void checkResult(File file, FileChangeEvent.Type type) throws InterruptedException {
+ Assert.assertTrue("File " + file + " operation " + type + " not received in results", checkResult(file, type, results));
+ Assert.assertTrue("File " + file + " operation " + type + " not received in secondResults", checkResult(file, type, secondResults));
}
- private FileChangeEvent[] consumeEvents() throws InterruptedException {
- FileChangeEvent[] nextEvents = new FileChangeEvent[2];
- Collection<FileChangeEvent> results = this.results.poll(1, TimeUnit.SECONDS);
- Collection<FileChangeEvent> secondResults = this.secondResults.poll(1, TimeUnit.SECONDS);
- Assert.assertNotNull(results);
- Assert.assertNotNull(secondResults);
- Assert.assertEquals(1, results.size());
- Assert.assertEquals(1, secondResults.size());
- nextEvents[0] = results.iterator().next();
- nextEvents[1] = secondResults.iterator().next();
-
- return nextEvents;
+ private static boolean checkResult(File file, FileChangeEvent.Type type, BlockingDeque<Collection<FileChangeEvent>> deque) throws InterruptedException {
+ // sometime OS will give a MODIFIED event on its parent folder when a file is ADDED
+ // consume all extra events until the expected one is received
+ Collection<FileChangeEvent> events = deque.poll(WAIT_SECONDS, TimeUnit.SECONDS);
+ while (events != null) {
+ for (FileChangeEvent e : events) {
+ if (file.equals(e.getFile()) && type == e.getType()) {
+ return true;
+ }
+ }
+ events = deque.poll(WAIT_SECONDS, TimeUnit.SECONDS);
+ }
+ return false;
}
public static void deleteRecursive(final File file) {
@@ -215,4 +228,36 @@ public class FileSystemWatcherTestCase {
file.delete();
}
+ /**
+ * Helper runnable to create NUM_FILES files in the working directory with
+ * the name: "thread-" + i + "-" + j. Where i is thread number and j the
+ * iteration [0-NUM_FILES). Between each file creation the thread waits a
+ * random time [0-100ms).
+ */
+ class FileAdder implements Runnable {
+
+ private final int number;
+ private final Random random;
+
+ FileAdder(int number) {
+ this.number = number;
+ this.random = new Random();
+ }
+
+ @Override
+ public void run() {
+ for (int j = 0; j < NUM_FILES; j++) {
+ try {
+ Path added = rootDir.toPath().resolve("thread-" + number + "-" + j);
+ Files.write(added, added.getFileName().toString().getBytes());
+ final int timeout = random.nextInt(100);
+ if (timeout > 0) {
+ TimeUnit.MILLISECONDS.sleep(timeout);
+ }
+ } catch (IOException | InterruptedException e) {
+ Assert.fail("Thread " + number + " failed " + e.getMessage());
+ }
+ }
+ }
+ }
}
=====================================
nio-impl/src/test/java/org/xnio/nio/test/XnioWorkerTestCase.java
=====================================
@@ -257,7 +257,6 @@ public class XnioWorkerTestCase {
channelListener.clear();
}
connectedStreamChannel = xnioWorker.connectStream(bindAddress, channelListener, OptionMap.create(Options.MAX_INBOUND_MESSAGE_SIZE, 50000, Options.WORKER_ESTABLISH_WRITING, true)).cancel();
- connectedStreamChannel.cancel();
} while (connectedStreamChannel.getStatus() != IoFuture.Status.CANCELLED);
CancellationException expected = null;
@@ -269,8 +268,9 @@ public class XnioWorkerTestCase {
assertNotNull(expected);
assertSame(IoFuture.Status.CANCELLED, connectedStreamChannel.getStatus());
- assertFalse(channelListener.isInvokedYet());
- assertFalse(bindListener.isInvokedYet());
+ assertFalse("listener is not supposed to have been invoked; is channel open: " +
+ (channelListener.getChannel() != null? channelListener.getChannel().isOpen(): " null channel"),
+ channelListener.isInvokedYet());
// make sure that the server is up and can accept more connections
assertTrue(streamServer.isOpen());
@@ -490,6 +490,8 @@ public class XnioWorkerTestCase {
assertNotNull(channel);
connectedStreamChannel.get().close();
channel.close();
+ channelListener.clear();
+ bindListener.clear();
// try again once more
channelFuture = xnioWorker.acceptStream(bindAddress, channelListener, bindListener, OptionMap.EMPTY).cancel();
connectedStreamChannel = xnioWorker.connectStream(bindAddress, null, OptionMap.EMPTY);
@@ -849,12 +851,12 @@ public class XnioWorkerTestCase {
private final CountDownLatch countDown = new CountDownLatch(1);
@Override
- public void run() {
+ public synchronized void run() {
invoked = true;
countDown.countDown();
}
- public boolean isInvoked() {
+ public synchronized boolean isInvoked() {
try {
countDown.await();
} catch (InterruptedException e) {
@@ -881,7 +883,7 @@ public class XnioWorkerTestCase {
this(w, -1, null);
}
- public void run() {
+ public synchronized void run() {
try {
if (timeoutUnit == null) {
xnioWorker.awaitTermination();
@@ -893,7 +895,7 @@ public class XnioWorkerTestCase {
}
}
- public boolean isInterrupted() {
+ public synchronized boolean isInterrupted() {
return interrupted;
}
}
=====================================
pom.xml
=====================================
@@ -32,7 +32,7 @@
<artifactId>xnio-all</artifactId>
<packaging>pom</packaging>
<name>XNIO Parent POM</name>
- <version>3.8.8.Final</version>
+ <version>3.8.10.Final</version>
<description>The aggregator POM of the XNIO project</description>
<licenses>
View it on GitLab: https://salsa.debian.org/java-team/jboss-xnio/-/compare/5a1c5b4ee7d5fdb9ff6f173487f3e35a2706aba8...e93c4e892b05014cbc25b589bce2dbf1dea2c2ad
--
View it on GitLab: https://salsa.debian.org/java-team/jboss-xnio/-/compare/5a1c5b4ee7d5fdb9ff6f173487f3e35a2706aba8...e93c4e892b05014cbc25b589bce2dbf1dea2c2ad
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20230913/2f1f86b2/attachment.htm>
More information about the pkg-java-commits
mailing list