From df454f44bd8cc25001bc6d2bb2a4f1031bac9422 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 26 Mar 2009 15:36:07 +0000
Subject: [PATCH] Fix for issue 3451 ("Unfinished" error message from ldapcompare --filename nosuchfile) Use an specific error message when we cannot read the provided file.
---
opendj-sdk/opends/src/messages/messages/tools.properties | 4 ++++
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java | 22 ++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/opendj-sdk/opends/src/messages/messages/tools.properties b/opendj-sdk/opends/src/messages/messages/tools.properties
index 61103a3..b3d7a8e 100644
--- a/opendj-sdk/opends/src/messages/messages/tools.properties
+++ b/opendj-sdk/opends/src/messages/messages/tools.properties
@@ -2463,3 +2463,7 @@
SEVERE_ERR_START_DATETIME_ALREADY_PASSED_1667=The specified start time '%s' \
has already passed
+
+SEVERE_ERR_LDAPCOMPARE_ERROR_READING_FILE_1668=An error occurred reading file \
+ '%s'. Check that the file exists and that you have read access rights to \
+ it. Details: %s
\ No newline at end of file
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
index 5117e2e..77e8b52 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -933,7 +933,25 @@
rdr = new InputStreamReader(System.in);
} else if(fileNameValue != null)
{
- rdr = new FileReader(fileNameValue);
+ try
+ {
+ rdr = new FileReader(fileNameValue);
+ }
+ catch (Throwable t)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, t);
+ }
+ String details = t.getMessage();
+ if (details == null)
+ {
+ details = t.toString();
+ }
+ err.println(wrapText(ERR_LDAPCOMPARE_ERROR_READING_FILE.get(
+ fileNameValue, details), MAX_LINE_WIDTH));
+ return 1;
+ }
}
if(rdr != null)
{
--
Gitblit v1.10.0