diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index ac0082e1..0dc6c31b 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,21 +1,23 @@ # OpenAS2 Server -# Version 2.13.1 +# Version 2.14.0 # RELEASE NOTES ----- -The OpenAS2 project is pleased to announce the release of OpenAS2 2.13.1 +The OpenAS2 project is pleased to announce the release of OpenAS2 2.14.0 -The release download file is: OpenAS2Server-2.13.1.zip +The release download file is: OpenAS2Server-2.14.0.zip + + **IMPORTANT:** If you are currently running 2.13.1 then you should upgrade to this release ASAP The zip file contains a PDF document (OpenAS2HowTo.pdf) providing information on installing and using the application. ## NOTE: Testing covers Java 8 to 17. The application should work for older versions down to Java 7 but they are not tested as part of the CI/CD pipeline. -Version 2.13.1 - 2021-12-02 -This is a minor enhancement release and windows bat files bugfix: +Version 2.14.0 - 2021-12-10 +This is a minor enhancement release and OS file handle release bugfix: **IMPORTANT NOTE**: Please review upgrade notes below if you are upgrading - 1. Fix error when resender is invoked. - 2. Fix directory polling module dying when specific errors occur that are not caught at source and end up in the module base invocation. + 1. Add an additional way to filter files based on a regular expression. This allows filtering files based on text within the file name and not just the file extension. See the section **Restricting Directory Files By Extension Or Name** in the documentation for details of use. + 2. Fix directory polling module not releasing file handles and eventually starving the OS of file handles. ##Upgrade Notes diff --git a/Remote/pom.xml b/Remote/pom.xml index bdaa303c..23f9712f 100644 --- a/Remote/pom.xml +++ b/Remote/pom.xml @@ -4,7 +4,7 @@ net.sf.openas2 OpenAS2 - 2.13.1 + 2.14.0 4.0.0 diff --git a/Server/pom.xml b/Server/pom.xml index 9909dd1b..30263e56 100644 --- a/Server/pom.xml +++ b/Server/pom.xml @@ -7,7 +7,7 @@ net.sf.openas2 OpenAS2 - 2.13.1 + 2.14.0 ../pom.xml diff --git a/Server/src/main/java/org/openas2/app/OpenAS2Server.java b/Server/src/main/java/org/openas2/app/OpenAS2Server.java index 257f74a0..732bb16c 100644 --- a/Server/src/main/java/org/openas2/app/OpenAS2Server.java +++ b/Server/src/main/java/org/openas2/app/OpenAS2Server.java @@ -101,23 +101,27 @@ public static Attributes getManifestAttributes() { InputStream is = url.openStream(); if (is != null) { Manifest manifest = new Manifest(is); - manifestAttributes = manifest.getMainAttributes(); + Attributes attribs = manifest.getMainAttributes(); is.close(); - String vendor = manifestAttributes.getValue(MANIFEST_VENDOR_ID_ATTRIB); + String vendor = attribs.getValue(MANIFEST_VENDOR_ID_ATTRIB); if (vendor != null && VENDOR_ID.equals(vendor)) { // We have an OpenAS2 jar at least - check the project name - String project = manifestAttributes.getValue(MANIFEST_TITLE_ATTRIB); + String project = attribs.getValue(MANIFEST_TITLE_ATTRIB); if (project != null && PROJECT_NAME.equals(project)) { if (openAS2Manifest != null) { // A duplicate detected throw new OpenAS2Exception("Duplicate manifests detected: " + openAS2Manifest.getPath() + " ::: " + url.getPath()); } openAS2Manifest = url; + manifestAttributes = attribs; } } + } else { + LOGGER.warn("MANIFEST input stream not opened for: " + url.toString()); } + } catch (Exception e) { - // Silently ignore wrong manifests on classpath? + LOGGER.info("MANIFEST not accessed: " + e.getMessage(), e); } } } catch (IOException e1) { diff --git a/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java b/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java index 8b66f4cf..0fb8bed2 100644 --- a/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java +++ b/Server/src/main/java/org/openas2/processor/receiver/DirectoryPollingModule.java @@ -21,12 +21,14 @@ public abstract class DirectoryPollingModule extends PollingModule { public static final String PARAM_OUTBOX_DIRECTORY = "outboxdir"; public static final String PARAM_FILE_EXTENSION_FILTER = "fileextensionfilter"; public static final String PARAM_FILE_EXTENSION_EXCLUDE_FILTER = "fileextensionexcludefilter"; + public static final String PARAM_FILE_NAME_EXCLUDE_FILTER = "filenameexcluderegexfilter"; private Map trackedFiles; private String outboxDir; private String errorDir; private String sentDir = null; private List allowExtensions; private List excludeExtensions; + private String excludeFilenameRegexFilter = null; private Log logger = LogFactory.getLog(DirectoryPollingModule.class.getSimpleName()); @@ -43,6 +45,7 @@ public void init(Session session, Map options) throws OpenAS2Exc IOUtil.getDirectoryFile(pendingFolder); String allowExtensionFilter = getParameter(PARAM_FILE_EXTENSION_FILTER, ""); String excludeExtensionFilter = getParameter(PARAM_FILE_EXTENSION_EXCLUDE_FILTER, ""); + String excludeFilenameRegexFilter = getParameter(PARAM_FILE_NAME_EXCLUDE_FILTER, ""); if (allowExtensionFilter == null || allowExtensionFilter.length() < 1) { this.allowExtensions = new ArrayList(); @@ -54,6 +57,9 @@ public void init(Session session, Map options) throws OpenAS2Exc } else { this.excludeExtensions = Arrays.asList(excludeExtensionFilter.split("\\s*,\\s*")); } + if (excludeFilenameRegexFilter != null && excludeFilenameRegexFilter.length() > 0) { + this.excludeFilenameRegexFilter = excludeFilenameRegexFilter; + } } catch (IOException e) { throw new OpenAS2Exception("Failed to initialise directory poller.", e); @@ -90,39 +96,49 @@ protected void scanDirectory(String directory) throws IOException, InvalidParame /* Claudio.Degioanni - Versione modificata 20210628 2.11 - Start */ /** - * Rispetto alla versione tesi ho aggiunto il supporto per allowExtensions e excludeExtensions aggiunto nelle versioni dopo + * Rispetto alla versione tesi ho aggiunto il supporto per allowExtensions e + * excludeExtensions aggiunto nelle versioni dopo */ - + if (logger.isDebugEnabled()) { + logger.debug("Polling module scanning directory: " + directory); + } File directoryAsFile = IOUtil.getDirectoryFile(directory); - - DirectoryStream dirs = Files.newDirectoryStream(directoryAsFile.toPath(), entry -> { - String name = entry.getFileName().toString(); - String extension = name.substring(name.lastIndexOf(".") + 1); - boolean isAllowed = true; - if (!allowExtensions.isEmpty()) { - isAllowed = allowExtensions.contains(extension); - if (!isAllowed) { + // Wrap in try-with-resources block to ensure close() is called + try (DirectoryStream dirs = Files.newDirectoryStream(directoryAsFile.toPath(), entry -> { + String name = entry.getFileName().toString(); + if (Files.isDirectory(entry)) { return false; } - } - // Check for the excluded filters - if (!excludeExtensions.isEmpty()) { - isAllowed = !excludeExtensions.contains(extension); - } - return isAllowed; + if (logger.isDebugEnabled()) { + logger.debug("Polling module file name found: " + name); + } + String extension = name.substring(name.lastIndexOf(".") + 1); + boolean isAllowed = true; + if (!allowExtensions.isEmpty()) { + isAllowed = allowExtensions.contains(extension); + } + // Check for the excluded filters if not already disallowed + if (isAllowed && !excludeExtensions.isEmpty()) { + isAllowed = !excludeExtensions.contains(extension); + } + // Check if there are filename regex exclusions if not already disallowed + if (isAllowed && excludeFilenameRegexFilter != null) { + isAllowed = !name.matches(excludeFilenameRegexFilter); + } + return isAllowed; - }); + })) { - for (Path dir : dirs) { - File currentFile = dir.toFile(); + for (Path dir : dirs) { + File currentFile = dir.toFile(); - if (checkFile(currentFile)) { - // start watching the file's size if it's not already being watched - trackFile(currentFile); + if (checkFile(currentFile)) { + // start watching the file's size if it's not already being watched + trackFile(currentFile); + } } + /* Claudio.degioanni - Versione modificata 20210628 2.11 - End */ } - - /* Claudio.degioanni - Versione modificata 20210628 2.11 - End */ } protected boolean checkFile(File file) { diff --git a/changes.txt b/changes.txt index da28d376..2ff56276 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,11 @@ -Version 2.13.0 - 2021-12-02 +Version 2.14.0 - 2021-12-10 +This is a enhancement and bugfix release: + **IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading + + 1. Add an additional way to filter files based on a regular expression. This allows filtering files based on text within the file name and not just the file extension. See the section **Restricting Directory Files By Extension Or Name** in the documentation for details of use. + 2. Fix directory polling module not releasing file handles and eventually starving the OS of file handles. + +Version 2.13.1 - 2021-12-02 This is a bugfix release: **IMPORTANT NOTE**: Please review upgrade notes in the RELEASE-NOTES.md if you are upgrading diff --git a/docs/OpenAS2HowTo.odt b/docs/OpenAS2HowTo.odt index af6438c5..1ce22303 100644 Binary files a/docs/OpenAS2HowTo.odt and b/docs/OpenAS2HowTo.odt differ diff --git a/docs/OpenAS2HowTo.pdf b/docs/OpenAS2HowTo.pdf index c840e893..5ad63b80 100644 Binary files a/docs/OpenAS2HowTo.pdf and b/docs/OpenAS2HowTo.pdf differ diff --git a/pom.xml b/pom.xml index 084f4f41..5f0df89a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.sf.openas2 OpenAS2 - 2.13.1 + 2.14.0 OpenAS2 pom