Author: desruisseaux
Date: Wed Aug 7 18:02:03 2013
New Revision: 1511422
URL: http://svn.apache.org/r1511422
Log:
Missing 'return null' statement when the given type is legal but no instance is
available.
This is different than throwing an exception when the given type is illegal.
Modified:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
Modified:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1511422&r1=1511421&r2=1511422&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] Wed Aug 7 18:02:03 2013
@@ -584,11 +584,13 @@ public class StorageConnector implements
if (type == Connection.class) {
if (storage instanceof Connection) {
return storage;
- } else if (storage instanceof DataSource) {
+ }
+ if (storage instanceof DataSource) {
final Connection c = ((DataSource) storage).getConnection();
addViewToClose(c, storage);
return c;
}
+ return null;
}
if (type == ImageInputStream.class) {
final DataInput input = getStorageAs(DataInput.class);
@@ -607,6 +609,7 @@ public class StorageConnector implements
addViewToClose(c, input);
return c;
}
+ return null;
}
if (type == Reader.class) {
if (storage instanceof Reader) {
@@ -620,6 +623,7 @@ public class StorageConnector implements
addViewToClose(c, input);
return c;
}
+ return null;
}
throw new
IllegalArgumentException(Errors.format(Errors.Keys.UnknownType_1, type));
}
Modified:
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java?rev=1511422&r1=1511421&r2=1511422&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] Wed Aug 7 18:02:03 2013
@@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
+import java.sql.Connection;
import org.apache.sis.internal.storage.ChannelDataInput;
import org.apache.sis.internal.storage.ChannelImageInputStream;
import org.apache.sis.test.DependsOnMethod;
@@ -265,6 +266,18 @@ public final strictfp class StorageConne
}
/**
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link Connection} type.
+ *
+ * @throws DataStoreException Should never happen.
+ * @throws IOException Should never happen.
+ */
+ public void testGetAsConnection() throws DataStoreException, IOException {
+ final StorageConnector connection = create(false);
+ assertNull(connection.getStorageAs(Connection.class));
+ connection.closeAllExcept(null);
+ }
+
+ /**
* Tests the {@link StorageConnector#closeAllExcept(Object)} method.
*
* @throws DataStoreException Should never happen.