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

Formatting

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