提交 268c6620 authored 作者: Thomas Mueller's avatar Thomas Mueller

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

上级 2b2162f8
......@@ -136,12 +136,12 @@ public class Bnf {
/**
* Get the HTML railroad for a given syntax.
*
* @param syntax the syntax
* @param bnf the syntax
* @return the HTML formatted railroad
*/
public String getRailroadHtml(String syntax) {
syntax = StringUtils.replaceAll(syntax, "\n ", " ");
String[] syntaxList = StringUtils.arraySplit(syntax, '\n', true);
public String getRailroadHtml(String bnf) {
bnf = StringUtils.replaceAll(bnf, "\n ", " ");
String[] syntaxList = StringUtils.arraySplit(bnf, '\n', true);
StringBuilder buff = new StringBuilder();
for (String s : syntaxList) {
this.syntax = s;
......
......@@ -4283,8 +4283,8 @@ public class Parser {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName);
}
private Sequence findSequence(String schemaName, String sequenceName) throws SQLException {
Sequence sequence = database.getSchema(schemaName).findSequence(sequenceName);
private Sequence findSequence(String schema, String sequenceName) throws SQLException {
Sequence sequence = database.getSchema(schema).findSequence(sequenceName);
if (sequence != null) {
return sequence;
}
......
......@@ -322,15 +322,15 @@ public class ConstraintReferential extends Constraint {
int refIdx = refCol.getColumnId();
check.setValue(refIdx, refCol.convert(v));
}
if (!found(session, refIndex, check, null)) {
if (!existsRow(session, refIndex, check, null)) {
throw Message.getSQLException(ErrorCode.REFERENTIAL_INTEGRITY_VIOLATED_PARENT_MISSING_1,
getShortDescription());
}
}
private boolean found(Session session, Index searchIndex, SearchRow check, Row excluding) throws SQLException {
Table table = searchIndex.getTable();
table.lock(session, false, false);
private boolean existsRow(Session session, Index searchIndex, SearchRow check, Row excluding) throws SQLException {
Table searchTable = searchIndex.getTable();
searchTable.lock(session, false, false);
Cursor cursor = searchIndex.find(session, check, check);
while (cursor.next()) {
SearchRow found;
......@@ -344,7 +344,7 @@ public class ConstraintReferential extends Constraint {
int idx = cols[i].getColumnId();
Value c = check.getValue(idx);
Value f = found.getValue(idx);
if (table.compareTypeSave(c, f) != 0) {
if (searchTable.compareTypeSave(c, f) != 0) {
allEqual = false;
break;
}
......@@ -371,7 +371,7 @@ public class ConstraintReferential extends Constraint {
}
// exclude the row only for self-referencing constraints
Row excluding = (refTable == table) ? oldRow : null;
if (found(session, index, check, excluding)) {
if (existsRow(session, index, check, excluding)) {
throw Message.getSQLException(ErrorCode.REFERENTIAL_INTEGRITY_VIOLATED_CHILD_EXISTS_1,
getShortDescription());
}
......
......@@ -474,9 +474,9 @@ public class FullTextLucene extends FullText {
prep.setString(2, tableName);
rs = prep.executeQuery();
if (rs.next()) {
String columns = rs.getString(1);
if (columns != null) {
for (String s : StringUtils.arraySplit(columns, ',', true)) {
String cols = rs.getString(1);
if (cols != null) {
for (String s : StringUtils.arraySplit(cols, ',', true)) {
indexList.add(s);
}
}
......
......@@ -321,11 +321,11 @@ public abstract class BaseIndex extends SchemaObjectBase implements Index {
return buff.toString();
}
public String getCreateSQLForCopy(Table table, String quotedName) {
public String getCreateSQLForCopy(Table targetTable, String quotedName) {
StringBuilder buff = new StringBuilder("CREATE ");
buff.append(indexType.getSQL());
buff.append(' ').append(quotedName);
buff.append(" ON ").append(table.getSQL());
buff.append(" ON ").append(targetTable.getSQL());
if (comment != null) {
buff.append(" COMMENT ").append(StringUtils.quoteStringSQL(comment));
}
......
......@@ -98,7 +98,6 @@ public class PageBtreeIndex extends PageIndex {
PageBtree page1 = root;
PageBtree page2 = root.split(splitPoint);
store.logUndo(page2, null);
int rootPageId = root.getPos();
int id = store.allocatePage();
page1.setPageId(id);
page1.setParentPageId(rootPageId);
......
......@@ -127,11 +127,11 @@ abstract class PageData extends Page {
/**
* Get the key at this position.
*
* @param index the index
* @param at the index
* @return the key
*/
long getKey(int index) {
return keys[index];
long getKey(int at) {
return keys[at];
}
/**
......
......@@ -160,7 +160,6 @@ public class PageDataIndex extends PageIndex implements RowIndex {
long pivot = splitPoint == 0 ? row.getKey() : root.getKey(splitPoint - 1);
PageData page1 = root;
PageData page2 = root.split(splitPoint);
int rootPageId = root.getPos();
int id = store.allocatePage();
page1.setPageId(id);
page1.setParentPageId(rootPageId);
......
......@@ -423,8 +423,8 @@ public class PageDataLeaf extends PageData {
}
Row getRow(long key) throws SQLException {
int index = find(key);
return getRowAt(index);
int at = find(key);
return getRowAt(at);
}
int getRowCount() {
......
......@@ -24,8 +24,8 @@ public class PageDelegateIndex extends PageIndex {
private final PageDataIndex mainIndex;
public PageDelegateIndex(TableData table, int id, String name, IndexType indexType, PageDataIndex mainIndex, int headPos, Session session) throws SQLException {
IndexColumn[] columns = IndexColumn.wrap(new Column[] { table.getColumn(mainIndex.getMainIndexColumn())});
this.initBaseIndex(table, id, name, columns, indexType);
IndexColumn[] cols = IndexColumn.wrap(new Column[] { table.getColumn(mainIndex.getMainIndexColumn())});
this.initBaseIndex(table, id, name, cols, indexType);
this.mainIndex = mainIndex;
if (!database.isPersistent() || id < 0) {
throw Message.throwInternalError("" + name);
......
......@@ -61,7 +61,7 @@ import java.sql.SQLXML;
*/
public class JdbcPreparedStatement extends JdbcStatement implements PreparedStatement {
private final String sql;
private final String sqlStatement;
private CommandInterface command;
private ObjectArray<Value[]> batchParameters;
......@@ -69,7 +69,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
int resultSetConcurrency, boolean closeWithResultSet) throws SQLException {
super(conn, id, resultSetType, resultSetConcurrency, closeWithResultSet);
setTrace(session.getTrace(), TraceObject.PREPARED_STATEMENT, id);
this.sql = sql;
this.sqlStatement = sql;
command = conn.prepareCommand(sql, fetchSize);
}
......@@ -1495,7 +1495,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
if (super.checkClosed(write)) {
// if the session was re-connected, re-prepare the statement
ObjectArray< ? extends ParameterInterface> oldParams = command.getParameters();
command = conn.prepareCommand(sql, fetchSize);
command = conn.prepareCommand(sqlStatement, fetchSize);
ObjectArray< ? extends ParameterInterface> newParams = command.getParameters();
for (int i = 0; i < oldParams.size(); i++) {
ParameterInterface old = oldParams.get(i);
......
......@@ -74,8 +74,8 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
private transient JdbcDataSourceFactory factory;
private transient PrintWriter logWriter;
private int loginTimeout;
private String user = "";
private char[] password = new char[0];
private String userName = "";
private char[] passwordChars = new char[0];
private String url = "";
static {
......@@ -150,7 +150,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/
public Connection getConnection() throws SQLException {
debugCodeCall("getConnection");
return getJdbcConnection(user, StringUtils.cloneCharArray(password));
return getJdbcConnection(userName, StringUtils.cloneCharArray(passwordChars));
}
/**
......@@ -205,7 +205,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/
public void setPassword(String password) {
debugCodeCall("setPassword", "");
this.password = convertToCharArray(password);
this.passwordChars = convertToCharArray(password);
}
/**
......@@ -217,7 +217,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
if (isDebugEnabled()) {
debugCode("setPasswordChars(new char[0]);");
}
this.password = password;
this.passwordChars = password;
}
private char[] convertToCharArray(String s) {
......@@ -235,7 +235,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/
public String getPassword() {
debugCodeCall("getPassword");
return convertToString(password);
return convertToString(passwordChars);
}
/**
......@@ -245,7 +245,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/
public String getUser() {
debugCodeCall("getUser");
return user;
return userName;
}
/**
......@@ -255,7 +255,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
*/
public void setUser(String user) {
debugCodeCall("setUser", user);
this.user = user;
this.userName = user;
}
/**
......@@ -269,8 +269,8 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
String factoryClassName = JdbcDataSourceFactory.class.getName();
Reference ref = new Reference(getClass().getName(), factoryClassName, null);
ref.add(new StringRefAddr("url", url));
ref.add(new StringRefAddr("user", user));
ref.add(new StringRefAddr("password", convertToString(password)));
ref.add(new StringRefAddr("user", userName));
ref.add(new StringRefAddr("password", convertToString(passwordChars)));
ref.add(new StringRefAddr("loginTimeout", String.valueOf(loginTimeout)));
return ref;
}
......@@ -285,7 +285,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
public XAConnection getXAConnection() throws SQLException {
debugCodeCall("getXAConnection");
int id = getNextId(XA_DATA_SOURCE);
return new JdbcXAConnection(factory, id, url, user, password);
return new JdbcXAConnection(factory, id, url, userName, passwordChars);
}
//## Java 1.4 end ##
......@@ -362,7 +362,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
* INTERNAL
*/
public String toString() {
return getTraceObjectName() + ": url=" + url + " user=" + user;
return getTraceObjectName() + ": url=" + url + " user=" + userName;
}
}
......@@ -69,7 +69,7 @@ public class LogFile {
private byte[] buffer;
private ObjectArray<Record> unwritten;
private DataPage rowBuff;
private int pos = LogSystem.LOG_WRITTEN;
private int logPos = LogSystem.LOG_WRITTEN;
private int firstUncommittedPos = LogSystem.LOG_WRITTEN;
private int firstUnwrittenPos = LogSystem.LOG_WRITTEN;
......@@ -88,8 +88,8 @@ public class LogFile {
if (!log.getDatabase().isReadOnly()) {
writeHeader();
}
pos = getBlock();
firstUncommittedPos = pos;
logPos = getBlock();
firstUncommittedPos = logPos;
} catch (SQLException e) {
close(false);
throw e;
......@@ -167,12 +167,12 @@ public class LogFile {
if (buff.length() >= buffer.length) {
// special case really long write request: write it without buffering
file.write(buff.getBytes(), 0, buff.length());
pos = getBlock();
logPos = getBlock();
return;
}
System.arraycopy(buff.getBytes(), 0, buffer, bufferPos, buff.length());
bufferPos += buff.length();
pos = getBlock() + (bufferPos / BLOCK_SIZE);
logPos = getBlock() + (bufferPos / BLOCK_SIZE);
}
/**
......@@ -367,9 +367,9 @@ public class LogFile {
try {
int max = (int) (length / BLOCK_SIZE);
while (true) {
pos = getBlock();
database.setProgress(DatabaseEventListener.STATE_RECOVER, fileName, pos, max);
if ((long) pos * BLOCK_SIZE >= length) {
logPos = getBlock();
database.setProgress(DatabaseEventListener.STATE_RECOVER, fileName, logPos, max);
if ((long) logPos * BLOCK_SIZE >= length) {
break;
}
boolean more = redoOrUndo(false, readOnly);
......@@ -392,7 +392,7 @@ public class LogFile {
// on power loss, sometime there is garbage at the end of the file
// we stop recovering in this case (checksum mismatch)
}
go(pos);
go(logPos);
}
/**
......@@ -424,13 +424,13 @@ public class LogFile {
throw Message.getSQLException(ErrorCode.DATABASE_IS_CLOSED);
}
file.write(buffer, 0, bufferPos);
pos = getBlock();
logPos = getBlock();
for (Record r : unwritten) {
r.setLogWritten(id, pos);
r.setLogWritten(id, logPos);
}
unwritten.clear();
bufferPos = 0;
long min = (long) pos * BLOCK_SIZE;
long min = (long) logPos * BLOCK_SIZE;
min = MathUtils.scaleUp50Percent(Constants.FILE_MIN_SIZE, min, Constants.FILE_PAGE_SIZE, Constants.FILE_MAX_INCREMENT);
if (min > file.length()) {
file.setLength(min);
......@@ -598,7 +598,7 @@ public class LogFile {
}
int getPos() {
return pos;
return logPos;
}
long getFileSize() throws SQLException {
......
......@@ -102,7 +102,7 @@ public class Trace {
private TraceWriter traceWriter;
private String module;
private String lineSeparator;
private int level = TraceSystem.PARENT;
private int traceLevel = TraceSystem.PARENT;
Trace(TraceWriter traceWriter, String module) {
this.traceWriter = traceWriter;
......@@ -117,14 +117,14 @@ public class Trace {
* @param level the new level
*/
public void setLevel(int level) {
this.level = level;
this.traceLevel = level;
}
private boolean isEnabled(int level) {
if (this.level == TraceSystem.PARENT) {
if (this.traceLevel == TraceSystem.PARENT) {
return traceWriter.isEnabled(level);
}
return level <= this.level;
return level <= this.traceLevel;
}
/**
......
......@@ -114,7 +114,7 @@ public class TraceObject {
};
private Trace trace;
private int type;
private int traceType;
private int id;
/**
......@@ -126,7 +126,7 @@ public class TraceObject {
*/
protected void setTrace(Trace trace, int type, int id) {
this.trace = trace;
this.type = type;
this.traceType = type;
this.id = id;
}
......@@ -159,7 +159,7 @@ public class TraceObject {
* INTERNAL
*/
public String getTraceObjectName() {
return PREFIX[type] + id;
return PREFIX[traceType] + id;
}
/**
......@@ -195,13 +195,13 @@ public class TraceObject {
* className prefixId = objectName.value.
*
* @param className the class name of the result
* @param type the prefix type
* @param id the trace object id of the created object
* @param newType the prefix type
* @param newId the trace object id of the created object
* @param value the value to assign this new object to
*/
protected void debugCodeAssign(String className, int type, int id, String value) {
protected void debugCodeAssign(String className, int newType, int newId, String value) {
if (trace.isDebugEnabled()) {
trace.debugCode(className + " " + PREFIX[type] + id + " = " + getTraceObjectName() + "." + value + ";");
trace.debugCode(className + " " + PREFIX[newType] + newId + " = " + getTraceObjectName() + "." + value + ";");
}
}
......
......@@ -84,7 +84,7 @@ public class TraceSystem implements TraceWriter {
private int levelSystemOut = DEFAULT_TRACE_LEVEL_SYSTEM_OUT;
private int levelFile = DEFAULT_TRACE_LEVEL_FILE;
private int level;
private int levelMax;
private int maxFileSize = DEFAULT_MAX_FILE_SIZE;
private String fileName;
private SmallLRUCache<String, Trace> traces;
......@@ -109,7 +109,7 @@ public class TraceSystem implements TraceWriter {
}
private void updateLevel() {
level = Math.max(levelSystemOut, levelFile);
levelMax = Math.max(levelSystemOut, levelFile);
}
/**
......@@ -140,7 +140,7 @@ public class TraceSystem implements TraceWriter {
}
public boolean isEnabled(int level) {
return level <= this.level;
return level <= this.levelMax;
}
/**
......@@ -217,7 +217,7 @@ public class TraceSystem implements TraceWriter {
}
public void write(int level, String module, String s, Throwable t) {
if (level <= levelSystemOut || level > this.level) {
if (level <= levelSystemOut || level > this.levelMax) {
// level <= levelSystemOut: the system out level is set higher
// level > this.level: the level for this module is set higher
System.out.println(format(module, s));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论