|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _TestHelper | Line # 8 | 8 | 5 | 46.7% |
0.46666667
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (1) | |||
| Result | |||
|
0.46666667
|
org.apache.lucene.index.TestCompoundFile.testClonedStreamsClosing
org.apache.lucene.index.TestCompoundFile.testClonedStreamsClosing
|
1 PASS | |
| 1 | package org.apache.lucene.store; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | ||
| 5 | /** This class provides access to package-level features defined in the | |
| 6 | * store package. It is used for testing only. | |
| 7 | */ | |
| 8 | public class _TestHelper { | |
| 9 | ||
| 10 | /** Returns true if the instance of the provided input stream is actually | |
| 11 | * an FSIndexInput. | |
| 12 | */ | |
| 13 | 7 |
public static boolean isFSIndexInput(IndexInput is) { |
| 14 | 7 | return is instanceof FSIndexInput; |
| 15 | } | |
| 16 | ||
| 17 | /** Returns true if the provided input stream is an FSIndexInput and | |
| 18 | * is a clone, that is it does not own its underlying file descriptor. | |
| 19 | */ | |
| 20 | 0 |
public static boolean isFSIndexInputClone(IndexInput is) { |
| 21 | 0 | if (isFSIndexInput(is)) { |
| 22 | 0 | return ((FSIndexInput) is).isClone; |
| 23 | } else { | |
| 24 | 0 | return false; |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | /** Given an instance of FSDirectory.FSIndexInput, this method returns | |
| 29 | * true if the underlying file descriptor is valid, and false otherwise. | |
| 30 | * This can be used to determine if the OS file has been closed. | |
| 31 | * The descriptor becomes invalid when the non-clone instance of the | |
| 32 | * FSIndexInput that owns this descriptor is closed. However, the | |
| 33 | * descriptor may possibly become invalid in other ways as well. | |
| 34 | */ | |
| 35 | 6 |
public static boolean isFSIndexInputOpen(IndexInput is) |
| 36 | throws IOException | |
| 37 | { | |
| 38 | 6 | if (isFSIndexInput(is)) { |
| 39 | 6 | FSIndexInput fis = (FSIndexInput) is; |
| 40 | 6 | return fis.isFDValid(); |
| 41 | } else { | |
| 42 | 0 | return false; |
| 43 | } | |
| 44 | } | |
| 45 | ||
| 46 | } | |
|
||||||||||