Skip to content

Commit 30722c4

Browse files
authored
Fix file watcher test for Java 25 (#7263)
1 parent 05aebb2 commit 30722c4

File tree

4 files changed

+25
-20
lines changed

4 files changed

+25
-20
lines changed

api/src/org/labkey/api/annotations/JavaRuntimeVersion.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
Used to mark code that is specific to a particular Java runtime version, for example, hacks that work around problems
2020
in the runtime or links to the Java documentation. Re-evaluate these when Java versions are released or deprecated.
2121
Search for text "@JavaRuntimeVersion" to find all usages.
22-
User: adam
23-
Date: 9/11/13
2422
*/
2523

2624
import java.lang.annotation.Retention;

api/src/org/labkey/api/files/FileSystemWatcherImpl.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.jetbrains.annotations.Nullable;
2424
import org.junit.Assert;
2525
import org.junit.Test;
26+
import org.labkey.api.annotations.JavaRuntimeVersion;
2627
import org.labkey.api.cloud.CloudWatchService;
2728
import org.labkey.api.cloud.CloudWatcherConfig;
2829
import org.labkey.api.collections.ConcurrentHashSet;
@@ -61,16 +62,20 @@
6162
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
6263

6364
/**
64-
* Wraps the low-level Java WatchService API with a simple listener-based interface. Unlike WatchService, which is limited to one
65-
* registration per file system directory, a single instance of this class should be sufficient to handle all file system listener
66-
* needs of the entire server.
67-
*
68-
* Callers register a FileSystemDirectoryListener on a directory Path, specifying the desired WatchEvent.Kinds (CREATE, DELETE,
69-
* and/or MODIFY); whenever an event occurs on any file or child directory in that directory, the appropriate method is invoked
70-
* on all listeners registered on that directory that have requested notification of that event.
71-
*
72-
* This class is thread-safe, for both listener registration and event invocation. Implementations of FileSystemDirectoryListener
73-
* must be thread-safe. Listener methods must return quickly since they are all invoked by a single thread.
65+
* <p>Wraps the low-level Java WatchService API with a simple listener-based interface. Unlike WatchService, which is
66+
* limited to one registration per file system directory, a single instance of this class should be sufficient to handle
67+
* all file system listener needs of the entire server.
68+
* </p>
69+
* <p>
70+
* Callers register a FileSystemDirectoryListener on a directory Path, specifying the desired WatchEvent.Kinds (CREATE,
71+
* DELETE, and/or MODIFY); whenever an event occurs on any file or child directory in that directory, the appropriate
72+
* method is invoked on all listeners registered on that directory that have requested notification of that event.
73+
* </p>
74+
* <p>
75+
* This class is thread-safe, for both listener registration and event invocation. Implementations of
76+
* FileSystemDirectoryListener must be thread-safe. Listener methods must return quickly since they are all invoked by a
77+
* single thread.
78+
* </p>
7479
*/
7580
public class FileSystemWatcherImpl implements FileSystemWatcher
7681
{
@@ -586,8 +591,10 @@ public void overflow()
586591

587592
assertEquals(3, created.size());
588593
assertTrue(created.containsAll(Set.of("a", "b", "c")));
589-
// Note: Modified events occur on delete on Windows, but not Linux
590-
Set<String> expectedModified = SystemUtils.IS_OS_WINDOWS ? Set.of("a", "b", "c") : Set.of("a", "c");
594+
// Note: In Java 17 on Windows, modified events occur on delete. This has never been the case on Linux and
595+
// is no longer the case in Java 25. TODO: Delete this check once we require Java 25
596+
@JavaRuntimeVersion
597+
Set<String> expectedModified = SystemUtils.IS_OS_WINDOWS && SystemUtils.IS_JAVA_17 ? Set.of("a", "b", "c") : Set.of("a", "c");
591598
assertEquals(expectedModified.size(), modified.size());
592599
assertTrue(created.containsAll(expectedModified));
593600
int deletedCount = deleted.size();
@@ -613,9 +620,9 @@ private void waitForEvents(AtomicInteger events, int targetCount) throws Interru
613620
i++;
614621
}
615622

616-
LOG.info("Waiting for file watcher events took " + StringUtilsLabKey.pluralize(i, "second"));
623+
LOG.info("Waiting for file watcher events took {}", StringUtilsLabKey.pluralize(i, "second"));
617624

618-
LOG.info("Actual event count: " + events.get() + " vs. target: " + targetCount);
625+
LOG.info("Actual event count: {} vs. target: {}", events.get(), targetCount);
619626
//assertEquals(expectedEventCount, events.get());
620627
}
621628
}

api/src/org/labkey/api/jsp/JspLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void moduleStartupComplete(ServletContext servletContext)
6666
* Create a new JSP page.
6767
*
6868
* @param jspFile Full path to the JSP page, starting with "/"
69-
* @return inited page
69+
* @return initialized page
7070
*/
7171
public static HttpJspPage createPage(String jspFile)
7272
{
@@ -84,7 +84,7 @@ public static HttpJspPage createPage(String jspFile)
8484
}
8585
}
8686

87-
public static Class loadClass(String jspFile)
87+
public static Class<?> loadClass(String jspFile)
8888
{
8989
try
9090
{

api/src/org/labkey/api/jsp/RecompilingJspClassLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class RecompilingJspClassLoader extends JspClassLoader
6363
private static final String DB_SCRIPT_PATH = "/schemas/dbscripts";
6464

6565
@Override
66-
public Class loadClass(ServletContext context, String jspFilename) throws ClassNotFoundException
66+
public Class<?> loadClass(ServletContext context, String jspFilename) throws ClassNotFoundException
6767
{
6868
String compiledJspPath = getCompiledJspPath(jspFilename);
6969
Collection<ResourceFinder> finders = ModuleLoader.getInstance().getResourceFindersForPath(compiledJspPath);
@@ -86,7 +86,7 @@ public Class loadClass(ServletContext context, String jspFilename) throws ClassN
8686

8787

8888
@JavaRuntimeVersion // Change CompilerTargetVM and CompilerSourceVM settings below
89-
private Class getCompiledClassFile(File classFile, File jspJavaFileBuildDirectory, File jspClassesFileBuildDir, ResourceFinder finder, String jspFileName)
89+
private Class<?> getCompiledClassFile(File classFile, File jspJavaFileBuildDirectory, File jspClassesFileBuildDir, ResourceFinder finder, String jspFileName)
9090
{
9191
String relativePath = getSourceJspPath(jspFileName);
9292
// Create File object for JSP source

0 commit comments

Comments
 (0)