From 4e84ddc3f58084e7eee33459909f408ae1aefe54 Mon Sep 17 00:00:00 2001 From: Dmitry Serebrennikov Date: Thu, 25 Sep 2003 21:50:11 +0000 Subject: [PATCH] Added a method used in test cases to determine if a file descriptor is closed. Added troubleshooting code (commented out) to help diagnose problems around openning and closing files. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150066 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/store/FSDirectory.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/java/org/apache/lucene/store/FSDirectory.java b/src/java/org/apache/lucene/store/FSDirectory.java index 37a488de8d1..22587f701b9 100644 --- a/src/java/org/apache/lucene/store/FSDirectory.java +++ b/src/java/org/apache/lucene/store/FSDirectory.java @@ -381,10 +381,34 @@ public final class FSDirectory extends Directory { final class FSInputStream extends InputStream { private class Descriptor extends RandomAccessFile { + /* DEBUG */ + //private String name; + /* DEBUG */ public long position; public Descriptor(File file, String mode) throws IOException { super(file, mode); + /* DEBUG */ + //name = file.toString(); + //debug_printInfo("OPEN"); + /* DEBUG */ } + + /* DEBUG */ + //public void close() throws IOException { + // debug_printInfo("CLOSE"); + // super.close(); + //} + // + //private void debug_printInfo(String op) { + // try { throw new Exception(op + " <" + name + ">"); + // } catch (Exception e) { + // java.io.StringWriter sw = new java.io.StringWriter(); + // java.io.PrintWriter pw = new java.io.PrintWriter(sw); + // e.printStackTrace(pw); + // System.out.println(sw.getBuffer().toString()); + // } + //} + /* DEBUG */ } Descriptor file = null; @@ -433,6 +457,13 @@ final class FSInputStream extends InputStream { clone.isClone = true; return clone; } + + /** Method used for testing. Returns true if the underlying + * file descriptor is valid. + */ + boolean isFDValid() throws IOException { + return file.getFD().valid(); + } }