提交 162c96c0 authored 作者: Thomas Mueller's avatar Thomas Mueller

Enable warning for 'Local variable declaration hides another field or variable'.

上级 dffedce8
...@@ -130,16 +130,16 @@ public class LocalResult implements ResultInterface { ...@@ -130,16 +130,16 @@ public class LocalResult implements ResultInterface {
* Create a shallow copy of the result set. The data and a temporary table * Create a shallow copy of the result set. The data and a temporary table
* (if there is any) is not copied. * (if there is any) is not copied.
* *
* @param session the session * @param targetSession the session of the copy
* @return the copy * @return the copy
*/ */
public LocalResult createShallowCopy(Session session) { public LocalResult createShallowCopy(Session targetSession) {
if (disk == null && (rows == null || rows.size() < rowCount)) { if (disk == null && (rows == null || rows.size() < rowCount)) {
return null; return null;
} }
LocalResult copy = new LocalResult(); LocalResult copy = new LocalResult();
copy.maxMemoryRows = this.maxMemoryRows; copy.maxMemoryRows = this.maxMemoryRows;
copy.session = session; copy.session = targetSession;
copy.visibleColumnCount = this.visibleColumnCount; copy.visibleColumnCount = this.visibleColumnCount;
copy.expressions = this.expressions; copy.expressions = this.expressions;
copy.rowId = -1; copy.rowId = -1;
......
...@@ -29,6 +29,7 @@ import org.h2.value.ValueArray; ...@@ -29,6 +29,7 @@ import org.h2.value.ValueArray;
* This class implements the temp table buffer for the LocalResult class. * This class implements the temp table buffer for the LocalResult class.
*/ */
public class ResultTempTable implements ResultExternal { public class ResultTempTable implements ResultExternal {
private static final String COLUMN_NAME = "DATA"; private static final String COLUMN_NAME = "DATA";
private Session session; private Session session;
private TableData table; private TableData table;
......
...@@ -174,7 +174,7 @@ public class RowList { ...@@ -174,7 +174,7 @@ public class RowList {
if (buff.readByte() == 0) { if (buff.readByte() == 0) {
return null; return null;
} }
int memory = buff.readInt(); int mem = buff.readInt();
int columnCount = buff.readInt(); int columnCount = buff.readInt();
long key = buff.readLong(); long key = buff.readLong();
int version = buff.readInt(); int version = buff.readInt();
...@@ -208,7 +208,7 @@ public class RowList { ...@@ -208,7 +208,7 @@ public class RowList {
return (Row) found; return (Row) found;
} }
} }
Row row = new Row(values, memory); Row row = new Row(values, mem);
row.setKey(key); row.setKey(key);
row.setVersion(version); row.setVersion(version);
row.setDeleted(deleted); row.setDeleted(deleted);
......
...@@ -18,14 +18,14 @@ public abstract class SchemaObjectBase extends DbObjectBase implements SchemaObj ...@@ -18,14 +18,14 @@ public abstract class SchemaObjectBase extends DbObjectBase implements SchemaObj
/** /**
* Initialize some attributes of this object. * Initialize some attributes of this object.
* *
* @param schema the schema * @param newSchema the schema
* @param id the object id * @param id the object id
* @param name the name * @param name the name
* @param traceModule the trace module name * @param traceModule the trace module name
*/ */
protected void initSchemaObjectBase(Schema schema, int id, String name, String traceModule) { protected void initSchemaObjectBase(Schema newSchema, int id, String name, String traceModule) {
initDbObjectBase(schema.getDatabase(), id, name, traceModule); initDbObjectBase(newSchema.getDatabase(), id, name, traceModule);
this.schema = schema; this.schema = newSchema;
} }
public Schema getSchema() { public Schema getSchema() {
......
...@@ -256,7 +256,7 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -256,7 +256,7 @@ public class TriggerObject extends SchemaObjectBase {
return null; return null;
} }
public String getCreateSQLForCopy(Table table, String quotedName) { public String getCreateSQLForCopy(Table targetTable, String quotedName) {
StringBuilder buff = new StringBuilder("CREATE FORCE TRIGGER "); StringBuilder buff = new StringBuilder("CREATE FORCE TRIGGER ");
buff.append(quotedName); buff.append(quotedName);
if (before) { if (before) {
...@@ -265,7 +265,7 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -265,7 +265,7 @@ public class TriggerObject extends SchemaObjectBase {
buff.append(" AFTER "); buff.append(" AFTER ");
} }
buff.append(getTypeNameList()); buff.append(getTypeNameList());
buff.append(" ON ").append(table.getSQL()); buff.append(" ON ").append(targetTable.getSQL());
if (rowBased) { if (rowBased) {
buff.append(" FOR EACH ROW"); buff.append(" FOR EACH ROW");
} }
......
...@@ -104,11 +104,11 @@ public class SecureFileStore extends FileStore { ...@@ -104,11 +104,11 @@ public class SecureFileStore extends FileStore {
} }
} }
private void xorInitVector(byte[] b, int off, int len, long pos) { private void xorInitVector(byte[] b, int off, int len, long p) {
byte[] iv = bufferForInitVector; byte[] iv = bufferForInitVector;
while (len > 0) { while (len > 0) {
for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i += 8) { for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i += 8) {
long block = (pos + i) >>> 3; long block = (p + i) >>> 3;
iv[i] = (byte) (block >> 56); iv[i] = (byte) (block >> 56);
iv[i + 1] = (byte) (block >> 48); iv[i + 1] = (byte) (block >> 48);
iv[i + 2] = (byte) (block >> 40); iv[i + 2] = (byte) (block >> 40);
...@@ -122,7 +122,7 @@ public class SecureFileStore extends FileStore { ...@@ -122,7 +122,7 @@ public class SecureFileStore extends FileStore {
for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i++) { for (int i = 0; i < Constants.FILE_BLOCK_SIZE; i++) {
b[off + i] ^= iv[i]; b[off + i] ^= iv[i];
} }
pos += Constants.FILE_BLOCK_SIZE; p += Constants.FILE_BLOCK_SIZE;
off += Constants.FILE_BLOCK_SIZE; off += Constants.FILE_BLOCK_SIZE;
len -= Constants.FILE_BLOCK_SIZE; len -= Constants.FILE_BLOCK_SIZE;
} }
......
...@@ -43,13 +43,13 @@ public class TcpServerThread implements Runnable { ...@@ -43,13 +43,13 @@ public class TcpServerThread implements Runnable {
private Transfer transfer; private Transfer transfer;
private Command commit; private Command commit;
private SmallMap cache = new SmallMap(SysProperties.SERVER_CACHED_OBJECTS); private SmallMap cache = new SmallMap(SysProperties.SERVER_CACHED_OBJECTS);
private int id; private int threadId;
private int clientVersion; private int clientVersion;
private String sessionId; private String sessionId;
TcpServerThread(Socket socket, TcpServer server, int id) { TcpServerThread(Socket socket, TcpServer server, int id) {
this.server = server; this.server = server;
this.id = id; this.threadId = id;
transfer = new Transfer(null); transfer = new Transfer(null);
transfer.setSocket(socket); transfer.setSocket(socket);
} }
...@@ -80,17 +80,17 @@ public class TcpServerThread implements Runnable { ...@@ -80,17 +80,17 @@ public class TcpServerThread implements Runnable {
String db = transfer.readString(); String db = transfer.readString();
String originalURL = transfer.readString(); String originalURL = transfer.readString();
if (db == null && originalURL == null) { if (db == null && originalURL == null) {
String sessionId = transfer.readString(); String targetSessionId = transfer.readString();
int command = transfer.readInt(); int command = transfer.readInt();
stop = true; stop = true;
if (command == SessionRemote.SESSION_CANCEL_STATEMENT) { if (command == SessionRemote.SESSION_CANCEL_STATEMENT) {
// cancel a running statement // cancel a running statement
int statementId = transfer.readInt(); int statementId = transfer.readInt();
server.cancelStatement(sessionId, statementId); server.cancelStatement(targetSessionId, statementId);
} else if (command == SessionRemote.SESSION_CHECK_KEY) { } else if (command == SessionRemote.SESSION_CHECK_KEY) {
// check if this is the correct server // check if this is the correct server
db = server.checkKeyAndGetDatabaseName(sessionId); db = server.checkKeyAndGetDatabaseName(targetSessionId);
if (!sessionId.equals(db)) { if (!targetSessionId.equals(db)) {
transfer.writeInt(SessionRemote.STATUS_OK); transfer.writeInt(SessionRemote.STATUS_OK);
} else { } else {
transfer.writeInt(SessionRemote.STATUS_ERROR); transfer.writeInt(SessionRemote.STATUS_ERROR);
...@@ -126,7 +126,7 @@ public class TcpServerThread implements Runnable { ...@@ -126,7 +126,7 @@ public class TcpServerThread implements Runnable {
transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_6); transfer.writeInt(Constants.TCP_PROTOCOL_VERSION_6);
} }
transfer.flush(); transfer.flush();
server.addConnection(id, originalURL, ci.getUserName()); server.addConnection(threadId, originalURL, ci.getUserName());
trace("Connected"); trace("Connected");
} catch (Throwable e) { } catch (Throwable e) {
sendError(e); sendError(e);
...@@ -157,7 +157,7 @@ public class TcpServerThread implements Runnable { ...@@ -157,7 +157,7 @@ public class TcpServerThread implements Runnable {
} }
try { try {
session.close(); session.close();
server.removeConnection(id); server.removeConnection(threadId);
} catch (Exception e) { } catch (Exception e) {
server.traceError(e); server.traceError(e);
} finally { } finally {
...@@ -398,11 +398,11 @@ public class TcpServerThread implements Runnable { ...@@ -398,11 +398,11 @@ public class TcpServerThread implements Runnable {
/** /**
* Cancel a running statement. * Cancel a running statement.
* *
* @param sessionId the session id * @param targetSessionId the session id
* @param statementId the statement to cancel * @param statementId the statement to cancel
*/ */
void cancelStatement(String sessionId, int statementId) throws SQLException { void cancelStatement(String targetSessionId, int statementId) throws SQLException {
if (StringUtils.equals(sessionId, this.sessionId)) { if (StringUtils.equals(targetSessionId, this.sessionId)) {
Command cmd = (Command) cache.getObject(statementId, false); Command cmd = (Command) cache.getObject(statementId, false);
cmd.cancel(); cmd.cancel();
} }
......
...@@ -63,7 +63,7 @@ public class PgServerThread implements Runnable { ...@@ -63,7 +63,7 @@ public class PgServerThread implements Runnable {
private String dateStyle = "ISO"; private String dateStyle = "ISO";
private HashMap<String, Prepared> prepared = New.hashMap(); private HashMap<String, Prepared> prepared = New.hashMap();
private HashMap<String, Portal> portals = New.hashMap(); private HashMap<String, Portal> portals = New.hashMap();
private HashSet<Integer> types = New.hashSet(); private HashSet<Integer> typeSet = New.hashSet();
PgServerThread(Socket socket, PgServer server) { PgServerThread(Socket socket, PgServer server) {
this.server = server; this.server = server;
...@@ -374,7 +374,7 @@ public class PgServerThread implements Runnable { ...@@ -374,7 +374,7 @@ public class PgServerThread implements Runnable {
} }
private void checkType(int type) { private void checkType(int type) {
if (types.contains(type)) { if (typeSet.contains(type)) {
server.trace("Unsupported type: " + type); server.trace("Unsupported type: " + type);
} }
} }
...@@ -618,7 +618,7 @@ public class PgServerThread implements Runnable { ...@@ -618,7 +618,7 @@ public class PgServerThread implements Runnable {
rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE"); rs = stat.executeQuery("SELECT OID FROM PG_CATALOG.PG_TYPE");
while (rs.next()) { while (rs.next()) {
types.add(rs.getInt(1)); typeSet.add(rs.getInt(1));
} }
} finally { } finally {
JdbcUtils.closeSilently(stat); JdbcUtils.closeSilently(stat);
...@@ -717,8 +717,8 @@ public class PgServerThread implements Runnable { ...@@ -717,8 +717,8 @@ public class PgServerThread implements Runnable {
dataOut.write(b); dataOut.write(b);
} }
private void startMessage(int messageType) { private void startMessage(int newMessageType) {
this.messageType = messageType; this.messageType = newMessageType;
outBuffer = new ByteArrayOutputStream(); outBuffer = new ByteArrayOutputStream();
dataOut = new DataOutputStream(outBuffer); dataOut = new DataOutputStream(outBuffer);
} }
......
...@@ -157,7 +157,7 @@ public class DbContents { ...@@ -157,7 +157,7 @@ public class DbContents {
return new String[] { null }; return new String[] { null };
} }
ResultSet rs = meta.getSchemas(); ResultSet rs = meta.getSchemas();
ArrayList<String> schemas = New.arrayList(); ArrayList<String> schemaList = New.arrayList();
while (rs.next()) { while (rs.next()) {
String schema = rs.getString(findColumn(rs, "TABLE_SCHEM", 1)); String schema = rs.getString(findColumn(rs, "TABLE_SCHEM", 1));
if (isOracle) { if (isOracle) {
...@@ -175,11 +175,11 @@ public class DbContents { ...@@ -175,11 +175,11 @@ public class DbContents {
if (schema == null) { if (schema == null) {
continue; continue;
} }
schemas.add(schema); schemaList.add(schema);
} }
rs.close(); rs.close();
String[] list = new String[schemas.size()]; String[] list = new String[schemaList.size()];
schemas.toArray(list); schemaList.toArray(list);
return list; return list;
} }
......
...@@ -790,23 +790,23 @@ public class WebApp implements DatabaseEventListener { ...@@ -790,23 +790,23 @@ public class WebApp implements DatabaseEventListener {
boolean isH2 = url.startsWith("jdbc:h2:"); boolean isH2 = url.startsWith("jdbc:h2:");
try { try {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
String profileOpen = "", profileClose = ""; String profOpen = "", profClose = "";
Profiler profiler = new Profiler(); Profiler prof = new Profiler();
profiler.startCollecting(); prof.startCollecting();
Connection conn; Connection conn;
try { try {
conn = server.getConnection(driver, url, user, password, this); conn = server.getConnection(driver, url, user, password, this);
} finally { } finally {
profiler.stopCollecting(); prof.stopCollecting();
profileOpen = profiler.getTop(3); profOpen = prof.getTop(3);
} }
profiler = new Profiler(); prof = new Profiler();
profiler.startCollecting(); prof.startCollecting();
try { try {
JdbcUtils.closeSilently(conn); JdbcUtils.closeSilently(conn);
} finally { } finally {
profiler.stopCollecting(); prof.stopCollecting();
profileClose = profiler.getTop(3); profClose = prof.getTop(3);
} }
long time = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
String success; String success;
...@@ -814,9 +814,9 @@ public class WebApp implements DatabaseEventListener { ...@@ -814,9 +814,9 @@ public class WebApp implements DatabaseEventListener {
success = "<a class=\"error\" href=\"#\" onclick=\"var x=document.getElementById('prof').style;x.display=x.display==''?'none':'';\">" + success = "<a class=\"error\" href=\"#\" onclick=\"var x=document.getElementById('prof').style;x.display=x.display==''?'none':'';\">" +
"${text.login.testSuccessful}</a>" + "${text.login.testSuccessful}</a>" +
"<span style=\"display: none;\" id=\"prof\"><br />" + "<span style=\"display: none;\" id=\"prof\"><br />" +
PageParser.escapeHtml(profileOpen) + PageParser.escapeHtml(profOpen) +
"<br />" + "<br />" +
PageParser.escapeHtml(profileClose) + PageParser.escapeHtml(profClose) +
"</span>"; "</span>";
} else { } else {
success = "${text.login.testSuccessful}"; success = "${text.login.testSuccessful}";
......
...@@ -595,30 +595,30 @@ public class WebServer implements Service { ...@@ -595,30 +595,30 @@ public class WebServer implements Service {
* Open a database connection. * Open a database connection.
* *
* @param driver the driver class name * @param driver the driver class name
* @param url the database URL * @param databaseUrl the database URL
* @param user the user name * @param user the user name
* @param password the password * @param password the password
* @param listener the database event listener object * @param listener the database event listener object
* @return the database connection * @return the database connection
*/ */
Connection getConnection(String driver, String url, String user, String password, DatabaseEventListener listener) throws SQLException { Connection getConnection(String driver, String databaseUrl, String user, String password, DatabaseEventListener listener) throws SQLException {
driver = driver.trim(); driver = driver.trim();
url = url.trim(); databaseUrl = databaseUrl.trim();
org.h2.Driver.load(); org.h2.Driver.load();
Properties p = new Properties(); Properties p = new Properties();
p.setProperty("user", user.trim()); p.setProperty("user", user.trim());
// do not trim the password, otherwise an // do not trim the password, otherwise an
// encrypted H2 database with empty user password doesn't work // encrypted H2 database with empty user password doesn't work
p.setProperty("password", password); p.setProperty("password", password);
if (url.startsWith("jdbc:h2:")) { if (databaseUrl.startsWith("jdbc:h2:")) {
if (ifExists) { if (ifExists) {
url += ";IFEXISTS=TRUE"; databaseUrl += ";IFEXISTS=TRUE";
} }
p.put("DATABASE_EVENT_LISTENER_OBJECT", listener); p.put("DATABASE_EVENT_LISTENER_OBJECT", listener);
// PostgreSQL would throw a NullPointerException // PostgreSQL would throw a NullPointerException
// if it is loaded before the H2 driver // if it is loaded before the H2 driver
// because it can't deal with non-String objects in the connection Properties // because it can't deal with non-String objects in the connection Properties
return org.h2.Driver.load().connect(url, p); return org.h2.Driver.load().connect(databaseUrl, p);
} }
// try { // try {
// Driver dr = (Driver) urlClassLoader. // Driver dr = (Driver) urlClassLoader.
...@@ -627,7 +627,7 @@ public class WebServer implements Service { ...@@ -627,7 +627,7 @@ public class WebServer implements Service {
// } catch(ClassNotFoundException e2) { // } catch(ClassNotFoundException e2) {
// throw e2; // throw e2;
// } // }
return JdbcUtils.getConnection(driver, url, p); return JdbcUtils.getConnection(driver, databaseUrl, p);
} }
/** /**
......
...@@ -328,8 +328,8 @@ class WebThread extends WebApp implements Runnable { ...@@ -328,8 +328,8 @@ class WebThread extends WebApp implements Runnable {
server.traceError(e); server.traceError(e);
} }
public void init(String url) { public void init(String databaseUrl) {
log("Init: " + PageParser.escapeHtml(url)); log("Init: " + PageParser.escapeHtml(databaseUrl));
} }
public void opened() { public void opened() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论