From cf4d532bc0312d6456637a01c6b7c29d2906ecbd Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 13 Apr 2009 19:26:44 +0000
Subject: [PATCH] Fix for issues 2273 and 3482:
---
opends/src/server/org/opends/server/loggers/TimeStampNaming.java | 51 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/opends/src/server/org/opends/server/loggers/TimeStampNaming.java b/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
index b4113d0..38ae09f 100644
--- a/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
+++ b/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.loggers;
@@ -43,7 +43,8 @@
*/
private static final DebugTracer TRACER = getTracer();
- File file;
+ private File file;
+ private TimeStampNamingFilter filter;
/**
* The FilenameFilter implementation for this naming policy to filter
@@ -66,8 +67,45 @@
{
return false;
}
- name = name.toLowerCase();
- return name.startsWith(file.getName().toLowerCase());
+
+ String initialFileName = file.getName();
+
+ // Make sure it is the expected length.
+ if(name.length() != initialFileName.length() + 16)
+ {
+ return false;
+ }
+
+ int pos;
+ // Make sure we got the expected name prefix.
+ for(pos = 0; pos < initialFileName.length(); pos++)
+ {
+ if(name.charAt(pos) != initialFileName.charAt(pos))
+ {
+ return false;
+ }
+ }
+
+ // Make sure there is a period between the prefix and timestamp.
+ if(name.charAt(pos) != '.')
+ {
+ return false;
+ }
+
+ char c;
+ // Make sure there are 14 numbers for the timestamp.
+ for(pos++; pos < name.length() - 1; pos++)
+ {
+ c = name.charAt(pos);
+ if(c < 48 || c > 57)
+ {
+ return false;
+ }
+ }
+
+ // And ends with an Z.
+ return name.charAt(pos) == 'Z';
+
}
}
@@ -80,6 +118,7 @@
public TimeStampNaming(File file)
{
this.file = file;
+ this.filter = new TimeStampNamingFilter();
}
/**
@@ -103,7 +142,7 @@
*/
public FilenameFilter getFilenameFilter()
{
- return new TimeStampNamingFilter();
+ return filter;
}
/**
@@ -112,7 +151,7 @@
public File[] listFiles()
{
File directory = file.getParentFile();
- File[] files = directory.listFiles(getFilenameFilter());
+ File[] files = directory.listFiles(filter);
if(files == null)
{
--
Gitblit v1.10.0