提交 e08bf7a4 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Formatting

上级 7fefdea5
......@@ -815,7 +815,10 @@ public class Session extends SessionWithState {
if (!closed) {
try {
database.checkPowerOff();
rollback(); // release any open table locks
// release any open table locks
rollback();
removeTemporaryLobs(false);
cleanTempTables(true);
undoLog.clear();
......
......@@ -259,7 +259,7 @@ public class CompareLike extends Condition {
if (regexp) {
result = patternRegexp.matcher(value).find();
} else if (shortcutToStartsWith) {
result = value.regionMatches(ignoreCase, 0, patternString, 0, patternLength-1);
result = value.regionMatches(ignoreCase, 0, patternString, 0, patternLength - 1);
} else {
result = compareAt(value, 0, 0, value.length(), patternChars, patternTypes);
}
......@@ -388,7 +388,7 @@ public class CompareLike extends Condition {
while (maxMatch < patternLength && patternTypes[maxMatch] == MATCH) {
maxMatch++;
}
if (maxMatch == patternLength - 1 && patternTypes[patternLength-1] == ANY) {
if (maxMatch == patternLength - 1 && patternTypes[patternLength - 1] == ANY) {
shortcutToStartsWith = true;
}
}
......
......@@ -167,23 +167,22 @@ public class CipherFactory {
* Removes DH_anon and ECDH_anon from a comma separated list of ciphers.
* Only the first occurrence is removed.
* If there is nothing to remove, returns the reference to the argument.
* @param commaSepList a list of names separated by commas (and spaces)
* @param list a list of names separated by commas (and spaces)
* @return a new string without DH_anon and ECDH_anon items,
* or the original if none were found
*/
public static String removeDhAnonFromCommaSepList(String commaSepList) {
if (commaSepList == null) {
return commaSepList;
public static String removeDhAnonFromCommaSeparatedList(String list) {
if (list == null) {
return list;
}
List<String> algos = new LinkedList<String>(Arrays.asList(commaSepList.split("\\s*,\\s*")));
List<String> algos = new LinkedList<String>(Arrays.asList(list.split("\\s*,\\s*")));
boolean dhAnonRemoved = algos.remove("DH_anon");
boolean ecdhAnonRemoved = algos.remove("ECDH_anon");
if (dhAnonRemoved || ecdhAnonRemoved) {
String algosStr = Arrays.toString(algos.toArray(new String[algos.size()]));
return (algos.size() > 0) ? algosStr.substring(1, algosStr.length() - 1): "";
} else {
return commaSepList;
}
return list;
}
/**
......@@ -206,7 +205,7 @@ public class CipherFactory {
if (legacyAlgosOrig == null) {
return;
}
String legacyAlgosNew = removeDhAnonFromCommaSepList(legacyAlgosOrig);
String legacyAlgosNew = removeDhAnonFromCommaSeparatedList(legacyAlgosOrig);
if (!legacyAlgosOrig.equals(legacyAlgosNew)) {
setLegacyAlgorithmsSilently(legacyAlgosNew);
}
......
......@@ -553,6 +553,7 @@ public class Data {
writeVarInt(ts.getTimeZoneOffsetMins());
}
case Value.GEOMETRY:
// fall though
case Value.JAVA_OBJECT: {
writeByte((byte) type);
byte[] b = v.getBytesNoCopy();
......@@ -792,7 +793,7 @@ public class Data {
case Value.TIMESTAMP_TZ: {
long dateValue = readVarLong();
long nanos = readVarLong();
short tz = (short)readVarInt();
short tz = (short) readVarInt();
return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, nanos, tz);
}
case Value.BYTES: {
......
......@@ -298,7 +298,7 @@ public class Column {
} else if (dt.type == Value.TIMESTAMP_UTC) {
value = ValueTimestampUtc.fromMillis(session.getTransactionStart());
} else if (dt.type == Value.TIMESTAMP_TZ) {
value = ValueTimestampTimeZone.fromMillis(session.getTransactionStart(), (short)0);
value = ValueTimestampTimeZone.fromMillis(session.getTransactionStart(), (short) 0);
} else if (dt.type == Value.TIME) {
value = ValueTime.fromNanos(0);
} else if (dt.type == Value.DATE) {
......
......@@ -248,6 +248,7 @@ public abstract class Table extends SchemaObjectBase {
* @param filters the table filters
* @param filter the filter index
* @param sortOrder the sort order
* @param allColumnsSet all columns
* @return the scan index
*/
public Index getScanIndex(Session session, int[] masks,
......
......@@ -565,7 +565,7 @@ public class TableView extends Table {
return result + 1;
}
private int getMaxParameterIndex(ArrayList<Parameter> parameters) {
private static int getMaxParameterIndex(ArrayList<Parameter> parameters) {
int result = -1;
for (Parameter p : parameters) {
result = Math.max(result, p.getIndex());
......
......@@ -148,8 +148,9 @@ class ToDateTokenizer {
dateNr = Integer.parseInt(inputFragmentStr);
// Gregorian calendar does not have a year 0.
// 0 = 0001 BC, -1 = 0002 BC, ... so we adjust
if (dateNr==0)
if (dateNr == 0) {
throwException(params, "Year may not be zero");
}
result.set(Calendar.YEAR, dateNr >= 0 ? dateNr : dateNr + 1);
break;
case YYY:
......@@ -166,13 +167,15 @@ class ToDateTokenizer {
PATTERN_TWO_TO_FOUR_DIGITS, params, formatTokenEnum);
dateNr = Integer.parseInt(inputFragmentStr);
if (inputFragmentStr.length() < 4) {
if (dateNr < 50)
if (dateNr < 50) {
dateNr += 2000;
else if (dateNr < 100)
} else if (dateNr < 100) {
dateNr += 1900;
}
}
if (dateNr==0)
if (dateNr == 0) {
throwException(params, "Year may not be zero");
}
result.set(Calendar.YEAR, dateNr);
break;
case RR:
......
......@@ -58,7 +58,7 @@ public class ValueTimestampTimeZone extends Value {
if (timeNanos < 0 || timeNanos >= 24L * 60 * 60 * 1000 * 1000 * 1000) {
throw new IllegalArgumentException("timeNanos out of range " + timeNanos);
}
if (timeZoneOffsetMins < (-12*60) || timeZoneOffsetMins >= (12*60)) {
if (timeZoneOffsetMins < (-12 * 60) || timeZoneOffsetMins >= (12 * 60)) {
throw new IllegalArgumentException("timeZoneOffsetMins out of range " + timeZoneOffsetMins);
}
this.dateValue = dateValue;
......@@ -149,7 +149,7 @@ public class ValueTimestampTimeZone extends Value {
}
long dateValue = DateTimeUtils.parseDateValue(s, 0, dateEnd);
long nanos;
short tz_mins = 0;
short tzMinutes = 0;
if (timeStart < 0) {
nanos = 0;
} else {
......@@ -183,12 +183,12 @@ public class ValueTimestampTimeZone extends Value {
}
if (tz != null) {
long millis = DateTimeUtils.convertDateValueToDate(dateValue).getTime();
tz_mins = (short) (tz.getOffset(millis) / 1000 / 60);
tzMinutes = (short) (tz.getOffset(millis) / 1000 / 60);
}
}
nanos = DateTimeUtils.parseTimeNanos(s, dateEnd + 1, timeEnd, true);
}
return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, nanos, tz_mins);
return ValueTimestampTimeZone.fromDateValueAndNanos(dateValue, nanos, tzMinutes);
}
/**
......@@ -250,7 +250,7 @@ public class ValueTimestampTimeZone extends Value {
private static void appendTimeZone(StringBuilder buff, short tz) {
if (tz < 0) {
buff.append('-');
tz = (short)-tz;
tz = (short) -tz;
}
int hours = tz / 60;
tz -= hours * 60;
......
......@@ -1413,15 +1413,15 @@ public class TestFunctions extends TestBase implements AggregateFunction {
SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd");
assertEquals(ymd.parse("0001-03-01"), ToDateParser.toDate("1-MAR-0001","DD-MON-RRRR"));
assertEquals(ymd.parse("9999-03-01"), ToDateParser.toDate("1-MAR-9999","DD-MON-RRRR"));
assertEquals(ymd.parse("2000-03-01"), ToDateParser.toDate("1-MAR-000","DD-MON-RRRR"));
assertEquals(ymd.parse("1999-03-01"), ToDateParser.toDate("1-MAR-099","DD-MON-RRRR"));
assertEquals(ymd.parse("0100-03-01"), ToDateParser.toDate("1-MAR-100","DD-MON-RRRR"));
assertEquals(ymd.parse("2000-03-01"), ToDateParser.toDate("1-MAR-00","DD-MON-RRRR"));
assertEquals(ymd.parse("2049-03-01"), ToDateParser.toDate("1-MAR-49","DD-MON-RRRR"));
assertEquals(ymd.parse("1950-03-01"), ToDateParser.toDate("1-MAR-50","DD-MON-RRRR"));
assertEquals(ymd.parse("1999-03-01"), ToDateParser.toDate("1-MAR-99","DD-MON-RRRR"));
assertEquals(ymd.parse("0001-03-01"), ToDateParser.toDate("1-MAR-0001", "DD-MON-RRRR"));
assertEquals(ymd.parse("9999-03-01"), ToDateParser.toDate("1-MAR-9999", "DD-MON-RRRR"));
assertEquals(ymd.parse("2000-03-01"), ToDateParser.toDate("1-MAR-000", "DD-MON-RRRR"));
assertEquals(ymd.parse("1999-03-01"), ToDateParser.toDate("1-MAR-099", "DD-MON-RRRR"));
assertEquals(ymd.parse("0100-03-01"), ToDateParser.toDate("1-MAR-100", "DD-MON-RRRR"));
assertEquals(ymd.parse("2000-03-01"), ToDateParser.toDate("1-MAR-00", "DD-MON-RRRR"));
assertEquals(ymd.parse("2049-03-01"), ToDateParser.toDate("1-MAR-49", "DD-MON-RRRR"));
assertEquals(ymd.parse("1950-03-01"), ToDateParser.toDate("1-MAR-50", "DD-MON-RRRR"));
assertEquals(ymd.parse("1999-03-01"), ToDateParser.toDate("1-MAR-99", "DD-MON-RRRR"));
}
private static void setMonth(Date date, int month) {
......
......@@ -262,15 +262,15 @@ public class TestSecurity extends TestBase {
", DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, DH_RSA_EXPORT, RSA_EXPORT" +
", RC4_128, RC4_40, DES_CBC, DES40_CBC";
assertEquals(expectedLegacyAlgosWithoutDhAnon,
CipherFactory.removeDhAnonFromCommaSepList(legacyAlgos));
CipherFactory.removeDhAnonFromCommaSeparatedList(legacyAlgos));
legacyAlgos = "ECDH_anon, DH_anon_EXPORT, DH_anon";
expectedLegacyAlgosWithoutDhAnon = "DH_anon_EXPORT";
assertEquals(expectedLegacyAlgosWithoutDhAnon,
CipherFactory.removeDhAnonFromCommaSepList(legacyAlgos));
CipherFactory.removeDhAnonFromCommaSeparatedList(legacyAlgos));
legacyAlgos = null;
assertNull(CipherFactory.removeDhAnonFromCommaSepList(legacyAlgos));
assertNull(CipherFactory.removeDhAnonFromCommaSeparatedList(legacyAlgos));
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论