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

Fix Eclipse 3.5 warnings

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