mirror of
https://github.com/apache/lucene.git
synced 2025-02-21 17:46:28 +00:00
- Added a missing RuntimeException throw.
- s/\t/ /g git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24fa693cff
commit
ef7ff202fe
@ -117,8 +117,8 @@ public final class FSDirectory extends Directory {
|
|||||||
synchronized (DIRECTORIES) {
|
synchronized (DIRECTORIES) {
|
||||||
dir = (FSDirectory)DIRECTORIES.get(file);
|
dir = (FSDirectory)DIRECTORIES.get(file);
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
dir = new FSDirectory(file, create);
|
dir = new FSDirectory(file, create);
|
||||||
DIRECTORIES.put(file, dir);
|
DIRECTORIES.put(file, dir);
|
||||||
} else if (create) {
|
} else if (create) {
|
||||||
dir.create();
|
dir.create();
|
||||||
}
|
}
|
||||||
@ -144,8 +144,8 @@ public final class FSDirectory extends Directory {
|
|||||||
|
|
||||||
private synchronized void create() throws IOException {
|
private synchronized void create() throws IOException {
|
||||||
if (!directory.exists())
|
if (!directory.exists())
|
||||||
if (!directory.mkdir())
|
if (!directory.mkdir())
|
||||||
throw new IOException("Cannot create directory: " + directory);
|
throw new IOException("Cannot create directory: " + directory);
|
||||||
|
|
||||||
String[] files = directory.list(); // clear old files
|
String[] files = directory.list(); // clear old files
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
@ -210,7 +210,7 @@ public final class FSDirectory extends Directory {
|
|||||||
|
|
||||||
if (nu.exists())
|
if (nu.exists())
|
||||||
if (!nu.delete())
|
if (!nu.delete())
|
||||||
throw new IOException("couldn't delete " + to);
|
throw new IOException("couldn't delete " + to);
|
||||||
|
|
||||||
// Rename the old file to the new one. Unfortunately, the renameTo()
|
// Rename the old file to the new one. Unfortunately, the renameTo()
|
||||||
// method does not work reliably under some JVMs. Therefore, if the
|
// method does not work reliably under some JVMs. Therefore, if the
|
||||||
@ -229,7 +229,7 @@ public final class FSDirectory extends Directory {
|
|||||||
}
|
}
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buffer)) >= 0) {
|
while ((len = in.read(buffer)) >= 0) {
|
||||||
out.write(buffer, 0, len);
|
out.write(buffer, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the old file.
|
// delete the old file.
|
||||||
@ -239,19 +239,19 @@ public final class FSDirectory extends Directory {
|
|||||||
throw new IOException("couldn't rename " + from + " to " + to);
|
throw new IOException("couldn't rename " + from + " to " + to);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// what can we do?
|
throw new RuntimeException("could not close input stream", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("could not close output stream", e);
|
throw new RuntimeException("could not close output stream", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,27 +282,27 @@ public final class FSDirectory extends Directory {
|
|||||||
public final Lock makeLock(String name) {
|
public final Lock makeLock(String name) {
|
||||||
final File lockFile = new File(directory, name);
|
final File lockFile = new File(directory, name);
|
||||||
return new Lock() {
|
return new Lock() {
|
||||||
public boolean obtain() throws IOException {
|
public boolean obtain() throws IOException {
|
||||||
if (DISABLE_LOCKS)
|
if (DISABLE_LOCKS)
|
||||||
return true;
|
return true;
|
||||||
return lockFile.createNewFile();
|
return lockFile.createNewFile();
|
||||||
}
|
}
|
||||||
public void release() {
|
public void release() {
|
||||||
if (DISABLE_LOCKS)
|
if (DISABLE_LOCKS)
|
||||||
return;
|
return;
|
||||||
lockFile.delete();
|
lockFile.delete();
|
||||||
}
|
}
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Lock@" + lockFile;
|
return "Lock@" + lockFile;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Closes the store to future operations. */
|
/** Closes the store to future operations. */
|
||||||
public final synchronized void close() throws IOException {
|
public final synchronized void close() throws IOException {
|
||||||
if (--refCount <= 0) {
|
if (--refCount <= 0) {
|
||||||
synchronized (DIRECTORIES) {
|
synchronized (DIRECTORIES) {
|
||||||
DIRECTORIES.remove(directory);
|
DIRECTORIES.remove(directory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,16 +336,16 @@ final class FSInputStream extends InputStream {
|
|||||||
synchronized (file) {
|
synchronized (file) {
|
||||||
long position = getFilePointer();
|
long position = getFilePointer();
|
||||||
if (position != file.position) {
|
if (position != file.position) {
|
||||||
file.seek(position);
|
file.seek(position);
|
||||||
file.position = position;
|
file.position = position;
|
||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
do {
|
do {
|
||||||
int i = file.read(b, offset+total, len-total);
|
int i = file.read(b, offset+total, len-total);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
throw new IOException("read past EOF");
|
throw new IOException("read past EOF");
|
||||||
file.position += i;
|
file.position += i;
|
||||||
total += i;
|
total += i;
|
||||||
} while (total < len);
|
} while (total < len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ final class FSInputStream extends InputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final void finalize() throws IOException {
|
protected final void finalize() throws IOException {
|
||||||
close(); // close the file
|
close(); // close the file
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
@ -397,7 +397,7 @@ final class FSOutputStream extends OutputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final void finalize() throws IOException {
|
protected final void finalize() throws IOException {
|
||||||
file.close(); // close the file
|
file.close(); // close the file
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user