From 891480e9d2a11848b84fae942274d9644b9106cf Mon Sep 17 00:00:00 2001 From: rjung Date: Fri, 15 Jul 2011 07:48:27 +0000 Subject: [PATCH] Missing svn:eol-style. Please fix your svn config. Thanks. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1146994 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tomcat/jdbc/pool/TrapException.java | 158 ++++++++++----------- .../java/org/apache/tomcat/jdbc/test/Bug50571.java | 78 +++++----- res/maven/tomcat-jdbc.pom | 64 ++++----- 3 files changed, 150 insertions(+), 150 deletions(-) diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/TrapException.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/TrapException.java index 7654ef09d..0fa3920e3 100644 --- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/TrapException.java +++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/TrapException.java @@ -1,79 +1,79 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -package org.apache.tomcat.jdbc.pool; - - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.sql.SQLException; -/** - * Interceptor that traps any unhandled exception types and throws an exception that has been declared by the method - * called, or throw a SQLException if it is declared. - * If the caught exception is not declared, and the method doesn't throw SQLException, then this interceptor will - * throw a RuntimeException - * @author fhanik - * - */ -public class TrapException extends JdbcInterceptor { - - - public TrapException() { - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - try { - return super.invoke(proxy, method, args); - }catch (Exception t) { - Throwable exception = t; - if (t instanceof InvocationTargetException) { - exception = t.getCause()!=null?t.getCause():t; - } - Class exceptionClass = exception.getClass(); - if (!isDeclaredException(method, exceptionClass)) { - if (isDeclaredException(method,SQLException.class)) { - SQLException sqlx = new SQLException("Uncaught underlying exception."); - sqlx.initCause(exception); - exception = sqlx; - } else { - RuntimeException rx = new RuntimeException("Uncaught underlying exception."); - rx.initCause(exception); - exception = rx; - } - } - throw exception; - } - - } - - public boolean isDeclaredException(Method m, Class clazz) { - for (Class cl : m.getExceptionTypes()) { - if (cl.equals(clazz) || cl.isAssignableFrom(clazz)) return true; - } - return false; - } - - /** - * no-op for this interceptor. no state is stored. - */ - @Override - public void reset(ConnectionPool parent, PooledConnection con) { - // NOOP - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.tomcat.jdbc.pool; + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.sql.SQLException; +/** + * Interceptor that traps any unhandled exception types and throws an exception that has been declared by the method + * called, or throw a SQLException if it is declared. + * If the caught exception is not declared, and the method doesn't throw SQLException, then this interceptor will + * throw a RuntimeException + * @author fhanik + * + */ +public class TrapException extends JdbcInterceptor { + + + public TrapException() { + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + try { + return super.invoke(proxy, method, args); + }catch (Exception t) { + Throwable exception = t; + if (t instanceof InvocationTargetException) { + exception = t.getCause()!=null?t.getCause():t; + } + Class exceptionClass = exception.getClass(); + if (!isDeclaredException(method, exceptionClass)) { + if (isDeclaredException(method,SQLException.class)) { + SQLException sqlx = new SQLException("Uncaught underlying exception."); + sqlx.initCause(exception); + exception = sqlx; + } else { + RuntimeException rx = new RuntimeException("Uncaught underlying exception."); + rx.initCause(exception); + exception = rx; + } + } + throw exception; + } + + } + + public boolean isDeclaredException(Method m, Class clazz) { + for (Class cl : m.getExceptionTypes()) { + if (cl.equals(clazz) || cl.isAssignableFrom(clazz)) return true; + } + return false; + } + + /** + * no-op for this interceptor. no state is stored. + */ + @Override + public void reset(ConnectionPool parent, PooledConnection con) { + // NOOP + } + +} diff --git a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java index 8a5650cbe..2fd5411f4 100644 --- a/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java +++ b/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java @@ -1,39 +1,39 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ -package org.apache.tomcat.jdbc.test; - -import org.apache.tomcat.jdbc.pool.interceptor.ConnectionState; - -public class Bug50571 extends DefaultTestCase{ - - public Bug50571(String name) { - super(name); - } - - @Override - public void setUp() throws Exception { - super.setUp(); - this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE"); - this.datasource.setJdbcInterceptors(ConnectionState.class.getName()); - this.datasource.setDefaultTransactionIsolation(-55); - this.datasource.setInitialSize(1); - } - - public void testBug50571() throws Exception { - this.datasource.getConnection().close(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ +package org.apache.tomcat.jdbc.test; + +import org.apache.tomcat.jdbc.pool.interceptor.ConnectionState; + +public class Bug50571 extends DefaultTestCase{ + + public Bug50571(String name) { + super(name); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE"); + this.datasource.setJdbcInterceptors(ConnectionState.class.getName()); + this.datasource.setDefaultTransactionIsolation(-55); + this.datasource.setInitialSize(1); + } + + public void testBug50571() throws Exception { + this.datasource.getConnection().close(); + } +} diff --git a/res/maven/tomcat-jdbc.pom b/res/maven/tomcat-jdbc.pom index 89e274b9f..100b38308 100644 --- a/res/maven/tomcat-jdbc.pom +++ b/res/maven/tomcat-jdbc.pom @@ -1,32 +1,32 @@ - - - - 4.0.0 - org.apache.tomcat - tomcat-jdbc - @MAVEN.DEPLOY.VERSION@ - Tomcat JDBC Pool Package - - - org.apache.tomcat - tomcat-jdbc - @MAVEN.DEPLOY.VERSION@ - compile - - - + + + + 4.0.0 + org.apache.tomcat + tomcat-jdbc + @MAVEN.DEPLOY.VERSION@ + Tomcat JDBC Pool Package + + + org.apache.tomcat + tomcat-jdbc + @MAVEN.DEPLOY.VERSION@ + compile + + + -- 2.11.0