提交 a4afb494 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fix Eclipse 3.5 warnings

上级 383a7c09
......@@ -103,7 +103,7 @@ public class Restore extends Tool {
}
}
zipIn.close();
if (multiple && !originalDbName.equals(db)) {
if (multiple && !db.equals(originalDbName)) {
throw new IOException("Multiple databases found, but not " + db);
}
return originalDbName;
......@@ -141,6 +141,7 @@ public class Restore extends Tool {
throw new IOException("File not found: " + zipFileName);
}
String originalDbName = null;
int originalDbLen = 0;
if (db != null) {
originalDbName = getOriginalDbName(zipFileName, db);
if (originalDbName == null) {
......@@ -149,6 +150,7 @@ public class Restore extends Tool {
if (originalDbName.startsWith(File.separator)) {
originalDbName = originalDbName.substring(1);
}
originalDbLen = originalDbName.length();
}
in = FileUtils.openFileInputStream(zipFileName);
ZipInputStream zipIn = new ZipInputStream(in);
......@@ -168,7 +170,7 @@ public class Restore extends Tool {
if (db == null) {
copy = true;
} else if (fileName.startsWith(originalDbName + ".")) {
fileName = db + fileName.substring(originalDbName.length());
fileName = db + fileName.substring(originalDbLen);
copy = true;
}
if (copy) {
......
......@@ -91,7 +91,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* A simple array implementation,
* backed by an object array
*/
private static class SimpleArray implements Array {
public static class SimpleArray implements Array {
private Object[] value;
......
......@@ -77,14 +77,15 @@ public class StringCache {
int hash = s.hashCode();
String[] cache = getCache();
int index = hash & (SysProperties.OBJECT_CACHE_SIZE - 1);
if (cache != null) {
if (cache == null) {
return s;
}
String cached = cache[index];
if (cached != null) {
if (s.equals(cached)) {
return cached;
}
}
}
// create a new object that is not shared
// (to avoid out of memory if it is a substring of a big String)
// NOPMD
......
......@@ -133,7 +133,8 @@ public class Profile extends Thread {
return;
}
long now = System.currentTimeMillis();
if (TRACE && trace != null) {
if (TRACE) {
if (trace != null) {
int duration = (int) (now - lastTime);
try {
trace.write(i + "\t" + duration + "\r\n");
......@@ -142,6 +143,7 @@ public class Profile extends Thread {
System.exit(1);
}
}
}
count[i]++;
time[lastIndex] += (int) (now - lastTime);
lastTime = now;
......
......@@ -12,8 +12,6 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import org.h2.engine.Constants;
import org.h2.test.TestBase;
/**
......@@ -70,11 +68,7 @@ public class TestCompatibility extends TestBase {
Statement stat = conn.createStatement();
String[] modes = new String[] { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" };
String columnAlias;
if (Constants.VERSION_MINOR == 0) {
columnAlias = "MySQL";
} else {
columnAlias = "MySQL,Regular";
}
stat.execute("CREATE TABLE TEST(ID INT)");
for (String mode : modes) {
stat.execute("SET MODE " + mode);
......
......@@ -20,9 +20,9 @@ import org.h2.util.SortedProperties;
public class TestAutoServer extends TestBase {
/**
* If enabled, this flag allows to debug the test case.
* The number of iterations.
*/
static final boolean SLOW = false;
static final int ITERATIONS = 30;
/**
* Run just this test.
......@@ -42,7 +42,7 @@ public class TestAutoServer extends TestBase {
String user = getUser(), password = getPassword();
Connection connServer = getConnection(url + ";OPEN_NEW=TRUE", user, password);
int i = SLOW ? Integer.MAX_VALUE : 30;
int i = ITERATIONS;
for (; i > 0; i--) {
Thread.sleep(100);
SortedProperties prop = SortedProperties.loadProperties(baseDir + "/autoServer.lock.db");
......
......@@ -86,7 +86,7 @@ public class TestValueHashMap extends TestBase implements DataHandler {
case 2:
Value v1 = map.get(key);
Value v2 = hash.get(key);
assertTrue((v1 == null && v2 == null) || v1.compareEqual(v2));
assertTrue(v1 == null ? v2 == null : v1.compareEqual(v2));
break;
case 3: {
ObjectArray<Value> a1 = map.keys();
......
......@@ -22,6 +22,8 @@ import java.net.Socket;
*/
public class PgTcpRedirect {
private static final boolean DEBUG = false;
/**
* This method is called when executing this application from the command
* line.
......@@ -92,7 +94,7 @@ public class PgTcpRedirect {
}
private void println(String s) {
if (false) {
if (DEBUG) {
System.out.println(s);
}
}
......@@ -536,7 +538,7 @@ public class PgTcpRedirect {
* @param len the length
*/
synchronized void printData(byte[] buffer, int len) {
if (false) {
if (DEBUG) {
System.out.print(" ");
for (int i = 0; i < len; i++) {
int c = buffer[i] & 255;
......
......@@ -7,6 +7,7 @@
package org.h2.jaqu;
//## Java 1.5 begin ##
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
......@@ -165,10 +166,14 @@ public class Query<T> {
public <A> QueryWhere<T> where(Filter filter) {
// TODO decompile the filter and add conditions accordingly
// for (Field f : filter.getClass().getDeclaredFields()) {
// f.setAccessible(true);
// try { System.out.println(f.getName() + "=" + f.get(filter));
// } catch (Exception e) { } }
for (Field f : filter.getClass().getDeclaredFields()) {
f.setAccessible(true);
// try {
// System.out.println(f.getName() + "=" + f.get(filter));
// } catch (Exception e) {
// // convert
// }
}
return new QueryWhere<T>(this);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论