You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/01/30 00:54:33 UTC
cvs commit: jakarta-log4j/org/apache/log4j/helpers FileWatchdog.java
ceki 01/01/29 15:54:33
Modified: org/apache/log4j/helpers FileWatchdog.java
Log:
Fixed a possible problem with uncaugt SecurityException in FileWatchdog.checkAndConfigure.
Reported by Mathias Bogaert.
Revision Changes Path
1.3 +19 -5 jakarta-log4j/org/apache/log4j/helpers/FileWatchdog.java
Index: FileWatchdog.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/helpers/FileWatchdog.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileWatchdog.java 2000/12/14 21:07:44 1.2
+++ FileWatchdog.java 2001/01/29 23:54:32 1.3
@@ -5,6 +5,9 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
+
+// Contributors: Mathias Bogaert
+
package org.apache.log4j.helpers;
import java.io.File;
@@ -36,6 +39,7 @@
File file;
long lastModif = 0;
boolean warnedAlready = false;
+ boolean interrupted = false;
protected
FileWatchdog(String filename) {
@@ -59,10 +63,20 @@
protected
void checkAndConfigure() {
- if(file.exists()) {
- long l = file.lastModified();
- if(l > lastModif) {
- lastModif = l;
+ boolean fileExists;
+ try {
+ fileExists = file.exists();
+ } catch(SecurityException e) {
+ LogLog.warn("Was not allowed to read check file existance, file:["+
+ fileName+"]."));
+ interrupted = true; // there is no point in continuing
+ return;
+ }
+
+ if(fileExists) {
+ long l = file.lastModified(); // this can also throw a SecurityException
+ if(l > lastModif) // however, if we reached this point this
+ lastModif = l; // is very unlikely.
doOnChange();
warnedAlready = false;
}
@@ -76,7 +90,7 @@
public
void run() {
- while(!interrupted()) {
+ while(!interrupted) {
try {
Thread.currentThread().sleep(delay);
} catch(InterruptedException e) {