diff --git a/jOOQ/src/main/java/org/jooq/exception/DataAccessException.java b/jOOQ/src/main/java/org/jooq/exception/DataAccessException.java index 452201e531..f93e8967d1 100644 --- a/jOOQ/src/main/java/org/jooq/exception/DataAccessException.java +++ b/jOOQ/src/main/java/org/jooq/exception/DataAccessException.java @@ -55,11 +55,6 @@ public class DataAccessException extends RuntimeException { */ private static final long serialVersionUID = 491834858363345767L; - /** - * Never run infinite loops - */ - private static int maxCauseLookups = 256; - /** * Constructor for DataAccessException. * @@ -128,26 +123,7 @@ public class DataAccessException extends RuntimeException { * Find a root cause of a given type, or null if no root cause * of that type was found. */ - @SuppressWarnings("unchecked") public T getCause(Class type) { - Throwable next = getCause(); - Throwable prev; - - for (int i = 0; i < maxCauseLookups; i++) { - if (next == null) - return null; - - if (type.isInstance(next)) - return (T) next; - - prev = next; - next = next.getCause(); - - // Don't trust exceptions to respect the default behaviour of Throwable.getCause() - if (prev == next) - return null; - } - - return null; + return ExceptionTools.getCause(this, type); } } diff --git a/jOOQ/src/main/java/org/jooq/exception/ExceptionTools.java b/jOOQ/src/main/java/org/jooq/exception/ExceptionTools.java new file mode 100644 index 0000000000..ab37cd350b --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/exception/ExceptionTools.java @@ -0,0 +1,78 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.exception; + +/** + * @author Lukas Eder + */ +public final class ExceptionTools { + + /** + * Never run infinite loops + */ + private static int maxCauseLookups = 256; + + /** + * Find a root cause of a given type, or null if no root cause + * of that type was found. + */ + @SuppressWarnings("unchecked") + public static T getCause(Throwable t, Class type) { + Throwable next = t.getCause(); + Throwable prev; + + for (int i = 0; i < maxCauseLookups; i++) { + if (next == null) + return null; + + if (type.isInstance(next)) + return (T) next; + + prev = next; + next = next.getCause(); + + // Don't trust exceptions to respect the default behaviour of Throwable.getCause() + if (prev == next) + return null; + } + + return null; + } + + private ExceptionTools() {} +} diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index a617228e78..d4fd864b20 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -344,6 +344,7 @@ import org.jooq.Name; import org.jooq.OrderedAggregateFunction; import org.jooq.OrderedAggregateFunctionOfDeferredType; import org.jooq.Param; +import org.jooq.Parameter; import org.jooq.Parser; import org.jooq.Privilege; import org.jooq.QualifiedAsterisk; @@ -564,6 +565,66 @@ final class ParserImpl implements Parser { return result; } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static final void parseDelimiterSpecifications(ParserContext ctx) { while (parseKeywordIf(ctx, "DELIMITER")) ctx.delimiter(parseUntilEOL(ctx).trim()); @@ -2792,7 +2853,7 @@ final class ParserImpl implements Parser { throw ctx.expected("ADD", "ALTER", "COMMENT", "DROP", "MODIFY", "RENAME"); } - private static DDLQuery parseAlterTableAdd(ParserContext ctx, AlterTableStep s1, Table tableName) { + private static final DDLQuery parseAlterTableAdd(ParserContext ctx, AlterTableStep s1, Table tableName) { List list = new ArrayList(); if (((parseKeywordIf(ctx, "SPATIAL INDEX")