You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/01/28 09:33:29 UTC
[syncope] branch master updated: [SYNCOPE-1536] Stopping
FileAlterationMonitor instance during SyncopeEnduserApplication#onDestroy
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 628060a [SYNCOPE-1536] Stopping FileAlterationMonitor instance during SyncopeEnduserApplication#onDestroy
628060a is described below
commit 628060a9d53b4bfcde79ca7891f152ec0e76fdbd
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue Jan 28 10:32:46 2020 +0100
[SYNCOPE-1536] Stopping FileAlterationMonitor instance during SyncopeEnduserApplication#onDestroy
---
.../client/enduser/SyncopeWebApplication.java | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
index eb8a900..edc4ae4 100644
--- a/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
+++ b/client/idrepo/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeWebApplication.java
@@ -133,6 +133,8 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
private Integer maxUploadFileSizeMB;
+ private FileAlterationMonitor customFormAttributesMonitor;
+
private Map<String, CustomAttributesInfo> customFormAttributes;
protected void setSecurityHeaders(final Properties props, final WebResponse response) {
@@ -207,7 +209,7 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
: new FileAlterationObserver(getClass().getResource('/' + CUSTOM_FORM_ATTRIBUTES_FILE).getFile(),
pathname -> StringUtils.contains(pathname.getPath(), CUSTOM_FORM_ATTRIBUTES_FILE));
- FileAlterationMonitor monitor = new FileAlterationMonitor(5000);
+ customFormAttributesMonitor = new FileAlterationMonitor(5000);
FileAlterationListener listener = new FileAlterationListenerAdaptor() {
@@ -220,7 +222,8 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
new TypeReference<HashMap<String, CustomAttributesInfo>>() {
});
} catch (IOException e) {
- e.printStackTrace(System.err);
+ LOG.error("{} While reading app customization configuration.",
+ CUSTOM_FORM_ATTRIBUTES_FILE, e);
}
}
@@ -233,7 +236,8 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
new TypeReference<HashMap<String, CustomAttributesInfo>>() {
});
} catch (IOException e) {
- e.printStackTrace(System.err);
+ LOG.error("{} While reading app customization configuration.",
+ CUSTOM_FORM_ATTRIBUTES_FILE, e);
}
}
@@ -246,8 +250,8 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
};
observer.addListener(listener);
- monitor.addObserver(observer);
- monitor.start();
+ customFormAttributesMonitor.addObserver(observer);
+ customFormAttributesMonitor.start();
} catch (Exception e) {
throw new WicketRuntimeException("Could not read " + CUSTOM_FORM_ATTRIBUTES_FILE, e);
}
@@ -359,7 +363,13 @@ public class SyncopeWebApplication extends WicketBootStandardWebApplication {
protected void onDestroy() {
serviceOps.unregister(getNetworkService());
- super.onDestroy();
+ if (customFormAttributesMonitor != null) {
+ try {
+ customFormAttributesMonitor.stop(0);
+ } catch (Exception e) {
+ LOG.error("{} While stopping file monitor", CUSTOM_FORM_ATTRIBUTES_FILE, e);
+ }
+ }
}
@Override