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